Advertisement
AnonGaming

Untitled

Mar 2nd, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. local users = {}
  2.  
  3. users["anon"] = {}
  4. users["anon"]["pass"] = "testPass"
  5. users["anon"]["rank"] = "owner"
  6.  
  7.  
  8. users["danny"] = {}
  9. users["danny"]["pass"] = "jimmy69"
  10. users["danny"]["rank"] = "owner"
  11.  
  12.  
  13. users["akemi"] = {}
  14. users["akemi"]["pass"] = "password"
  15. users["akemi"]["rank"] = "admin"
  16.  
  17. local ranks = {}
  18. ranks["owner"] = {}
  19. ranks["admin"] = {}
  20. ranks["mod"] = {}
  21. ranks["user"] = {}
  22.  
  23.  
  24. function split(pString, pPattern)
  25.    local Table = {}  -- NOTE: use {n = 0} in Lua-5.0
  26.    local fpat = "(.-)" .. pPattern
  27.    local last_end = 1
  28.    local s, e, cap = pString:find(fpat, 1)
  29.    while s do
  30.           if s ~= 1 or cap ~= "" then
  31.          table.insert(Table,cap)
  32.           end
  33.           last_end = e+1
  34.           s, e, cap = pString:find(fpat, last_end)
  35.    end
  36.    if last_end <= #pString then
  37.           cap = pString:sub(last_end)
  38.           table.insert(Table, cap)
  39.    end
  40.    return Table
  41. end
  42.  
  43.  
  44. rednet.open("top")
  45.  
  46. while true do
  47.  
  48.     senderID,message = rednet.receive(1000)
  49.      
  50.      
  51.     if message == "userServer" then
  52.    
  53.         rednet.send(senderID,"19")
  54.     else
  55.    
  56.      
  57.      
  58.         local tab = split(message," ")
  59.        
  60.         local username = tab[2]
  61.         local pass = tab[3]
  62.         local rank = tab[4]
  63.         local cmd = tab[1]
  64.        
  65.        
  66.        
  67.        
  68.         if cmd == "auth" then
  69.             print(username)
  70.             if users[username] then
  71.                
  72.                 if users[username]["pass"] == pass then
  73.                     print("Correct Details")
  74.                     local usrRank = users[username]["rank"]
  75.                    
  76.                     if string.find(rank,usrRank) then
  77.                         rednet.send(senderID,"Authed")
  78.                     else
  79.                         rednet.send(senderID,"Not authed for this area")
  80.                     end
  81.                    
  82.                    
  83.                 else
  84.                     print("Incorrect Details")
  85.                     rednet.send(senderID,"Incorrect Pass")
  86.                 end
  87.             else
  88.                 print("No User")
  89.                 rednet.send(senderID,"Unknown User")
  90.             end
  91.            
  92.            
  93.         end
  94.    
  95.     end
  96.    
  97.      
  98.     print("Message: "..message)
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement