Advertisement
albrat

CC Pass client V2

Jul 18th, 2013
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.85 KB | None | 0 0
  1.    
  2.     oldpull = os.pullEvent
  3.     os.pullEvent = os.pullEventRaw -- remove the CTRL + T escape
  4.      
  5.     -- Local variables
  6.      
  7.     local cmpid = os.getComputerID()
  8.     local locker = true  -- Technically I no longer use this varible. it used to define the loop for my login.
  9.     local failed = true
  10.     local attempted_login = true
  11.     local password_server = 10 -- change to the ID of your password server computer
  12.     local moside = "top"  -- This is your modem location :- top, bottom, left, right, back or front
  13.      
  14.     print("Computer ID : ".. cmpid)
  15.     rednet.open(moside)  -- open the Rednet modem.
  16.      
  17.      
  18.     while true do  -- infinite loop
  19.      attempted_login = false  -- reset the varible
  20.      term.clear()
  21.      term.setCursorPos(1,1)
  22.      print("Welcome to a Client PC")
  23.      print("What would you like to do?")
  24.      print("[1] Login (*)")
  25.      print("[2] Shutdown")
  26.      
  27.      -- end of the menu
  28.      
  29.      write("> ")
  30.      local input = read()
  31.      
  32.      if input == "2" then  -- reverse order shall we shut down ?
  33.       os.shutdown()
  34.      
  35.      elseif input == "1" then -- if not then lets do something maybe ?
  36.       attempted_login = true
  37.       print("Please login...")
  38.      
  39.       -- Username
  40.      
  41.       write("Username: ")
  42.       local username = read()  -- Get input of Username
  43.      
  44.       -- Password
  45.      
  46.       write("Password: ")
  47.       local password = read("*") -- Get masked input of Password
  48.      
  49.       local testmessage = username .. " " .. password  -- make our rednet message with seperator
  50.      
  51.       if debug then print(testmessage);sleep(5); end  -- Debug testing to check the message
  52.      
  53.       rednet.send(password_server, testmessage, true)
  54.       senderId, message, distance = rednet.receive(5)
  55.       if message == "valid" then  -- did the server send the message "valid" ?
  56.        failed = false
  57.        
  58.        --[[
  59.        locker = false  -- here is the non used Locker again, at this point it would unlock us from the loop.
  60.        -- the while true do makes that line obsolete.
  61.        --]]
  62.        
  63.        term.clear()
  64.        term.setCursorPos(1,1)
  65.        print("Welcome ", username) -- Welcome the user.
  66.        printError("Command restored")
  67.        os.pullEvent = oldpull
  68.        error()
  69.        
  70.        --[[ This next section is my door opening server. Send the open and close commands
  71.        -- to the door server, plus the wait time of 6 seconds to get out the terminal and through the door
  72.         rednet.send(17, "open")
  73.             sleep(6)
  74.             rednet.send(17, "close")
  75.             --]]
  76.            
  77.       else  -- The server sent a non valid respone.
  78.        print("Invalid Username or Password.")
  79.        sleep(3)
  80.       end
  81.      
  82.       -- If you did not type 1 or 2... I have no idea...
  83.      
  84.      else  
  85.       print("Command not recognised...")
  86.       sleep(2)
  87.      end
  88.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement