Jump to content




I need help with the code

help wireless networking

3 replies to this topic

#1 gergo654

  • Members
  • 8 posts

Posted 29 May 2016 - 02: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

#2 TYKUHN2

  • Members
  • 210 posts
  • LocationSomewhere in this dimension... I think.

Posted 29 May 2016 - 05:12 PM

In my case, it's because contents = nil and msg1 = nil so it tried to use id1 which is nil.

File from which contents comes from is not created on my end

Edited by TYKUHN2, 29 May 2016 - 05:13 PM.


#3 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 29 May 2016 - 07:26 PM

What is the last thing that gets printed?

#4 gergo654

  • Members
  • 8 posts

Posted 01 June 2016 - 07:47 AM

i already fixed it but thank for the help :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users