PaymentOption

keyServer

May 28th, 2012
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. --[[
  2. function checkKey(sKey)
  3.     rednet.send(nServerID, tostring(sKey))
  4.    
  5.     sender, message = rednet.receive(1)
  6.    
  7.     if sender == nServerID then
  8.         if message ~= "authentic" then bAuthentic = false; return false
  9.         else bAuthentic = true; return true end
  10.     end
  11. end
  12. --]]
  13.  
  14. rednet.open("top")
  15. rednet.open("bottom")
  16. rednet.open("back")
  17. rednet.open("front")
  18. rednet.open("right")
  19. rednet.open("left")
  20.  
  21. while true do
  22.     sender, message = rednet.receive()
  23.    
  24.     if message == "CHECKMYKEY" then
  25.         print("Checking KEY")
  26.         confirmSender, message = rednet.receive(0.8)
  27.        
  28.         if confirmSender == sender then
  29.             file = fs.open("keyList", "r")
  30.             for i=1, 10000 do
  31.                 local fileContents = file.readLine()
  32.                
  33.                 if fileContents == message then rednet.send(confirmSender, "authentic"); print("Key confirmed"); break end
  34.             end
  35.             file.close()
  36.         else print("Lost connection...") end
  37.     end
  38. end
Advertisement
Add Comment
Please, Sign In to add comment