Advertisement
Bolodefchoco_LUAXML

[Script] Ban

Nov 6th, 2015
920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.25 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 06/11/2015
  3. --Last update: 17/05/2016
  4. --[[ Notes:
  5.     Does:
  6.         Ban um jogador.
  7.     Comandos:
  8.         !
  9.             ban --> Ban (mata + tela preta)
  10.             unban --> Remove o ban
  11.                 Nome --> Nome do jogador
  12. ]]--
  13.  
  14.  
  15. admins={"Bolodefchoco"}
  16. mice={}
  17. ban={}
  18.  
  19. eventNewPlayer=function(n)
  20.     if not mice[n] then
  21.         mice[n]={
  22.             isbanned = false
  23.         }
  24.     end
  25. end
  26. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  27.  
  28. table.find=function(list,value)
  29.     local found,keys,times = false,{},0
  30.     for k,v in next,list do
  31.         if type(v) ~= "table" then
  32.             if v == value then
  33.                 found = true
  34.                 keys[#keys+1] = k
  35.                 times = times + 1
  36.             end
  37.         else
  38.             local a,b,c = table.find(v,value)
  39.             if not found then found = a end
  40.             if b then table.insert(keys,table.unpack(b)) end
  41.             if c then times = times + c end
  42.         end
  43.     end
  44.     return found,keys,times
  45. end
  46.  
  47. string.nick=function(player)
  48.     return player:lower():gsub('%a',string.upper,1)
  49. end
  50.  
  51. system.ban=function(playerName)
  52.     if table.find(ban,playerName) then
  53.         tfm.exec.killPlayer(playerName)
  54.         ui.addTextArea(0,"",playerName,-1500,-1500,3000,3000,1,1,1,true)
  55.         mice[playerName].isbanned = true
  56.     else
  57.         table.insert(ban,playerName)
  58.         system.ban(playerName)
  59.     end
  60. end
  61.  
  62. system.unban=function(playerName)
  63.     if table.find(ban,playername) then
  64.         table.destroy(ban,playerName)
  65.         mice[playerName].isbanned = false
  66.         ui.removeTextArea(0,playerName)
  67.     end
  68. end
  69.  
  70. eventNewGame=function()
  71.     for n in next,tfm.get.room.playerList do
  72.         if mice[n].isbanned then
  73.             system.ban(n)
  74.         end
  75.     end
  76. end
  77.  
  78. eventChatCommand=function(playerName,command)
  79.     local arg={}
  80.     for value in command:gmatch('[^%s]+') do table.insert(arg,value) end
  81.     arg[1] = arg[1]:lower()
  82.     if table.find(admins,playerName) then
  83.         if arg[1] == "ban" then
  84.             if arg[2] then
  85.                 arg[2] = string.nick(arg[2])
  86.                 if tfm.get.room.playerList[arg[2]] then
  87.                     if not table.find(ban,arg[2]) and not table.find(admins,arg[2]) then
  88.                         system.ban(arg[2])
  89.                     end
  90.                 end
  91.             end
  92.         end
  93.         if arg[1] == "unban" then
  94.             if arg[2] then
  95.                 arg[2] = string.nick(arg[2])
  96.                 if tfm.get.room.playerList[arg[2]] then
  97.                     system.unban(arg[2])
  98.                 end
  99.             end
  100.         end
  101.     end
  102. end
  103. for _,c in next,{"ban","unban"} do
  104.     system.disableChatCommandDisplay(c,true)
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement