10 posts
Posted 08 April 2013 - 03:01 AM
Hello !
For my server, i'm creating a bank system. I search how to send (by rednet) several variables. I test :
http://www.computerc...rednet-message/http://www.computerc...rednet-message/and
local send = pseudo .. password
rednet.send(32, send)
and that not's working, that write : rednet:11: string expected. Where is the problem ? :(/>
I'm very sorry for my bad english, i'm french.
169 posts
Posted 08 April 2013 - 03:09 AM
For some reason, the send variable is not a string. Without seeing the rest of your code (that is, where you declare pseudo and password), I don't know how to help you.
10 posts
Posted 08 April 2013 - 03:15 AM
version = "BIM - Banque Internationale MineCube - Version 1.0"
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.lime)
print(" ######## #### ## ## ")
print(" ## ## ## ### ### ")
print(" ## ## ## #### #### ")
print(" ######## ## ## ### ## ")
print(" ## ## ## ## ## ")
print(" ## ## ## ## ## ")
print(" ######## #### ## ## ")
term.setTextColor(colors.orange)
print(" ")
print(" + - - - - - - - - - - - - - - - - - - - - +")
print(" I Connexion - Espace sécurisé I")
print(" I I")
print(" I Identifiant : I")
print(" I Mot de passe : I")
print(" I I")
print(" + - - - - - - - - - - - - - - - - - - - - +")
print(" ")
term.setTextColor(colors.lime)
print(version)
term.setCursorPos(24,12)
pseudo = read()
term.setCursorPos(24,13)
password = read("*")
rednet.open(top)
local send = pseudo .. password
rednet.send(32, send)
sleep(2)
os.shutdown()
For the moment, I have not installing a security system (sha1). Thank you ;)/>
515 posts
Location
Australia
Posted 08 April 2013 - 03:47 AM
rednet.open(top) should be rednet.open("top")
169 posts
Posted 08 April 2013 - 04:32 AM
Yeah, looks like I was wrong about what was causing the problem. 1lann has it right.
2217 posts
Location
3232235883
Posted 08 April 2013 - 04:49 AM
soooo, your effectively broadcasting the password
10 posts
Posted 08 April 2013 - 06:52 AM
Thank you ! I have an other problem, how I can save in the server computer (fs) several informations (username (name of the file), password, the money, and, maybe the "logs") ?
I want to read the first line of the file to find the true password, and on the second line the money currently, it's possible ?
Thanks you ;)/>
36 posts
Posted 08 April 2013 - 09:58 AM
use the fs-API
for example:
z = "USERNAME"
y = "USERPASS"
local file = fs.open("<YOURFILE>", "w") -- open File in write mode
file.writeLine(z) ---writing the variable "z" in the first Line
file.writeLine(y) ---writing the variable "y" in the second Line
Now the File looks like this:
USERNAME
USERPASS
To read the information you can use:
local file = fs.open("<YOURFILE>","r") --open File in read mode
userdata = {} ---clear the table "userdata"
local line = file.readLine() --read the first Line of the File
repeat --repeat the following
table.insert(userdata, line) --insert the line into the table
local line = file.readLine() --read the next line of the file
until line == nil --stop reading the file, if there're no more lines
local username = userdata[1] --Take the username from the table
local password = userdata[2] ---Take the userpassword from the table
the rest should be known ;)/>
2217 posts
Location
3232235883
Posted 08 April 2013 - 10:16 AM
more compact (and fixed) version:
local file = io.open("<YOURFILE>","r") -- open File in read mode (use io API instead)
local userdata = {} -- make and localize the table "userdata"
for line in file:lines() do --repeat the following
table.insert(userdata, line) --insert the line into the table
end --stop reading the file, if there're no more lines
-- dont need to close the handle because lines does it for us
local username = userdata[1] --Take the username from the table
local password = userdata[2] ---Take the password from the table
10 posts
Posted 09 April 2013 - 07:32 AM
Hum ..
I wrote that, and I don't understand, the screen is always black :
term.clear()
term.setCursorPos(1,1)
rednet.open("left")
while true do
event, senderId, message, distance = os.pullEvent("rednet_message")
if senderId == 35 then
table = textutils.unserialize(message)
pseudo = table[1]
password = table[2]
ask1 = table[3]
ask2 = table[4]
if ask1 == "exist" then
folder = "/comptes/"
extension = ".txt"
file = folder..pseudo..extension
if fs.exists(file) then
local file = io.open(file) -- open File in read mode (use io API instead)
local userdata = {} -- make and localize the table "userdata"
for line in file:lines() do --repeat the following
table.insert(userdata, line) --insert the line into the table
end --stop reading the file, if there're no more lines
-- dont need to close the handle because lines does it for us
local username = userdata[1] --Take the username from the table
local pass = userdata[2] ---Take the password from the table
print(username)
print(pass)
end
end
else
rednet.send(senderId, "Nos machines sont protégées contre le hack.")
end
end
2217 posts
Location
3232235883
Posted 09 April 2013 - 09:51 AM
change
local file = io.open(file) -- open File in read mode (use io API instead)
to
local file = io.open(file,"r") -- open File in read mode (use io API instead)
and we need to see the program that sends the message
10 posts
Posted 10 April 2013 - 06:43 AM
I changed the program who check the accounts.
The program that sends the message :
version = "BIM - Banque Internationale MineCube - Version 1.0"
ask1 = "exist"
ask2 = "money"
function Logo()
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.lime)
print(" ######## #### ## ## ")
print(" ## ## ## ### ### ")
print(" ## ## ## #### #### ")
print(" ######## ## ## ### ## ")
print(" ## ## ## ## ## ")
print(" ## ## ## ## ## ")
print(" ######## #### ## ## ")
end
Logo()
term.setTextColor(colors.orange)
print(" ")
print(" + - - - - - - - - - - - - - - - - - - - - +")
print(" I Connexion - Espace sécurisé I")
print(" I I")
print(" I Identifiant : I")
print(" I Mot de passe : I")
print(" I I")
print(" + - - - - - - - - - - - - - - - - - - - - +")
print(" ")
term.setTextColor(colors.lime)
print(version)
term.setCursorPos(24,12)
pseudo = read()
term.setCursorPos(24,13)
password = read("*")
rednet.open("top")
table = {pseudo, password, ask1, ask2}
message = textutils.serialize(table)
rednet.send(32, message)
Logo()
term.setTextColor(colors.orange)
print(" ")
print(" + - - - - - - - - - - - - - - - - - - - - +")
print(" I Connexion - Espace sécurisé I")
print(" I I")
print(" I Attente de réponse du serveur ... I")
print(" I I")
print(" I I")
print(" + - - - - - - - - - - - - - - - - - - - - +")
print(" ")
sleep(2)
os.shutdown()
10 posts
Posted 12 April 2013 - 09:17 AM
Up
10 posts
Posted 21 April 2013 - 07:47 AM
Up please :(/>
7508 posts
Location
Australia
Posted 21 April 2013 - 07:56 AM
Up
Up please :(/>
Uhh what now? Up? are you meaning bump?
What is the latest error?
10 posts
Posted 08 May 2013 - 06:41 AM
Hum .. I wrote that, and I don't understand, the screen is always black :
Please help me :/
10 posts
Posted 15 May 2013 - 08:27 AM
Hum .. I wrote that, and I don't understand, the screen is always black :
Please help me :/
10 posts
Posted 19 May 2013 - 12:04 PM
Why the server computer is always black ?