Advertisement
ForeverDev

Untitled

Oct 24th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.00 KB | None | 0 0
  1. local admins = {
  2.     [-1] = 3
  3. }
  4.  
  5. local removeElement = function(array, element)
  6.     for index, value in ipairs(array) do
  7.         if value == element then
  8.             table.remove(array, index)
  9.             break
  10.         end
  11.     end
  12.     return array
  13. end
  14.  
  15. local target = function(targ, speaker)
  16.     if targ:lower() == "all" then
  17.         return game.Players:GetPlayers()
  18.     elseif targ:lower() == "others" then
  19.         return removeElement(game.Players:GetPlayers(), speaker)
  20.     elseif targ:lower() == "me" then
  21.         return {speaker}
  22.     else
  23.         each(game.Players:GetPlayers(), function(_, this)
  24.             if this.Name:lower():sub(1, targ:len()) == targ:lower() then
  25.                 return {this}
  26.             end
  27.         end)
  28.         return {}
  29.     end
  30. end
  31.  
  32. local each = function(array, callback)
  33.     for index, value in pairs(array) do
  34.         callback(index, value)
  35.     end
  36. end
  37.  
  38. local chat = function(message, speaker)
  39.     if admins[speaker.userId] then
  40.         local words = {}
  41.         message:gsub("([%a%d]+)", function(catch)
  42.             table.insert(words, catch)
  43.         end)
  44.         if message:sub(1, 1) == "#" and (owner[words[1]] or perm[words[1]] or temp[words[1]]) then
  45.             local success;
  46.             local level = admins[speaker.userId]
  47.             repeat
  48.                 local stringLevel = level == 3 and "owner" or level == 2 and "perm" or level == 1 and "temp" or "false"
  49.                 if getfenv()[stringLevel][words[1]] then
  50.                     success = getfenv()[stringLevel][words[1]](speaker, message, words)
  51.                 end
  52.                 level = level - 1
  53.             until success or level == 0
  54.         end
  55.     end
  56. end
  57.    
  58. game.Players.PlayerAdded:connect(function(player)
  59.     player.Chatted:connect(chat)
  60. end)
  61.  
  62. --[[
  63.     levels:
  64.         3 = owner
  65.         2 = perm
  66.         1 = temp
  67.     you can access commands from your level and under.
  68.     ex) perm admins can access commands @ level 2 and 1
  69.    
  70.     must be global so getfenv() can be used to find these tables
  71. ]]
  72.  
  73. owner, perm, temp = {}, {}, {}
  74.  
  75. owner.kill = function(speaker, message, words)
  76.     each(target(words[2], speaker), function(_, this)
  77.         if this.Character then
  78.             this.Character:BreakJoints()
  79.         end
  80.     end)
  81.     return 1
  82. end
  83.  
  84. wait(2)
  85. chat("#kill others", game.Players.Player1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement