Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- serverID = 3
- registerID = 33
- ausername = "admin"
- apassword = "password"
- function connect()
- rednet.open("top")
- end
- success = pcall(connect)
- if not success then
- os.reboot()
- end
- function conductTransaction(username, password, cost)
- message = "buy " .. username .. " " .. password .. " " .. cost
- rednet.send(serverID, message)
- id, value = rednet.receive(nil, 3)
- os.sleep(1)
- return value
- end
- function checkCredentials(username, password)
- message = "search " .. username .. " " .. password
- rednet.send(serverID, message)
- id, value = rednet.receive(nil, 3)
- os.sleep(1)
- return value
- end
- while true do
- shell.run("clear")
- print("Please Complete Your Order with the Assistant")
- id, cost = rednet.receive()
- print("Username: ")
- username = read()
- print("Password: ")
- password = read("*")
- if username == ausername and password == apassword then
- os.exit(1)
- end
- balance = checkCredentials(username, password)
- if balance == nil then
- print("Connection to Server Failed")
- os.sleep(3)
- elseif balance == "false" then
- print("Account Not Found")
- os.sleep(3)
- else
- success = conductTransaction(username, password, cost)
- if success == "nil" then
- print("Transaction Connection to Server Failed")
- os.sleep(3)
- elseif success == "false" then
- print("Transaction Failed")
- print("Account Value: " .. balance)
- os.sleep(5)
- else
- rednet.send(registerID, "true")
- print("Success!")
- os.sleep(3)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement