Safwanrockz

Banning

Nov 2nd, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. isBanned={}
  2. function table.contains(t,element)
  3.     if element==nil then
  4.         return false
  5.     end
  6.     for key,value in pairs(t) do
  7.         if value==element then
  8.             return true
  9.         end
  10.     end
  11.     return false
  12. end
  13.  
  14. function eventNewGame()
  15.  for name,player in pairs(tfm.get.room.playerList) do
  16.   if table.contains(isBanned,name) then
  17.    tfm.exec.killPlayer(name)
  18.   end
  19.  end
  20. end
  21.  
  22. function eventPlayerRespawn(name)
  23.  if table.contains(isBanned,name) then
  24.   tfm.exec.killPlayer(name)
  25.  end
  26. end
  27.  
  28. function eventChatCommand(name,cmd)
  29.  local arg={}
  30.  for argument in cmd:gmatch("[^%s]+") do
  31.   table.insert(arg, argument);
  32.  end
  33.  if arg[1]=="ban" then
  34.   table.insert(isBanned,arg[2])
  35.  elseif arg[1]=="unban" then
  36.   table.remove(isBanned,arg[2])
  37.  end
  38. end
Advertisement
Add Comment
Please, Sign In to add comment