Guest User

server

a guest
Aug 5th, 2016
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. local usePrinter = true
  2. -- If you put this to true, put a Printer to the
  3. -- right of the Server Computer.
  4. local printer = nil
  5. if usePrinter == true then
  6.   printer = peripheral.wrap("right")
  7. end
  8.  
  9. term.clear()
  10. term.setCursorPos(1, 1)
  11. term.setTextColor(colors.purple)
  12. print("Starting Login Server...")
  13.  
  14. local accounts = {
  15. {"DataIsLoading", "bxe9w123"}
  16. }
  17.  
  18. print("Loaded Accounts.")
  19. rednet.open("top")
  20. print("Started RedNet.")
  21.  
  22. while true do
  23.   id, username, password = rednet.receive()
  24.   if username == "RequestStatus" then
  25.     rednet.send(id, mode, true)
  26.   else
  27.  
  28.     for _, Account in ipairs(accounts) do
  29.     if username == Account[1] then
  30.       if password == Account[2] then
  31.         rednet.send(id, true)
  32.         print("["..username.."] Connection accepted.")
  33.         if usePrinter == true then
  34.         local page = printer.newPage()
  35.           printer.write("New Connection Access")
  36.           printer.setCursorPos(1, 3)
  37.           printer.write("Access Granted.")
  38.           printer.setPageTitle("Access Request: "..username)
  39.           printer.endPage()
  40.         end
  41.       else
  42.         rednet.send(id, false)
  43.       end
  44.     else
  45.       rednet.send(id, false)
  46.     end
  47.   end
  48.   end
  49. end
Add Comment
Please, Sign In to add comment