Advertisement
Bushmeister

Untitled

Oct 15th, 2015
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 23.79 KB | None | 0 0
  1. --[[
  2. #hotcheese
  3. Developers: Bushmeister and Smgxxx
  4. Testers: Bushmeister, his alts and Mepers
  5. Idea: Ikorra
  6. Thread: http://atelier801.com//topic?f=6&t=389040&p=1#m1
  7.  
  8. DEVELOPERS: KEEP THE CODE CLEAN!
  9. ]]
  10.     Module =
  11.     {
  12.         ["log"] = function (msg) for k, v in pairs(tfm.get.room.playerList) do if (Module.admins[k]~=nil) then tfm.exec.chatMessage("<N2>[Log]: <N>" .. tostring(msg), k); end end end;
  13.         ["init"] = function () for k, v in pairs(tfm.get.room.playerList) do eventNewPlayer(k); end tfm.exec.disableAutoShaman(true); tfm.exec.disableAutoNewGame(true); tfm.exec.disableAutoTimeLeft(true); tfm.exec.disableAfkDeath(true); system.disableChatCommandDisplay("m.addAdmin", true); system.disableChatCommandDisplay("m.addMod", true); system.disableChatCommandDisplay("m.DebugSend", true); system.disableChatCommandDisplay("m.stop", true); system.disableChatCommandDisplay("m.ban", true); system.disableChatCommandDisplay("m.unban", true); system.disableChatCommandDisplay("m", true); system.disableChatCommandDisplay("a", true); system.disableChatCommandDisplay("lang", true); system.disableChatCommandDisplay("l", true); Module.newGame(); end;
  14.         ["startGame"] = function ()
  15.                 local count = 0;
  16.                 local player;
  17.                 local playersTbl = {};
  18.                 for k, v in pairs(tfm.get.room.playerList) do
  19.                         if not(tfm.get.room.playerList[k].isDead) and not(Player[k].data.isAfk) then
  20.                                 count = count+1;
  21.                                 table.insert(playersTbl, k);
  22.                         elseif not(tfm.get.room.playerList[k].isDead) then
  23.                                 tfm.exec.killPlayer(k);  
  24.                         end
  25.                 end
  26.                 Module.log("count: " .. count);
  27.                 if (count<=1) then
  28.                         Module.lastPlayerWithCheese = nil;
  29.                         Module.newGame();
  30.                         return;
  31.                 end
  32.                 repeat
  33.                         player = playersTbl[math.random(1, #playersTbl)];
  34.                 until player~=Module.lastPlayerWithCheese;
  35.                
  36.                 Module.lastTimePlayerThrewCheese = -500;
  37.                 Module.lastPlayerWithCheese = player;
  38.                 tfm.exec.killPlayer(player);
  39.                 system.newTimer(function()
  40.                         Message.send('receivedCheese', Player.getPlayerList("exceptPlayers"));
  41.                         Message.send('startGame', Player.getPlayerList("exceptPWC"), Module.lastPlayerWithCheese);
  42.                 end, 1000, false);
  43.         end;
  44.         ["stop"] = function (adminName) if (Player.isInRoom(adminName)==true and Module.admins[adminName]~=nil) then system.exit() end end;
  45.         ["newGame"] = function () if (Module.lastMapIndex+1>#Maps) then Module.lastMapIndex = 1; else Module.lastMapIndex = Module.lastMapIndex + 1 end Module.log(Module.lastMapIndex) tfm.exec.newGame(Maps[Module.lastMapIndex]); end;
  46.         ["addAdmin"] = function(playerName, adminName) if (Player.isInRoom(playerName)==true and Module.admins[adminName]~=nil) then Module.admins[playerName] = tfm.get.room.playerList[playerName]; Player[playerName].data.isAdmin = true; end end;
  47.         ["addMod"] = function(playerName, adminName) if (Player.isInRoom(playerName)==true and Module.admins[adminName]~=nil) then Module.mods[playerName] = tfm.get.room.playerList[playerName]; Player[playerName].data.isMod = true; end end;
  48.         ["admins"] = {["Bushmeister"] = tfm.get.room.playerList["Bushmeister"], ["Smgxxx"] = tfm.get.room.playerList["Smgxxx"]};
  49.         ["mods"] = {};
  50.         ["timerID"] = nil;
  51.        
  52.         ["lastPlayerWithCheese"] = nil;
  53.         ["lastTimePlayerThrewCheese"] = 0;
  54.         ["lastSpaceBar"] = 0;
  55.         ["lastMapIndex"] = 1;
  56.     }
  57.     --[[
  58.                                                             MODULE DOCUMENTATION
  59.         Module.init() - инициализирует игру. Биндит клавиши, выключает ненужные функции, скрывает команды.
  60.         Module.startGame() - рандомно выбирает, кто из игроков получит сыр. Эта функция не выберет игрока повторно, если он был последний с сыром в прошлом раунде. Если в комнате 1 мышь - вызовет Module.newGame().
  61.         Module.stop(adminName) - вызывает system.exit(). Необходимо имя администратора, который вызывает эту функцию.
  62.         Module.newGame() - рандомно выбирает какую карту запустить. Эта функция не запустит карту, которая играла в прошлом раунде.
  63.         Module.addAdmin(playerName, adminName) - добавляет игрока в админы. Необходимо имя администратора, который вызывает эту функцию.
  64.         Module.addMod(playerName, adminName) - тоже самое, что и addAdmin, только добавляет игрока в модераторы.
  65.         Message.send(message, messageType, sender) - отправляет сообщение в чат выбранному(выбранным) игроку(игрокам). Для отправки сообщения в чат модераторов/администраторов - необходимо имя модератора(администратора), который вызывает функцию.
  66.     ]]
  67.     Player =
  68.     {
  69.         ["isInRoom"] = function (playerName) return tfm.get.room.playerList[playerName]~=nil end,
  70.         ["hasCheese"] = function (playerName) return tfm.get.room.playerList[playerName].hasCheese end,
  71.         ["x"] = function (playerName) if (tfm.get.room.playerList[playerName]~=nil) then return tfm.get.room.playerList[playerName].x end return false end,
  72.         ["y"] = function (playerName) if (tfm.get.room.playerList[playerName]~=nil) then return tfm.get.room.playerList[playerName].y end return false end;
  73.         ["changeLang"] = function (playerName, lang) if (tfm.get.room.playerList[playerName]~=nil and lang~=nil) then Player[playerName].data.lang = lang end end;
  74.         ["saveData"] = function(playerName) if (Player.isInRoom(playerName)==true and Player[playerName]~=nil) then system.savePlayerData (playerName, Player.ToString(playerName)) end end;
  75.         ["loadData"] = function(playerName) if (Player.isInRoom(playerName)==true and Player[playerName]~=nil) then system.loadPlayerData(playerName) end end;
  76.         ["ToString"] = function(playerName) local dataInText = Player[playerName].data.deaths .. " " .. Player[playerName].data.gaveCheese .. " " .. Player[playerName].data.roundsPlayed .. " " .. Player[playerName].data.scores.. " " .. Player[playerName].data.lang .. " " .. tostring(Player[playerName].data.isAdmin) .. " " .. tostring(Player[playerName].data.isMod) .. " " .. tostring(Player[playerName].data.ban.banType) .. " " .. tostring(Player[playerName].data.ban.unbanTime) .. " " .. tostring(Player[playerName].data.ban.Moderator); return dataInText; end; -- соединяет данные таблицы data в одну строку для дальнейшего сохранения
  77.         ["ToTable"] =
  78.                     function(str, playerName)
  79.                         local args = {};
  80.                         for arg in str:gmatch("%S+") do
  81.                             if (arg=="nil") then
  82.                                 arg = nil;
  83.                             end
  84.                             if (arg=="true") then
  85.                                 arg = true;
  86.                             end
  87.                             if (arg=="false") then
  88.                                 arg = false;
  89.                             end
  90.                             table.insert(args, arg);
  91.                         end
  92.                         Player[playerName].data.deaths = args[1];
  93.                         Player[playerName].data.gaveCheese = args[2];
  94.                         Player[playerName].data.roundsPlayed = args[3];
  95.                         Player[playerName].data.scores = args[4];
  96.                         Player[playerName].data.lang = args[5];
  97.                         Player[playerName].data.isAdmin = args[6];
  98.                         Player[playerName].data.isMod = args[7];
  99.                         Player[playerName].data.ban.banType = args[8];
  100.                         Player[playerName].data.ban.unbanTime = args[9];
  101.                         Player[playerName].data.ban.Moderator = args[10];
  102.                        
  103.                     end; -- сортирует данные из одной, целой строки в поля таблицы
  104.         ["checkBan"] =
  105.                         function(playerName)
  106.                             if (Player[playerName].data.ban.banType=="temp" and Player[playerName].data.ban.unbanTime~=nil) then
  107.                                 if (os.time()>tonumber(Player[playerName].data.ban.unbanTime)) then
  108.                                     Player[playerName].data.ban.unbanTime = nil;
  109.                                     Player[playerName].data.ban.banType = nil;
  110.                                     tfm.exec.setPlayerScore (playerName, 0);
  111.                                 else
  112.                                     tfm.exec.killPlayer(playerName);
  113.                                     tfm.exec.setPlayerScore (playerName, -360);
  114.                                 end
  115.                             end
  116.                             if (Player[playerName].data.ban.banType=="perm") then
  117.                                 tfm.exec.killPlayer(playerName);
  118.                                 tfm.exec.setPlayerScore (playerName, -777);
  119.                             end
  120.                         end; -- будет проверять текущую дату+время и сверяет с unbanTime. Если срок прошел - анбан
  121.         ["getPlayerList"] =
  122.         function (typeList)
  123.                 local list = {}
  124.                 for k,v in pairs(tfm.get.room.playerList) do
  125.                         if (
  126.                                 (typeList == nil) or
  127.                                 (typeList == 'exceptPlayers' and Player.hasCheese(k) and not tfm.get.room.playerList[k].isDead) or
  128.                                 (typeList == 'exceptPWC' and not(Player.hasCheese(k))) or
  129.                                 (typeList == 'admins' and Module.admins[k] ~= nil) or
  130.                                 (typeList == 'mods' and (Module.mods[k] ~= nil or Module.admins[k] ~= nil))
  131.                             ) then
  132.                         table.insert(list, k)
  133.                     end
  134.                 end
  135.             return list;
  136.         end;
  137.         ["init"] =
  138.         function(playerName)
  139.             Player[playerName] =
  140.             {--только свойства. Все методы доступы сразу из Player.
  141.                 ["data"] =
  142.                 {
  143.                     ["deaths"] = 0; -- смерти
  144.                     ["gaveCheese"] = 0; --сколько передано сыра
  145.                     ["roundsPlayed"] = 0; -- сыграно раундов
  146.                     ["scores"] = 0; -- очки
  147.                     ["lang"] = tfm.get.room.playerList[playerName].community; -- язык
  148.                     ["isAdmin"] = false;
  149.                     ["isMod"] = false;
  150.                     ["isAfk"] = true; -- данная переменная не должна сохраняться в saveData, а также не участвует в ToString() ToTable(). Необходима для убийства afk игроков, после того как был выдан сыр рандомом и выбора активного игрока(рандом вас не выберет, если вы не сдвинулись с места)  
  151.                     ["ban"] =
  152.                     {  
  153.                         ["banType"] = nil; --тип бана. temp или perm
  154.                         ["unbanTime"] = nil; --дата и время анбана (UNIX)
  155.                         ["Moderator"] = nil; --модератор, выдавший бан
  156.                     }
  157.                 }
  158.             };
  159.             if (Player[playerName].data.isAdmin==true or Module.admins[playerName]~=nil) then
  160.                 Module.admins[playerName] = tfm.get.room.playerList[playerName];
  161.                 Player[playerName].data.isAdmin = true;
  162.             end
  163.             if (Player[playerName].data.isMod==true or Module.mods[playerName]~=nil) then
  164.                 Module.mods[playerName] = tfm.get.room.playerList[playerName];
  165.                 Player[playerName].data.isMod = true;
  166.             end
  167.             Module.log(playerName.."\'s data has been initialized");
  168.             Module.log("Player["..playerName.."].data.isAdmin = " .. tostring(Player[playerName].data.isAdmin));
  169.             Module.log("Player["..playerName.."].data.isMod = " .. tostring(Player[playerName].data.isMod));
  170.         end;
  171.     }
  172.     Maps =
  173.     {
  174.         4465309,
  175.         4388974
  176.     }
  177.     Message =
  178.     {
  179.         ["send"] =
  180.         function (messageKey, recipient, ...)
  181.             if recipient == nil then recipient = Player.getPlayerList(); end
  182.             if type(recipient) == 'string' then
  183.                 recipient = {recipient}
  184.             end
  185.             local message = '';
  186.             for _,v in pairs(recipient) do
  187.                 if Player.isInRoom(v) then
  188.                     message = Message.translate(messageKey, Player[v].data.lang)
  189.                     message = message:format(...);
  190.                     tfm.exec.chatMessage(message, v);
  191.                 end
  192.             end
  193.         end;
  194.         ["defaultLang"] = "en";
  195.         ["translate"] = function (key, lang) return (Message[lang] or Message[Message.defaultLang])[key] or Message[Message.defaultLang][key] or key; end;
  196.         ["en"] =
  197.         {
  198.             ["availableCommands"] = "<VI>[#HotCheese]:<T> Available commands: <J>%s";
  199.             ["newPlayer"] = "<VI>[#HotCheese]:<T> Hello %s! Welcome to <VI>#HotCheese<T>! Every round random player receives hot cheese and you have to avoid them. If you catch hot cheese, try to throw it to another mouse as soon as it possible! Press <VI>spacebar<T> to throw cheese.";
  200.             ["endGame"] = "<VI>[#HotCheese]:<T> %s<J> has lost the game T_T";
  201.             ["startGame"] = "<VI>[#HotCheese]:<J> Oh, no! %s has received cheese! Be careful, (s)he'll try to throw hot cheese to you";
  202.             ["receivedCheese"] = "<VI>[#HotCheese]:<J> Hurry up! You have only <T>20<J> seconds to give cheese to another mouse!";
  203.             ["receivedCheeseGlobal"] = "<VI>[#HotCheese]:<J> Run away from <T>%s!<J> (S)he has caught hot cheese!";
  204.             ["addAdmin"] = "<VI>[Module]:<V> Player <VP>%s<V> has been added to the admin group";
  205.             ["addMod"] = "<VI>[Module]:<V>Player <VP>%s<V> has been added to the moderator group";
  206.             ["stop"] = "<VI>[Module]:<VP> Goodbye!";
  207.            
  208.             ["testAll"] = "<VI>[Module]:<V> Это сообщение должно быть отправлено всем игрокам в комнате";
  209.             ["testExcept"] = "<VI>[Module]:<V> Это сообщение должен был получить игрок с сыром";
  210.             ["testNotExcept"] = "<VI>[Module]:<V> Это сообщение должно быть отправлено всем игрокам без сыра";
  211.             ["testMods"] = "<VI>[Module]:<V> Это сообщение должно быть отправлено всем модераторам и администраторам";
  212.             ["testAdmins"] = "<VI>[Module]:<V> Это сообщение должно быть отправлено всем администраторам";
  213.             ["chatA"] = "<R>[Admins]<T> [%s]:<R> %s";
  214.             ["chatM"] = "<ROSE>[Mods]<T> [%s]:<ROSE> %s";
  215.         };
  216.         ["ru"] =
  217.         {
  218.             ["newPlayer"]  = "Привет %s! Добро пожаловать в мини-игру #HotCheese! Каждый раунд случайному игроку будет выдан горячий сыр, Вы должные избегать его(её)! Если Вы получили/поймали горячий сыр, постарайтесь как можно скорее передать его другой мышке. Используйте пробел, чтобы бросить сыр.";
  219.             ["endGame"] = "<VI>[#HotCheese]:<T> %s<J> проиграл T_T";
  220.             ["startGame"] = "<VI>[#HotCheese]:<J> О нет! <T>%s<J> получил(а) горячий сыр! Будьте осторожны, он(а) попытается бросить его вам!";
  221.             ["receivedCheese"] = "<VI>[#HotCheese]:<J> Поторопись! У тебя есть только <T>20<J> секунд чтобы передать сыр!";
  222.             ["receivedCheeseGlobal"] = "<VI>[#HotCheese]:<J> Убегайте от <T>%s!<J> У него горячий сыр!";
  223.            
  224.             ["addAdmin"] = "<VI>[Module]:<V>Игрок <VP>%s<V> стал администратором";
  225.             ["addMod"] = "<VI>[Module]:<V>Игрок <VP>%s<V> стал модератором";
  226.             ["stop"] = "<VI>[Module]:<VP> ^-^ bye-bye";
  227.         };
  228.         ["tr"] =
  229.         {
  230.             ["newPlayer"]  = "<VI>[#HotCheese]:<T> Merhaba %s!  <VI>#HotCheese<T>! odasına hoş geldin! Her oyuncu rastgele bir peynir alır, sizin bunlardan kaçmanız gerekiyor. En kısa sürede peyniri yakalayın ve diğer farelere vermeye çalışın! Peyniri vermek için  <VI>Boşluk<T> tuşuna basın.";
  231.             ["endGame"] = "<VI>[#HotCheese]:<T> %s<J> Oyunu kaybetti T_T ";
  232.             ["startGame"] = "<VI>[#HotCheese]:<J>  Ah, hayır! %s  seçildi! Dikkat et, o sana peyniri vermeye çalışacak";
  233.             ["receivedCheese"] =  "<VI>[#HotCheese]:<J> Çabuk ol! Peyniri başka bir fareye vermek için sadece  <T>20<J> saniyen var!";
  234.             ["receivedCheeseGlobal"] =  "<VI>[#HotCheese]:<J>  <T>%s!<J> kişisinden kaç! Çünkü bu peyniri sana verirse oyunu kaybedersin. ";
  235.             ["stop"] = "<VI>[Module]:<VP> ^-^ bye-bye";
  236.         };
  237.     }
  238.    
  239.     function eventPlayerDataLoaded(playerName,data)
  240.         if (data~="#") then
  241.             Player.ToTable(data, playerName);
  242.         end
  243.     end
  244.     function eventNewPlayer(playerName)
  245.    
  246.         if (Player[playerName]==nil) then
  247.             Player.init(playerName)
  248.         end
  249.         Message.send('newPlayer', playerName, playerName);
  250.         local Buttons = {32, 37, 38, 39, 40, 65, 68, 83, 87};
  251.         for i, v in ipairs(Buttons) do
  252.             tfm.exec.bindKeyboard(playerName, v, true, true);
  253.         end
  254.     end
  255.    
  256.     function eventPlayerLeft(playerName)
  257.         --Player[playerName] = nil;
  258.         --Module.admins[playerName] = nil;
  259.         --Module.mods[playerName] = nil;
  260.         --tfm.exec.bindKeyboard(playerName, 32, true, false);
  261.     end
  262.    
  263.     function eventNewGame()
  264.         for k, v in pairs(tfm.get.room.playerList) do
  265.             Player.checkBan(k);
  266.             Player[k].data.isAfk = true;
  267.             Player[k].data.roundsPlayed=Player[k].data.roundsPlayed+1;
  268.         end
  269.         if (Module.timerID~=nil) then
  270.             --[[
  271.                 Необходимо т.к если в комнате один игрок и он умирает в первые 9 секунд
  272.                 (когда таймер начал работать) таймер остается рабочим и запускается
  273.                 в новом раунде раньше времени, а также создается новый таймер на 10сек.
  274.                                             ♥while(true)♥
  275.             ]]
  276.             system.removeTimer(Module.timerID);
  277.             Module.timerID=nil;
  278.         end
  279.         Module.lastTimePlayerThrewCheese = -10000;
  280.         tfm.exec.setGameTime(130);
  281.         Module.timerID = system.newTimer(function() Module.timerID = nil; Module.startGame(); end, 10000, false)
  282.     end
  283.    
  284.     function eventPlayerDied(playerName)
  285.         if (Player[playerName]~=nil) then
  286.             Player[playerName].data.deaths = Player[playerName].data.deaths+1;
  287.         else
  288.             Module.log(playerName.."\'s data wasn't initialized")
  289.             Player.init(playerName);
  290.         end
  291.         if (playerName~=Module.lastPlayerWithCheese) then
  292.             local playersAlive = 0;
  293.             for k, v in pairs(tfm.get.room.playerList) do
  294.                 if (tfm.get.room.playerList[k].isDead~=true) then
  295.                     playersAlive = playersAlive + 1;
  296.                 end
  297.             end
  298.             if (playersAlive<=1) then
  299.                 Module.newGame();
  300.             end
  301.         end
  302.         if (playerName==Module.lastPlayerWithCheese) then
  303.             if (Module.lastTimePlayerThrewCheese<20000 and Player[playerName].data.ban.banType==nil) then
  304.                 tfm.exec.setPlayerScore(playerName, -1, true); tfm.exec.respawnPlayer(playerName); tfm.exec.giveCheese(playerName);
  305.             else
  306.                 Message.send('endGame', nil, playerName);
  307.                 Module.startGame();
  308.             end
  309.         end
  310.     end
  311.    
  312.     function eventLoop(currentTime, timeRemaining)
  313.         Module.lastSpaceBar = Module.lastSpaceBar-500;
  314.         Module.lastTimePlayerThrewCheese = Module.lastTimePlayerThrewCheese+500; --счетчики времени последней передачи сыра и последнего нажатия пробела
  315.         if (Module.lastTimePlayerThrewCheese>=20000) then
  316.             tfm.exec.killPlayer(Module.lastPlayerWithCheese);
  317.         end
  318.         if (timeRemaining<=500) then
  319.             Module.newGame();
  320.         end
  321.     end
  322.    
  323.     function eventKeyboard(playerName, keyCode, down, xPlayerPosition, yPlayerPosition)
  324.         local Buttons = {37, 38, 39, 40, 65, 68, 83, 87};
  325.         if Player[playerName].data.isAfk==true then
  326.             for _, v in pairs(Buttons) do
  327.                 if keyCode==v then
  328.                     Player[playerName].data.isAfk = false;
  329.                     break;
  330.                 end
  331.             end
  332.         end
  333.         if (Player.hasCheese(playerName)) then
  334.             local playerNameWhoCaughtCheese = nil;
  335.             if (keyCode==32 and Module.lastSpaceBar<=0) then--антиспам пробелом
  336.                 Module.lastSpaceBar = 500;
  337.                 for k, v in pairs(tfm.get.room.playerList) do
  338.                     if math.pow((Player.x(k)-xPlayerPosition), 2)+math.pow((Player.y(k)-yPlayerPosition), 2)<900 and k~=playerName then
  339.                         playerNameWhoCaughtCheese=k;
  340.                         break;
  341.                     end
  342.                 end
  343.                 if (playerNameWhoCaughtCheese~=nil) then
  344.                     Module.lastSpaceBar = 3000;
  345.                     Module.lastTimePlayerThrewCheese = -500;
  346.                     Module.lastPlayerWithCheese=playerNameWhoCaughtCheese;
  347.                     tfm.exec.giveCheese(playerNameWhoCaughtCheese);
  348.                     tfm.exec.playerVictory(playerName);
  349.                     tfm.exec.respawnPlayer(playerName);
  350.                     Player[playerName].data.gaveCheese = Player[playerName].data.gaveCheese+1;
  351.                     Player[playerName].data.scores = Player[playerName].data.scores+1;
  352.                     system.newTimer(function() Message.send('receivedCheeseGlobal', Player.getPlayerList("exceptPWC"), playerNameWhoCaughtCheese); Message.send('receivedCheese', Player.getPlayerList("exceptPlayers")); end, 1500, false);
  353.                 end
  354.             end
  355.         end
  356.     end
  357.  
  358. function eventChatCommand(playerName, message)
  359.     if (Module.admins[playerName]~=nil) then
  360.         --commands for admins
  361.         if (message:sub(0,11)=="m.addAdmin " and message:len()>=12) then
  362.             Module.addAdmin(message:sub(12), playerName);
  363.             Message.send('addAdmin', playerName, message:sub(12));
  364.         end
  365.         if (message:sub(0,9)=="m.addMod " and message:len()>=10) then
  366.             Module.addMod(message:sub(10), playerName)
  367.             Message.send('addMod', playerName, message:sub(10));
  368.         end
  369.         if (message:sub(0,6)=="m.stop") then
  370.             Message.send('stop');
  371.             system.newTimer(function () Module.stop(playerName) end, 1000, false);
  372.         end
  373.         if (message:sub(0, 8)=="m.unban " and message:len()>9) then
  374.             if (Player.isInRoom(message:sub(9))==true) then
  375.                 local pName = message:sub(9);
  376.                 Player[pName].data.ban.banType = nil;
  377.                 Player[pName].data.ban.unbanTime = nil;
  378.                 tfm.exec.setPlayerScore (pName, 0);
  379.             end
  380.         end
  381.         if (message:sub(0,10)=="m.DebugPD " and message:len()>10) then
  382.             if (Player.isInRoom(message:sub(11))) then
  383.                 tfm.exec.chatMessage("<R>"..Player.ToString(message:sub(11)));
  384.             end
  385.         end
  386.         if (message=="m.DebugSend") then
  387.             Message.send('testAll');
  388.             Message.send('testExcept', Player.getPlayerList("exceptPlayers"));
  389.             Message.send('testNotExcept', Player.getPlayerList("exceptPWC"));
  390.             Message.send('testMods', Player.getPlayerList("mods"));
  391.             Message.send('testAdmins', Player.getPlayerList("admins"));
  392.         end
  393.         if (message:sub(0,2)=="a " and message:len()>=3) then
  394.             Message.send('chatA', Player.getPlayerList("admins"), playerName, message:sub(3));
  395.         end
  396.     end
  397.     if (Module.admins[playerName]~=nil or Module.mods[playerName]~=nil) then
  398.         if (message:sub(0,2)=="m " and message:len()>=3) then
  399.             Message.send('chatM', Player.getPlayerList("mods"), playerName, message:sub(3));
  400.         end
  401.         if (message:sub(0,6)=="m.ban " and message:len()>9) then--check if temp or perm isnt null
  402.             --!m.ban name type time
  403.             local msgArgs = {}
  404.             for arg in message:gmatch("%S+") do
  405.                 table.insert(msgArgs, arg);
  406.                 print(arg)
  407.             end
  408.             local pName = msgArgs[2];
  409.             local bType = msgArgs[3];
  410.             local bTime = nil
  411.             if (bType~=nil and bType~="perm") then
  412.                 bTime = tonumber(msgArgs[4]);
  413.             end
  414.             if (Player[pName]~=nil) then
  415.                 if (bType~=nil) then
  416.                     if (bType=="perm" and Module.admins[playerName]~=nil) then
  417.                         Player[pName].data.ban.banType = "perm";
  418.                         Player[pName].data.ban.unbanTime = nil;
  419.                         Player[pName].data.ban.Moderator = playerName;
  420.                         tfm.exec.killPlayer(pName);
  421.                         tfm.exec.setPlayerScore (pName, -777);
  422.                         elseif (Module.admins[playerName]==nil) then
  423.                         tfm.exec.chatMessage("<VI>[Module]:<R> You don't have enough rights to do this action")
  424.                     end
  425.                     if (bType=="temp" and bTime~=nil and Player[pName].data.ban.banType==nil) then
  426.                         Player[pName].data.ban.banType = "temp";
  427.                         Player[pName].data.ban.unbanTime = os.time() + bTime*60*60*1000;
  428.                         Player[pName].data.ban.Moderator = playerName;
  429.                         tfm.exec.chatMessage(os.time().. "    " .. Player[pName].data.ban.unbanTime)
  430.                         tfm.exec.killPlayer(pName);
  431.                         tfm.exec.setPlayerScore (pName, -777);
  432.                     end
  433.                 end
  434.             end
  435.         end
  436.     end
  437.     if (message:sub(0,5)=="lang " or message:sub(0,2)=="l ") then
  438.         Player.changeLang(playerName, (message:sub(0,2)=="l " and message:sub(3,4)) or message:sub(6,7) )
  439.     end
  440. end
  441. Module.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement