SHARE
TWEET

server.lua

a guest Sep 20th, 2019 162 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rednet.open("top")
  2.  
  3. users = {
  4.     [1] = {user = "Trey", pass = "test", priv = 5, id = 22, ign = "Trey2k"},
  5.     [2] = {user = "shoe", pass = "abc", priv = 1, id = 25, ign = "i_am_a_shoe"},
  6. }
  7. umsg = {}
  8. --for k,v in pairs(users) do print(k.." : "..v.user) end
  9. function login(u, p)
  10. stk = {" ", false}
  11.     for k,v in pairs(users) do
  12.         if v.user == u and v.pass == p then
  13.             stk = {k, true}
  14.         end
  15.     end
  16.     print(stk[2])
  17.     if stk[2] == true then
  18.         return true
  19.     else
  20.         return false
  21.     end
  22. end
  23.  
  24. function rnet()
  25. umsg = {}
  26.     id, content = rednet.receive()
  27.     if textutils.unserialise(content) then
  28.         umsg = textutils.unserialise(content)
  29.     end
  30. end
  31.  
  32.  
  33. function encrypt(string)
  34.     local out = ""
  35.     for i = 1, #string do
  36.         local char = string:sub(i,i)
  37.         local sNum = char:byte()
  38.         local oNum = sNum + 47
  39.         if oNum > 127 then
  40.             oNum = oNum - 94
  41.         end
  42.         out = out .. string.char(oNum)
  43.     end
  44.     return out
  45. end
  46.  
  47. function decrypt(string)
  48.     local out = string.gsub(encrypt(string),"~"," ")
  49.     return out
  50. end
  51.  
  52. function comm()
  53. local asd = stk[1]
  54.     if umsg.cat == "exec" then
  55.         commands.exec(umsg.cmd)
  56.     elseif umsg.cat == "heal" then
  57.         print(users[asd].ign)
  58.         commands.exec("heal "..users[asd].ign)
  59.     end
  60.    
  61. end
  62.  
  63. --login("i_am_a_shoe", "abc")
  64. while true do
  65.     rnet()
  66.    if login(umsg.user, umsg.pass) then
  67.        print("Successful Login: "..umsg.user)
  68.        print(umsg.user.." Attempted to run "..umsg.cmd)
  69.        comm()
  70.     else
  71.         print("Invalid Packet: "..content)
  72.     end
  73. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top