Posted 04 July 2017 - 04:20 PM
Hi.
A currency system I am making is getting me stumped with the wireless modems not communicating.
I have 2 computers: a server and an ATM (client).
The client makes a login request to the server.
When I type any random username and password, the program continues like it should. But when I type a username that is in the users/ folder, all computers just freeze, no matter if my password is correct or incorrect.
If anybody could follow along in the program and spot out any issues, please feel free to tell me so.
Client Snippet
Server Snippet
A currency system I am making is getting me stumped with the wireless modems not communicating.
I have 2 computers: a server and an ATM (client).
The client makes a login request to the server.
When I type any random username and password, the program continues like it should. But when I type a username that is in the users/ folder, all computers just freeze, no matter if my password is correct or incorrect.
If anybody could follow along in the program and spot out any issues, please feel free to tell me so.
Client Snippet
clear()
print("[Login to debit account]")
print(" ")
rednet.open("top")
rednet.broadcast("login")
write("Username: ")
uInput = read()
rednet.broadcast(uInput)
write("Password: ")
pInput = read("*")
rednet.broadcast(pInput)
local q,w,e = rednet.receive()
if w == "notExist" then
clear()
print("[Login to debit account]")
print(" ")
term.setTextColor(colors.red)
textutils.slowPrint("Username or password does not match.")
term.setTextColor(colors.black)
sleep(2)
shell.run("login")
end
local s,m,p = rednet.receive()
if m == "correct" then
shell.run("menu")
elseif m == "incorrect" then
clear()
print("[Login to debit account]")
print(" ")
term.setTextColor(colors.red)
textutils.slowPrint("Username or password does not match.")
term.setTextColor(colors.black)
sleep(2)
shell.run("login")
end
Server Snippet
elseif m == "login" then
local s,m,p = rednet.receive() -- username
local s2,m2,p2 = rednet.receive() -- password
local h = fs.exists("users/"..m)
if h == true then
local h = fs.open("users/"..m.."/password", "r")
local pass = h.readLine()
h.close()
if m2 == pass then
rednet.broadcast("correct")
os.reboot()
else
rednet.broadcast("incorrect")
os.reboot()
end
else
rednet.broadcast("notExist")
os.reboot()
end
end
end