Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- term.clear()
- term.setCursorPos(1,1)
- local username, password
- print("Withdraw Cash")
- print("---------------------------------------------------")
- print("")
- io.write("Username: ")
- username = io.read()
- print("")
- io.write("Password: ")
- password = read("*")
- rednet.send(0, username, "getAccount")
- local senderId, message, protocol = rednet.receive()
- term.clear()
- term.setCursorPos(1,1)
- if message == "dns" then
- print("User does not exist. Please create an account")
- sleep(2)
- os.reboot()
- end
- if password == message[3] then
- local done = false
- while not done do
- term.clear()
- term.setCursorPos(1,1)
- print("Current Balance: "..message[4].."$")
- print("---------------------------------------------------")
- print("")
- print("Please enter the amount you wish to withdraw")
- print("Enter 'exit' to exit")
- print("")
- io.write("Amount to withdraw: ")
- local amount = io.read()
- if amount == "exit" then
- os.reboot()
- end
- if tonumber(amount) == nil then
- term.clear()
- term.setCursorPos(1,1)
- print("Please enter a number...")
- sleep(2)
- else
- amount = tonumber(amount)
- if amount > message[4] then
- term.clear()
- term.setCursorPos(1,1)
- print("You have insufficient funds")
- sleep(2)
- else
- rednet.send(10, {message[2], amount}, "withdraw")
- local senderId, success, protocol = rednet.receive()
- term.clear()
- term.setCursorPos(1,1)
- if success == true then
- rednet.send(0, {username, message[4] - amount}, "editBalance")
- print("Withdrawal complete...")
- print("New balance: "..message[4] - amount.."$")
- print("")
- print("Press any key to continue...")
- os.pullEvent("key")
- os.reboot()
- else
- print("Withdrawal failed...")
- print("Perhaps you spelled your MC name wrong.")
- print("Press any key to continue...")
- os.pullEvent("key")
- os.reboot()
- end
- end
- end
- end
- else
- print("Incorrect password. Please try again")
- sleep(2)
- os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement