Advertisement
clark

password to become user group

Sep 30th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. // https://i.imgur.com/UN0Pcbv.png
  2. // https://forum.facepunch.com/f/gmoddev/btrsh/I-want-to-make-command-so-that-the-user-has-to-enter-a-password-to-become-admin/
  3.  
  4. if CLIENT then return end
  5.  
  6. local Passwords = {
  7.     ['admin'] = "YWRtaW4=",
  8.     ['superadmin'] = "c3VwZXJhZG1pbg==",
  9.     ['user'] = "dXNlcg==",
  10. }
  11.  
  12. local Player = FindMetaTable("Player")
  13.  
  14. function becomeAdmin(ply, pass)
  15.     if !pass then return end
  16.    
  17.     for k, v in pairs(Passwords) do
  18.         if pass == v then
  19.             ply:SetNWString("UserGroup", k)
  20.             ply:ChatPrint("Your usergroup was changed to '" ..  k .. "'.")
  21.         end
  22.     end
  23. end
  24.  
  25. hook.Add("PlayerSay", "_PlayerSay", function(ply, txt, tm)
  26.     local cmd, args, str
  27.    
  28.     str = txt
  29.    
  30.     if string.Left(txt, 1) == "!" then
  31.         txt = txt:gsub( "^.(%S+)", function( match )
  32.             cmd = match
  33.             return ""
  34.         end, 1)
  35.     end
  36.    
  37.     args = string.Explode(" ", txt)
  38.     table.remove(args, 1)
  39.    
  40.     if cmd == "password" then
  41.         becomeAdmin(ply, args[1])
  42.        
  43.         return ""
  44.     end
  45. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement