Safwanrockz

Banning

Dec 25th, 2013
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.98 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 table.delete(t,v)
  15.      for key,value in ipairs(t) do
  16.          if v == t[key] then
  17.              table.remove(t, key)
  18.          end
  19.      end
  20. end
  21.  
  22. function eventNewGame()
  23.      for name,player in pairs(tfm.get.room.playerList) do
  24.          if table.contains(isBanned,player) then
  25.              tfm.exec.killPlayer(player)
  26.          end
  27.      end
  28. end
  29.  
  30. function eventPlayerRespawn(name)
  31.      if table.contains(isBanned,name) then
  32.          tfm.exec.killPlayer(name)
  33.      end
  34. end
  35.  
  36. function eventChatCommand(name,cmd)
  37.      local arg={}
  38.      for argument in cmd:gmatch("[^%s]+") do
  39.          table.insert(arg, argument);
  40.      end
  41.      if arg[1]=="ban" then
  42.          table.insert(isBanned,arg[2])
  43.      elseif arg[1]=="unban" then
  44.          table.delete(isBanned,arg[2])
  45.      end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment