Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Developed by -> Fly#8215
- Last update -> 13.10.2019
- Current version -> 2.8.7
- !!! UPDATE !!!
- * Added quick death setting. When turned on, the player who press DEL or BACKSPACE key will be killed instantly.
- * Now the player who starts the script will be set into the admin list automatically.
- * Bugs fixed!
- ]]
- --[[ Script Data ]]--
- -- Minified [DON'T CHANGE IT]
- local _a={'110\\111\\114\\109\\97\\108','104\\97\\114\\100','119\\106'}local function _b(c)local d=''for e=1,#c do d=d..string.byte(string.sub(c,e,e))..(e<#c and'\\'or'')end;return d end;local function _f(c)local g=''string.gsub(c,'[^\]+',function(h)g=g..string.char(h)end)return g end
- local version = '2.8.6'
- -- Admins list
- local admins = {
- -- Format --> ["Player#tag"] = true
- ['Starkyller#1446'] = true,
- ['Fly#8215'] = true
- }
- --[[
- Available game modes:
- normal - Only maps from p17 rotation
- hard - Try hard maps (by Starkyller#1446)
- wj - WJ maps
- ]]
- local game_settings = {
- mode = 'normal',
- autojoin = false,
- quickdeath = false
- }
- local teams
- do
- -- Hexadecimal colors
- local colors = {
- "CE0000",
- "0004FF"
- }
- teams = {}
- for i = 1, 2 do
- teams[i] = {
- members = {},
- score = 0,
- color = colors[i]
- }
- end
- local _, admin = pcall(nil)
- admin = string.match(admin, "(.-)%.")
- admins[admin] = true
- end
- local admin_buttons = {
- ['skip'] = function(admin)
- eventChatCommand(admin, 'np')
- end,
- ['anti-leve'] = function(admin)
- eventChatCommand(admin, 'npp ant')
- end,
- ['anti-pulo'] = function(admin)
- eventChatCommand(admin, 'npp ant pulo')
- end
- }
- local data = {
- mapAtt = { '', '', '', '', '' },
- players = {},
- next_np = {},
- log = {},
- start = false,
- pause = false,
- isP38 = false,
- endGame = false,
- first = false,
- max = 20, -- Maximum score
- round = 1
- }
- local keys = { [8] = "Backspace", [9] = "Tab", [13] = "Enter", [16] = "Shift", [17] = "Control", [18] = "Alt", [19] = "Pause", [20] = "Caps Lock", [27] = "Escape", [32] = "Spacebar", [33] = "Page Up", [34] = "Page Down", [35] = "End", [36] = "Home", [37] = "Left Arrow", [38] = "Up Arrow", [39] = "Right Arrow", [40] = "Down Arrow", [45] = "Insert", [46] = "Delete", [48] = "0", [49] = "1", [50] = "2", [51] = "3", [52] = "4", [53] = "5", [54] = "6", [55] = "7", [56] = "8", [57] = "9", [65] = "A", [66] = "B", [67] = "C", [68] = "D", [69] = "E", [70] = "F", [71] = "G", [72] = "H", [73] = "I", [74] = "K", [75] = "J", [76] = "L", [77] = "M", [78] = "N", [79] = "O", [80] = "P", [81] = "Q", [82] = "R", [83] = "S", [84] = "T", [85] = "U", [86] = "V", [87] = "W", [88] = "X", [89] = "Y", [90] = "Z", [91] = "Windows (Left)", [92] = "Windows (Right)", [93] = "Application Key", [97] = "1 (Numbpad)", [98] = "2 (Numbpad)", [99] = "3 (Numbpad)", [100] = "4 (Numbpad)", [101] = "5 (Numbpad)", [102] = "6 (Numbpad)", [103] = "7 (Numbpad)", [104] = "8 (Numbpad)", [105] = "9 (Numbpad)", [106] = "* Asterix (Numbpad)", [107] = "+ Plus (Numbpad)", [109] = "- Minus (Numbpad)", [110] = "\\ Forward Slash (Numbpad)", [112] = "F1", [113] = "F2", [114] = "F3", [115] = "F4", [116] = "F5", [117] = "F6", [118] = "F7", [119] = "F8", [120] = "F9", [121] = "F10", [122] = "F11", [123] = "F12", [144] = "Numlock", [145] = "Scroll Lock", [186] = "; Semicolon", [187] = "= Equals", [188] = ", Comma", [189] = "- Hyphen", [190] = ". Period", [191] = "/ Forward Slash", [192] = "` Apostrophe", [219] = "[ Left Square Bracket", [220] = "\\ Backslash", [221] = "] Right Square Bracket" }
- local antiMaps = {
- p22 = { 7433094, 7627065 },
- p38 = { 457253, 6640740, 6640807, 6640857, 6641096, 6641104, 6641109, 6641134, 6641137, 6641138, 6641145, 6640737, 6640748, 6640758, 6640803, 6640808, 6640811, 6640816, 6640823, 6640833, 6640846, 6640852, 6640854, 6640858, 6640859, 6640860, 6640866, 6640869, 6640884, 6641058, 6641064, 6641067, 6641069, 6641077, 6641079, 6641088, 6641090, 6641101, 6641132, 6640881, 6641075, 6641087, 6641110, 6641111, 6641121, 6641144, 6641097, 6641115, 6641141, 6641143, 6640755, 6640828, 6640889, 6641063, 6641094, 6641108, 6641124, 6641128, 6641130, 6641139, 6641147, 6640760, 6640837, 6640851, 6641059, 6641062, 6641083 },
- p44 = {},
- agil = { 212542, 308992, 31420, 315801, 323085, 344865, 345257, 352381, 356982, 357328, 367520, 386029, 391831, 419374, 429822, 470727, 507325, 508796, 606723, 664949, 1654841, 1724289, 1951856, 1964752, 2070768, 2134537, 2141379, 2369254, 3575108, 3821104, 4815404, 5032745, 5590554, 5805021, 5813480, 6665146 },
- pulo = { 178545 }
- }
- local hardMaps = { 7601909, 7601911, 7601913, 7601914, 7601915, 7601917, 7601919, 7601920, 7602019, 7602026, 7602022, 7602027, 7602029, 7602031, 7602033, 7602034, 7602039, 7602042, 7602053, 7602056, 7602067, 7602078, 7602082, 7602084, 7602085, 7602089, 7602092, 7602094, 7602097, 7602372, 7602373, 7602374, 7602375, 7602377, 7602378, 7602379, 7602380, 7602383, 7602384, 7602385, 7602386, 7602387, 7602389, 7602390, 7602392, 7602393, 7615151, 7615152, 7615154, 7615155, 7615157, 7615158, 7615159, 7615160, 7615162, 7615164, 7615165, 7615166, 7615167, 7615169, 7615170, 7615264, 7615266, 7615270, 7615272, 7615275, 7615327, 7615332, 7615333, 7615335, 7615338, 7615342, 7615343, 7615346, 7615347, 7615351, 7615355, 7615358, 7615360, 7615413, 7645917, 7645918, 7645921, 7645922, 7645923, 7645927, 7645939, 7645941, 7645946, 7645951 }
- local wj_maps = { 324428, 3788529, 6119572, 6119641, 6119642, 6119643, 6119655, 6120650, 6133176, 6146352, 6274154, 6313036, 6641061, 6641085, 7465241, 7485501, 7095618, 6799629, 6755943, 7627933, 7628267, 7628262, 7628264, 7627928, 7627934, 7627939, 7630265, 7630264, 7627957, 7627955, 7627953, 7628299, 7608227, 7608225, 7608215, 7601758, 6809280, 6809273, 6798504, 6798488, 6785385 }
- --[[ Disable Game Stuff ]]--
- for k, v in next, {'AutoShaman', 'AutoNewGame', 'AutoTimeLeft', 'AutoScore', 'PhysicalConsumables'} do
- tfm.exec['disable' .. v]()
- end
- system.disableChatCommandDisplay(nil)
- --[[ Function Library ]]--
- local function string_first_upper(str)
- return str:gsub("^%l", string.upper)
- end
- local function string_split(str, s)
- local t = {}
- for part in string.gmatch(str, "[^" .. s .. "]+") do
- t[#t + 1] = part
- end
- return t
- end
- local function table_shuffle(t)
- local size = #t
- for i = size, 1, -1 do
- local rand = math.random(size)
- t[i], t[rand] = t[rand], t[i]
- end
- return t
- end
- local function table_contains(t, element)
- if (element == nil) then return false end
- for k, v in next, t do
- if (k == element or v == element) then
- return true
- end
- end
- return false
- end
- local displayTeams, displaySettings, disableTeamsDisplay, disableSettingsDisplay
- function displayTeams(name)
- if (data.players[name].show_settings) then
- local n = disableSettingsDisplay(name)
- for i = 0, n do
- ui.removeTextArea(i, name)
- end
- end
- local isAdmin = admins[name]
- local str, str2 = "", ""
- local str3, str4 = table.concat(teams[1].members, "\n"), table.concat(teams[2].members, "\n")
- ui.addTextArea(0, "", name, 178, 57, 444, 285, 0x122529, 0, 1, true)
- if (isAdmin) then
- ui.addTextArea(1, "<p align='center'><font size='13'><b><r><a href='event:game.start'>START</a></r></b></font></p>", name, 324, 193, 150, 22, 0x0D181A, 0, 1, true)
- end
- ui.addTextArea(2, "<p align='center'><font color='#"..teams[1].color.."'>"..str3.."</font></p>", name, 185, 105, 176, 230, 0x0D181A, 0, 1, true)
- ui.addTextArea(3, "<p align='center'><font color='#"..teams[2].color.."'>"..str4.."</font></p>", name, 439, 105, 176, 230, 0x0D181A, 0, 1, true)
- ui.addTextArea(4, "<p align='center'><b><font color='#"..teams[1].color.."'>Team 1</font></b></p>", name, 185, 66, 176, 20, 0x0D181A, 0, 1, true)
- ui.addTextArea(5, "<p align='center'><b><font color='#"..teams[2].color.."'>Team 2</font></b></p>", name, 439, 66, 176, 20, 0x0D181A, 0, 1, true)
- if (isAdmin) then
- local buttons = {
- {
- "<p align='center'><b><a href='event:controls.clear.team1'>C</a></b></p>",
- "<p align='center'><b><a href='event:controls.autoJoin.team1'>A</a></b></p>",
- "<p align='center'><b><a href='event:controls.randomPlayers.team1'>R</a></b></p>"
- },
- {
- "<p align='center'><b><a href='event:controls.clear.team2'>C</a></b></p>",
- "<p align='center'><b><a href='event:controls.autoJoin.team2'>A</a></b></p>",
- "<p align='center'><b><a href='event:controls.randomPlayers.team2'>R</a></b></p>"
- }
- }
- ui.addTextArea(6, table.concat(buttons[1], " <bl>|</bl> "), name, 185, 68, nil, nil, 0x0D181A, 0, 1, true)
- ui.addTextArea(7, table.concat(buttons[2], " <bl>|</bl> "), name, 560, 68, nil, nil, 0x0D181A, 0, 1, true)
- end
- data.players[name].show_info = true
- end
- function disableTeamsDisplay(name)
- for i = 0, 7 do
- ui.removeTextArea(i, name)
- end
- data.players[name].show_info = false
- return 7
- end
- function displaySettings(name)
- if (data.players[name].show_info) then
- local n = disableTeamsDisplay(name)
- for i = 0, n do
- ui.removeTextArea(i, name)
- end
- end
- ui.addTextArea(0, '', name, 250, 85, 300, 230, 0x122529)
- ui.addTextArea(1, "<p align='center'><b><font size='12'>Settings</font></b></p>", name, 255, 90, 290, 20, 0x0d181a)
- ui.addTextArea(2, '', name, 255, 129, 290, 180, 0x0d181a)
- local str = ''
- for k, v in next, game_settings do
- local _str = v;if (type(v) == 'boolean') then _str = v and '<vp>on</vp>' or '<r>off</r>' end
- str = str .. '<g>' .. string_first_upper(k) .. '</g>: <a href="event:game.settings.' .. k .. '">' .. _str .. '</a>\n'
- end
- ui.updateTextArea(2, "<p align='center'><font size='14'>" .. str, name)
- data.players[name].show_settings = true
- end
- function disableSettingsDisplay(name)
- for i = 0, 2 do
- ui.removeTextArea(i, name)
- end
- data.players[name].show_settings = false
- return 2
- end
- local function displayScore(name)
- local x, y = data.players[name].change_score_position.x, data.players[name].change_score_position.y
- ui.addTextArea(14, string.format("<p align='center'><font size='16'><a href='event:controls.leftScore'>«</a></font><font size='23'><font color='#%s'>%s<N> <a href='event:controls.change_score_position'>x</a> <font color='#%s'>%s</font></N></font></font><font size='16'><a href='event:controls.rightScore'>»</a></font></p>", teams[1].color, teams[1].score, teams[2].color, teams[2].score), name, x, y, nil, 0, 0, 0, 0, true)
- end
- local function displayLog(name)
- local log = {}
- local str = ''
- if (#data.log > 14) then
- for i = (#data.log - 14), #data.log do
- log[#log + 1] = data.log[i]
- end
- else
- for i = 1, #data.log do
- log[i] = data.log[i]
- end
- end
- table.sort(log, function(a, b) return a[3] > b[3] end)
- for i = 1, #log do
- if (admins[log[i][1]]) then
- str = str .. '<r>[' .. log[i][1] .. '] <n>' .. log[i][2] .. '\n'
- else
- str = str .. '<v>[' .. log[i][1] .. '] <n>' .. log[i][2] .. '\n'
- end
- end
- ui.addTextArea(11, "<p align='center'>" .. str .. '</p>', name, -267, 405, 263, 187, 0x3A271C, 0x3A271C, 1, true)
- end
- local function getScoreDifference()
- return math.abs(teams[1].score - teams[2].score)
- end
- local function getNextMap()
- if (#data.next_np > 0) then
- local map = data.next_np[1];table.remove(data.next_np, 1)
- return map
- end
- local _next = (_a[1] == _b(game_settings.mode)) and '#17' or nil
- if (not _next) then
- local current_map = tfm.get.room.currentMap
- while true do
- if (_a[2] == _b(game_settings.mode)) then
- _next = hardMaps[math.random(#hardMaps)]
- elseif (_a[3] == _b(game_settings.mode)) then
- _next = wj_maps[math.random(#wj_maps)]
- end
- if (_next ~= currentMap) then
- break
- end
- end
- end
- return _next
- end
- local function teamWithFewerPlayers()
- local t = { }
- for i = 1, #teams do
- t[#t + 1] = { #teams[i].members, i }
- end
- table.sort(t, function(a, b) return a[1] < b[1] end)
- return t[1][2]
- end
- local function addPlayerToTeam(player, team_id)
- local team_id = team_id or teamWithFewerPlayers()
- teams[team_id].members[#teams[team_id].members + 1] = player
- data.players[player].in_game = true
- data.players[player].team = team_id
- if (not data.start) then
- table.foreach(tfm.get.room.playerList, displayTeams)
- end
- end
- --[[ Game API ]]--
- function eventNewPlayer(name)
- if (not data.players[name]) then
- data.players[name] = {
- change_score_position = {
- click = false,
- x = 360,
- y = 20
- },
- map_cat_show = true,
- show_log = false,
- in_game = false,
- in_room = true,
- show_info = false,
- team = 0
- }
- else
- data.players[name].in_room = true
- end
- if (not data.start) then
- displayTeams(name)
- else
- if (data.pause) then
- ui.addTextArea(9, "<p align='center'><font size='60' color='#FFFFFF'>▸ P A U S E D ◂</font></p>", name, 0, 200, 800, nil, 0, 0, 0)
- end
- end
- if (game_settings.autojoin and data.players[name].team == 0) then
- addPlayerToTeam(name)
- end
- for k, v in next, keys do
- system.bindKeyboard(name, k, true)
- end
- system.bindMouse(name)
- ui.addTextArea(12, "<p align='center'><b><i><font size='12'><a href='event:game.info'>i</a></font></i></b></p>", name, 5, -23, 16, 20, nil, nil, .6)
- if (admins[name]) then
- ui.addTextArea(13, "<p align='center'><b><font size='12'><a href='event:game.settings'>Settings</a></font></b></p>", name, 31, -23, 80, 20, nil, nil, .6)
- local str = "<font size='12'>";for k in next, admin_buttons do str = str .. string.format("<a href='event:controls.%s'>%s</a>", k, string_first_upper(k)) .. ' <j>|</j> ' end
- ui.addTextArea(15, str, name, 121, -23, nil, 20, nil, nil, .6)
- end
- end
- table.foreach(tfm.get.room.playerList, eventNewPlayer)
- function eventNewGame()
- if (data.start) then
- local mapAuthor, mapCode, permCode
- local xml = tfm.get.room.xmlMapInfo
- if (xml) then
- mapCode, permCode = xml.mapCode, xml.permCode
- if (permCode == 38) then
- data.isP38 = true
- else
- data.isP38 = false
- end
- end
- for k, v in next, data.players do
- disableTeamsDisplay(k)
- if (not v.in_game) then
- tfm.exec.killPlayer(k)
- else
- local color = ''
- if (table_contains(teams[1].members, k)) then
- color = teams[1].color
- tfm.exec.setNameColor(k, '0x' .. color)
- elseif (table_contains(teams[2].members, k)) then
- color = teams[2].color
- tfm.exec.setNameColor(k, '0x' .. color)
- end
- end
- if (admins[k]) then
- if (v.map_cat_show) then
- ui.addTextArea(10, '<j>P' .. permCode .. '</j>', k, -26, 2, nil, nil, nil, nil, 0)
- else
- ui.removeTextArea(10, k)
- end
- end
- displayScore(k)
- end
- ui.setMapName('<j>Teams VS ' .. version .. '</j> | <ch>Max: ' .. data.max .. '</ch>')
- else
- for k, v in next, data.players do
- displayTeams(k)
- tfm.exec.killPlayer(k)
- tfm.exec.setPlayerScore(k, 0)
- end
- ui.removeTextArea(14)
- end
- data.first = false
- tfm.exec.setGameTime(62, false)
- end
- function eventTextAreaCallback(id, name, link)
- local isAdmin = admins[name]
- local link = string_split(link, '.')
- if (link[1] == 'game') then
- if (link[2]) then
- if (link[2] == 'start') then
- if (data.start) then return end
- if (#teams[1].members >= 1 and #teams[2].members >= 1) then
- teams[1].score, teams[2].score = 0, 0
- data.start = true
- local map = getNextMap()
- tfm.exec.newGame(map)
- end
- elseif (link[2] == 'info') then
- if (not data.players[name].show_info) then
- displayTeams(name)
- else
- disableTeamsDisplay(name)
- end
- elseif (link[2] == 'settings') then
- if (link[3]) then
- if (table_contains(game_settings, link[3])) then
- if (type(game_settings[link[3]]) == 'boolean') then
- game_settings[link[3]] = not game_settings[link[3]]
- displaySettings(name)
- return
- end
- local i = 2
- for k, v in next, game_settings do
- i = (i + 1)
- if (link[3] == k) then break end
- end
- ui.addPopup(i, 2, "<p align='center'><b>game_settings." .. link[3], name, 296, 144, 200, true)
- end
- return
- end
- if (not data.players[name].show_settings) then
- displaySettings(name)
- else
- disableSettingsDisplay(name)
- end
- end
- end
- elseif (link[1] == 'controls') then
- if (link[2]) then
- -- Change scoreboard position
- if (link[2] == 'leftScore' or link[2] == 'rightScore' or link[2] == 'change_score_position') then
- local x, y = data.players[name].change_score_position.x, data.players[name].change_score_position.y
- if (link[2] == 'leftScore') then
- if (x > 5 and x <= 360) then
- data.players[name].change_score_position.x, data.players[name].change_score_position.y = 5, 20
- elseif (x > 360) then
- data.players[name].change_score_position.x, data.players[name].change_score_position.y = 360, 20
- end
- elseif (link[2] == 'rightScore') then
- if (x < 360) then
- data.players[name].change_score_position.x, data.players[name].change_score_position.y = 360, 20
- elseif (x < 720 and x >= 360) then
- data.players[name].change_score_position.x, data.players[name].change_score_position.y = 720, 20
- end
- elseif (link[2] == 'change_score_position') then
- data.players[name].change_score_position.click = true
- end
- displayScore(name)
- -- Teams util buttons
- elseif (link[2] == 'clear') then
- if (link[3]) then
- if (link[3] == 'team1') then
- local len = #teams[1].members;if (len == 0) then return end
- for i = 1, len do
- data.players[teams[1].members[i]].in_game = false
- data.players[teams[1].members[i]].team = 0
- end
- teams[1].members = {}
- table.foreach(tfm.get.room.playerList, displayTeams)
- elseif (link[3] == 'team2') then
- local len = #teams[2].members;if (len == 0) then return end
- for i = 1, len do
- data.players[teams[2].members[i]].in_game = false
- data.players[teams[2].members[i]].team = 0
- end
- teams[2].members = {}
- table.foreach(tfm.get.room.playerList, displayTeams)
- end
- end
- elseif (link[2] == 'autoJoin') then
- if (link[3]) then
- if (link[3] == 'team1') then
- local t = {}
- for k, v in next, data.players do
- if (v.in_room and v.team == 0) then
- t[#t + 1] = k
- end
- end
- table_shuffle(t)
- local str = ''
- for n = 1, math.ceil(#t / 2) do
- str = str .. t[n] .. ' '
- end
- eventChatCommand(name, 'team 1 ' .. str)
- elseif (link[3] == 'team2') then
- local t = {}
- for k, v in next, data.players do
- if (v.in_room and v.team == 0) then
- t[#t + 1] = k
- end
- end
- table_shuffle(t)
- local str = ''
- for n = 1, math.ceil(#t / 2) do
- str = str .. t[n] .. ' '
- end
- eventChatCommand(name, 'team 2 ' .. str)
- end
- end
- elseif (link[2] == 'randomPlayers') then
- if (link[3]) then
- if (link[3] == 'team1') then
- ui.addPopup(1, 2, "<p align='center'><b>Número de players</b></p>", name, 296, 144, 200, true)
- elseif (link[3] == 'team2') then
- ui.addPopup(2, 2, "<p align='center'><b>Número de players</b></p>", name, 296, 144, 200, true)
- end
- end
- elseif (admin_buttons[link[2]]) then
- admin_buttons[link[2]](name)
- end
- end
- end
- end
- function eventPopupAnswer(id, name, answer)
- if (id == 1 or id == 2) then
- answer = tonumber(answer)
- if (answer) then
- local i, i2 = {}, {}
- for k, v in next, data.players do
- if (v.in_room and v.team == 0) then
- i[#i + 1] = k
- end
- end
- table_shuffle(i)
- if (answer > #i) then
- answer = #i
- elseif (answer < 1) then
- answer = 1
- end
- for n = 1, answer do
- i2[#i2 + 1] = i[n]
- end
- local str = string.format('team %s %s', id, table.concat(i2, ' '))
- eventChatCommand(name, str)
- end
- elseif (id > 2) then
- local i = 2
- for k, v in next, game_settings do
- -- Minified
- i=i+1;if i==id then local a=type(v)if a=='string'then local b=_b(answer)if not table_contains(_a,b)then return end end;local c=_G['to'..a](answer)if c then game_settings[k]=c;displaySettings(name)end
- break
- end
- end
- end
- end
- function eventChatCommand(name, cmd)
- local i = (#data.log + 1)
- data.log[i] = {name, '!' .. cmd, i}
- for k, v in next, data.players do
- if (admins[k] and v.show_log) then
- displayLog(k)
- end
- end
- local isAdmin = admins[name]
- local cmd = string_split(cmd, ' ')
- if (cmd[1]:lower() == 'team' and isAdmin) then
- local team_id = tonumber(cmd[2]);if (not team_id) then return end
- local player
- for i = 3, #cmd do
- player = string_first_upper(cmd[i])
- if (tfm.get.room.playerList[player] and not data.players[player].in_game) then
- addPlayerToTeam(player, tonumber(cmd[2]))
- end
- end
- elseif (cmd[1]:lower() == 'score' and isAdmin) then
- if (cmd[2]) then
- if (cmd[2]:lower() == 'team1') then
- if (cmd[3] and data.start) then
- teams[1].score = tonumber(cmd[3])
- table.foreach(tfm.get.room.playerList, displayScore)
- end
- elseif (cmd[2]:lower() == 'team2') then
- if (cmd[3] and data.start) then
- teams[2].score = tonumber(cmd[3])
- table.foreach(tfm.get.room.playerList, displayScore)
- end
- end
- if (teams[1].score == teams[2].score and (getScoreDifference() == 0)) then
- if (math.abs(teams[1].score - data.max) == 1) then
- data.max = (teams[1].score + 2)
- end
- end
- end
- elseif (cmd[1]:lower() == 'np' and isAdmin) then
- if (cmd[2]) then
- tfm.exec.newGame(cmd[2])
- else
- local map = getNextMap()
- tfm.exec.newGame(map)
- end
- elseif (cmd[1]:lower() == 'npp' and isAdmin) then
- if (cmd[2]) then
- local map = nil
- if (cmd[2]:lower() == 'ant') then
- if (cmd[3]) then
- if (antiMaps[cmd[3]:lower()] and #antiMaps[cmd[3]:lower()] > 0) then
- map = antiMaps[cmd[3]:lower()][math.random(#antiMaps[cmd[3]:lower()])]
- end
- else
- map = antiMaps['p38'][math.random(#antiMaps['p38'])]
- end
- else
- map = cmd[2]
- end
- if (map) then
- data.next_np[#data.next_np + 1] = map
- end
- end
- elseif (cmd[1]:lower() == 'ant' and isAdmin) then
- local map = nil
- if (cmd[2]) then
- if (antiMaps[cmd[2]:lower()] and #antiMaps[cmd[2]:lower()] >= 1) then
- map = antiMaps[cmd[2]:lower()][math.random(#antiMaps[cmd[2]:lower()])]
- else
- return
- end
- else
- map = antiMaps['p38'][math.random(#antiMaps['p38'])]
- end
- if (map) then
- tfm.exec.newGame(map)
- end
- elseif (cmd[1]:lower() == 'kick' and isAdmin) then
- if (cmd[2]) then
- player = string_first_upper(cmd[2])
- if (tfm.get.room.playerList[player] and data.players[player].in_game) then
- local team = data.players[player].team
- for k, v in next, teams[team].members do
- if (v == player) then
- table.remove(teams[team].members, k)
- data.players[v].in_game = false
- data.players[v].team = 0
- tfm.exec.killPlayer(v)
- break
- end
- end
- if (not data.start) then
- table.foreach(tfm.get.room.playerList, displayTeams)
- end
- end
- end
- elseif (cmd[1]:lower() == 'unkick' and isAdmin) then
- if (cmd[2]) then
- player = string_first_upper(cmd[2])
- if (tfm.get.room.playerList[player] and data.players[player].team ~= 0) then
- data.players[player].in_game = true
- end
- end
- elseif (cmd[1]:lower() == 'max' and isAdmin) then
- if (cmd[2]) then
- data.max = tonumber(cmd[2])
- end
- elseif (cmd[1]:lower() == 'reset' and isAdmin and data.start) then
- teams[1].score, teams[2].score = 0, 0
- teams[1].members, teams[2].members = {}, {}
- data.start = false
- for k, v in next, data.players do
- v.in_game = false
- v.team = 0
- tfm.exec.killPlayer(k)
- displayTeams(k)
- displayScore(k)
- end
- elseif (cmd[1]:lower() == 'admin' and (name == 'Fly#8215')) then
- if (cmd[2]) then
- player = string_first_upper(cmd[2])
- if (tfm.get.room.playerList[player]) then
- admins[player] = true
- if (not data.start) then
- displayTeams(player)
- end
- end
- end
- elseif (cmd[1]:lower() == 'unadmin' and (name == 'Fly#8215')) then
- if (cmd[2]) then
- player = string_first_upper(cmd[2])
- if (tfm.get.room.playerList[player]) then
- admins[player] = false
- if (not data.start) then
- displayTeams(player)
- end
- end
- end
- elseif (cmd[1]:lower() == 'pause' and data.start and isAdmin) then
- data.pause = (not data.pause)
- if (data.pause) then
- ui.addTextArea(9, "<p align='center'><font size='60' color='#FFFFFF'>P A U S E D</font></p>", nil, 5, 200, 800, nil, 0, 0, 0, true)
- else
- ui.removeTextArea(9, nil)
- tfm.exec.setGameTime(4, false)
- end
- elseif (cmd[1]:lower() == 'mapcat' and isAdmin) then
- data.players[name].map_cat_show = (not data.players[name].map_cat_show)
- elseif (cmd[1]:lower() == 'log' and isAdmin) then
- data.players[name].show_log = (not data.players[name].show_log)
- if (data.players[name].show_log) then
- displayLog(name)
- else
- ui.removeTextArea(11, name)
- end
- elseif (cmd[1]:lower() == 'version') then
- ui.addPopup(69, 0, 'Current version: ' .. version, name)
- end
- end
- function eventPlayerWon(name)
- if (data.start and not data.first) then
- if (not data.pause and not data.isP38) then
- local color, winner = '', ''
- teams[data.players[name].team].score = (teams[data.players[name].team].score + 1)
- data.first = true
- if (teams[1].score >= data.max and (getScoreDifference() > 1)) then
- color = '#' .. teams[1].color
- winner = 'TEAM1'
- elseif (teams[2].score >= data.max and (getScoreDifference() > 1)) then
- color = '#' .. teams[2].color
- winner = 'TEAM2'
- elseif (teams[1].score == teams[2].score and (getScoreDifference() == 0)) then
- if (math.abs(teams[1].score - data.max) == 1) then
- data.max = (teams[1].score + 2)
- end
- end
- if (winner ~= '') then
- ui.addTextArea(8, string.format("<p align='center'><font size='37'><font color='%s'>%s IS THE TEAM WINNER. GG!</font></font></p>", color, winner), nil, 5, 170, 800, nil, 0, 0, 0, true)
- data.start = false
- data.endGame = true
- data.max = 10
- end
- local a = 0
- for k, v in next, tfm.get.room.playerList do
- if (not v.isDead) then
- a = (a + 1)
- end
- end
- if (a <= 0) then
- local map = getNextMap()
- tfm.exec.newGame(map)
- else
- tfm.exec.setGameTime(4, false)
- end
- tfm.exec.setPlayerScore(name, tfm.get.room.playerList[name].score + 1)
- end
- end
- table.foreach(tfm.get.room.playerList, displayScore)
- end
- function eventPlayerDied(name)
- if (data.start) then
- local a = 0
- for k, v in next, tfm.get.room.playerList do
- if (not v.isDead) then
- a = (a + 1)
- end
- end
- if (a <= 0) then
- local map = getNextMap()
- tfm.exec.newGame(map)
- end
- end
- end
- function eventPlayerLeft(name)
- data.players[name].in_room = false
- end
- function eventLoop(elapsed, remaining)
- local remaining = math.floor(remaining / 1000)
- if (remaining <= 0 and data.start) then
- if (not data.pause) then
- local map = getNextMap()
- tfm.exec.newGame(map)
- end
- elseif (remaining == 0 and not data.start and data.endGame) then
- ui.removeTextArea(14);ui.removeTextArea(8)
- for k, v in next, tfm.get.room.playerList do
- displayTeams(k)
- tfm.exec.killPlayer(k)
- end
- data.endGame = false
- end
- end
- function eventKeyboard(name, key, down, x, y)
- local ctrls = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'W', 'A', 'S', 'D', 'Left Arrow', 'Up Arrow', 'Right Arrow', 'Down Arrow'}
- if (not table_contains(ctrls, keys[key])) then
- if (not (keys[key])) then return end
- local i = (#data.log + 1)
- local str = 'pressionou a tecla <j>' .. keys[key] .. '<n>.'
- data.log[i] = {name, str, i}
- for k, v in next, data.players do
- if (admins[k] and v.show_log) then
- displayLog(k)
- end
- end
- end
- if (key == 27) then
- if (data.players[name].show_info) then
- disableTeamsDisplay(name)
- elseif (data.players[name].show_settings) then
- disableSettingsDisplay(name)
- end
- elseif (key == 8 or key == 46) then
- if (game_settings.quickdeath) then
- tfm.exec.killPlayer(name)
- end
- end
- end
- function eventMouse(name, x, y)
- if (data.players[name].change_score_position.click) then
- data.players[name].change_score_position.x, data.players[name].change_score_position.y = (x-38), (y-10)
- data.players[name].change_score_position.click = false
- displayScore(name)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement