Advertisement
Guest User

Commands Template

a guest
Apr 6th, 2014
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. -- kill/nate;player2;player3
  2.  
  3. local admins = {"nate890"}
  4.  
  5. local commands = {
  6.     admin = function(msg)
  7.         local players = getPlayers(msg)
  8.         for i, c in pairs(players) do
  9.             table.insert(admins, c.Name)
  10.             allow(c)
  11.         end
  12.     end;
  13.     unadmin = function(msg)
  14.         local players = getPlayers(msg)
  15.         for i,  c in pairs(players) do
  16.             if check(admins, c.Name) then
  17.                 table.remove(admins, check(admins, c.Name))
  18.             end
  19.         end
  20.     end;
  21.     kill = function(msg)
  22.         local players = getPlayers(msg)
  23.         for i, c in pairs(players) do
  24.             if c.Character then
  25.                 c.Character:BreakJoints()
  26.             end
  27.         end
  28.     end;
  29.     kick = function(msg)
  30.         local players = getPlayers(msg)
  31.         for i, c in pairs(players) do
  32.             c:Destroy()
  33.         end
  34.     end;
  35.     jump = function(msg)
  36.         local players = getPlayers(msg)
  37.         for i, c in pairs(players) do
  38.             if c.Character and c.Character:FindFirstChild("Humanoid") then
  39.                 c.Character.Humanoid.Jump = true
  40.             end
  41.         end
  42.     end;
  43. }
  44.  
  45. function check(t, v)
  46.     for i, c in pairs(t) do
  47.         if c == v or v == i then
  48.             return i
  49.         end
  50.     end
  51. end
  52.  
  53. function getCommand(msg)
  54.     if string.match(msg, ("%p-/-%w+")) then
  55.         return string.match(msg, ("%p-/-%w+"))
  56.     end
  57. end
  58.  
  59. function getPlayers(msg)
  60.     local players = {}
  61.     for i in string.gmatch(";"..msg:sub(#getCommand(msg) + 2, #msg), (";%w+")) do
  62.         for _, p in pairs(game.Players:GetPlayers()) do
  63.             if p.Name:sub(1, #i:sub(2, #i)):lower() == i:sub(2, #i):lower() then
  64.                 table.insert(players, p)
  65.                 break
  66.             end
  67.         end
  68.     end
  69.     return players
  70. end
  71.  
  72. function allow(plr)
  73.     plr.Chatted:connect(function(msg)
  74.         if check(admins, plr.Name) then
  75.             local command = getCommand(msg)
  76.             if command and check(commands, getCommand(msg):lower()) then
  77.                 commands[command:lower()](msg)
  78.             end
  79.         end
  80.     end)
  81. end
  82.  
  83. game.Players.PlayerAdded:connect(function(plr)
  84.     if check(admins, plr.Name) then
  85.         allow(plr)
  86.     end
  87. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement