Advertisement
suxonov

Untitled

May 14th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. blacklist = {}
  2.  
  3. function table.contains(t,element) --checks that player is banned
  4.     if element==nil then
  5.         return false
  6.     end
  7.     for key,value in pairs(t) do
  8.         if value==element then
  9.         return true
  10.         end
  11.     end
  12.     return false
  13. end
  14.  
  15. function table.rem(tab,value)
  16.     function table.indexof(t,val)
  17.         for k,v in ipairs(t) do
  18.         if v == val then
  19.             return k end
  20.         end
  21.     end
  22.     table.remove(tab,table.indexof(tab,value))
  23. end
  24.  
  25. function eventChatCommand(name, command)
  26.     local arg = {}
  27.     for argument in command:gmatch("[^%s]+") do
  28.         table.insert(arg, argument)
  29.     end
  30.     if arg[1] == 'ban' and arg[2] ~= nil and arg[2] ~= name then
  31.         if table.contains(blacklist, arg[2]) then
  32.             print('<R>Player is alredy banned!~')
  33.         elseif not table.contains(blacklist, arg[2]) then
  34.             table.insert(blacklist, arg[2])
  35.         end
  36.     end
  37.     if arg[1] == 'unban' and arg[2] ~= nil then
  38.         if table.contains(blacklist, arg[2]) then
  39.             table.rem(blacklist, arg[2])
  40.             for k,v in ipairs({0, 1}) do
  41.                 ui.removeTextArea(v)
  42.             end
  43.             print('Player is unbanned!~')
  44.         elseif not table.contains(blacklist, arg[2]) then
  45.             print('<R>Player is not banned!~')
  46.         end
  47.     end
  48. end
  49.  
  50. function eventLoop()
  51.     for name,player in pairs(tfm.get.room.playerList) do
  52.         if table.contains(blacklist,name) then
  53.             tfm.exec.killPlayer(name)
  54.             ui.addTextArea(0, "", name, 6, 2, 788, 396, 0xf0f0f, 0xf0f0f, 1)
  55.             ui.addTextArea(1, "<R><p align='center'><font size='50'>You're banned!</font></p>", name, 189, 180, 473, 68)
  56.         end
  57.     end
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement