Posted 29 May 2016 - 03:44 PM
if i get a KEYREQ message i get a error that says: rednet:87 Expected number.
can someone help?
term.setTextColor(colors.blue)
term.clear()
term.setCursorPos(1,1)
print("Server started!")
print("————————")
rednet.open("back")
while true do
id,msg = rednet.receive()
print("Listening")if msg == "SENDING" then
stringid = tostring(id)
print("Got MSG from:",stringid)
if fs.exists(stringid) == false then
print("File does not exist")
else
local file1 = fs.open(stringid,"w")
contents = file1.readAll()
file1.close()
print("Requesting password")
rednet.send(id,"REQKEY")
id1, msg1 = rednet.receive(10)
end
end
if contents == msg1 then
rednet.send(id1,"scs")
print(stringid,"Logged in successfully")
end
if msg == "KEYREQ" then
print("File already exists!")
else
print("Got MSG2 from:",stringid)
random = math.random(1000000,10000000)
stringrandom = tostring(random)
print("Generated random")
rednet.send(id,stringrandom)
print("Sent Password")
id2, msg2 = rednet.receive()
local file = fs.open(stringid,"w")
file.write(msg2)
file.close()
end
end
can someone help?
term.setTextColor(colors.blue)
term.clear()
term.setCursorPos(1,1)
print("Server started!")
print("————————")
rednet.open("back")
while true do
id,msg = rednet.receive()
print("Listening")if msg == "SENDING" then
stringid = tostring(id)
print("Got MSG from:",stringid)
if fs.exists(stringid) == false then
print("File does not exist")
else
local file1 = fs.open(stringid,"w")
contents = file1.readAll()
file1.close()
print("Requesting password")
rednet.send(id,"REQKEY")
id1, msg1 = rednet.receive(10)
end
end
if contents == msg1 then
rednet.send(id1,"scs")
print(stringid,"Logged in successfully")
end
if msg == "KEYREQ" then
print("File already exists!")
else
print("Got MSG2 from:",stringid)
random = math.random(1000000,10000000)
stringrandom = tostring(random)
print("Generated random")
rednet.send(id,stringrandom)
print("Sent Password")
id2, msg2 = rednet.receive()
local file = fs.open(stringid,"w")
file.write(msg2)
file.close()
end
end