Advertisement
Guest User

Untitled

a guest
Jan 1st, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. PLUGIN_NAME = "setadmin workaround"
  2. PLUGIN_AUTHOR = "Sveark"
  3. PLUGIN_VERSION = "nonnative"
  4.  
  5.  
  6. -- brains
  7.  
  8. local command = "!setadmin"
  9.  
  10. -- skeleton
  11.  
  12. function string.startsWith(haystack, needle)
  13.   return string.sub(haystack, 1, string.len(needle)) == needle
  14. end
  15.  
  16. function string.trim(str)
  17.   return str:match'^()%s*$' and '' or str:match'^%s*(.*%S)'
  18. end
  19.  
  20. -- muscle
  21.  
  22. function onPlayerSayText(cn, text)
  23.   if text:trim():startsWith(command) then
  24.     local arg = text:sub(command:len() + 1):trim()
  25.     local passwords = getadminpwds()
  26.     for line, password in pairs(passwords) do
  27.       if arg == password then
  28.         setrole(cn, CR_ADMIN)
  29.         break
  30.       end
  31.     end
  32.     return PLUGIN_BLOCK
  33.   end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement