Advertisement
CelticCoder

checkoutComputer

Jun 16th, 2024 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. serverID = 3
  3. registerID = 33
  4. ausername = "admin"
  5. apassword = "password"
  6.  
  7. function connect()
  8.     rednet.open("top")
  9. end
  10.  
  11. success = pcall(connect)
  12. if not success then
  13.     os.reboot()
  14. end
  15.  
  16. function conductTransaction(username, password, cost)
  17.   message = "buy " .. username .. " " .. password .. " " .. cost
  18.   rednet.send(serverID, message)
  19.   id, value = rednet.receive(nil, 3)
  20.   os.sleep(1)
  21.   return value
  22. end
  23.  
  24. function checkCredentials(username, password)
  25.   message = "search " .. username .. " " .. password
  26.   rednet.send(serverID, message)
  27.   id, value = rednet.receive(nil, 3)
  28.   os.sleep(1)
  29.   return value
  30. end
  31.  
  32. while true do
  33.     shell.run("clear")
  34.     print("Please Complete Your Order with the Assistant")
  35.     id, cost = rednet.receive()
  36.     print("Username: ")
  37.     username = read()
  38.     print("Password: ")
  39.     password = read("*")
  40.     if username == ausername and password == apassword then
  41.         os.exit(1)
  42.     end
  43.     balance = checkCredentials(username, password)
  44.     if balance == nil then
  45.         print("Connection to Server Failed")
  46.         os.sleep(3)
  47.     elseif balance == "false" then
  48.         print("Account Not Found")
  49.         os.sleep(3)
  50.     else
  51.         success = conductTransaction(username, password, cost)
  52.         if success == "nil" then
  53.             print("Transaction Connection to Server Failed")
  54.             os.sleep(3)
  55.         elseif success == "false" then
  56.             print("Transaction Failed")
  57.             print("Account Value: " .. balance)
  58.             os.sleep(5)
  59.         else
  60.             rednet.send(registerID, "true")
  61.             print("Success!")
  62.             os.sleep(3)
  63.         end
  64.     end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement