Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- from https://www.lua.org/pil/11.4.html
- local List = {}
- function List.new ()
- return {first = 0, last = -1}
- end
- function List.pushleft (list, value)
- local first = list.first - 1
- list.first = first
- list[first] = value
- end
- function List.pushright (list, value)
- local last = list.last + 1
- list.last = last
- list[last] = value
- end
- function List.popleft (list)
- local first = list.first
- if first > list.last then
- return nil
- end
- local value = list[first]
- list[first] = nil -- to allow garbage collection
- list.first = first + 1
- return value
- end
- function List.popright (list)
- local last = list.last
- if list.first > last then
- return nil
- end
- local value = list[last]
- list[last] = nil -- to allow garbage collection
- list.last = last - 1
- return value
- end
- -- the lib
- local timerList = {}
- local timersPool = List.new()
- function addTimer(callback, ms, loops, label, ...)
- local id = List.popleft(timersPool)
- if id then
- local timer = timerList[id]
- timer.callback = callback
- timer.label = label
- timer.arguments = {...}
- timer.time = ms
- timer.currentTime = 0
- timer.currentLoop = 0
- timer.loops = loops or 1
- timer.isComplete = false
- timer.isPaused = false
- timer.isEnabled = true
- else
- id = #timerList+1
- timerList[id] = {
- callback = callback,
- label = label,
- arguments = {...},
- time = ms,
- currentTime = 0,
- currentLoop = 0,
- loops = loops or 1,
- isComplete = false,
- isPaused = false,
- isEnabled = true,
- }
- end
- return id
- end
- function getTimerId(label)
- local found
- for id = 1, #timerList do
- local timer = timerList[id]
- if timer.label == label then
- found = id
- break
- end
- end
- return found
- end
- function pauseTimer(id)
- if type(id) == 'string' then
- id = getTimerId(id)
- end
- if timerList[id] and timerList[id].isEnabled then
- timerList[id].isPaused = true
- return true
- end
- return false
- end
- function resumeTimer(id)
- if type(id) == 'string' then
- id = getTimerId(id)
- end
- if timerList[id] and timerList[id].isPaused then
- timerList[id].isPaused = false
- return true
- end
- return false
- end
- function removeTimer(id)
- if type(id) == 'string' then
- id = getTimerId(id)
- end
- if timerList[id] and timerList[id].isEnabled then
- timerList[id].isEnabled = false
- List.pushright(timersPool, id)
- return true
- end
- return false
- end
- function clearTimers()
- local timer
- repeat
- timer = List.popleft(timersPool)
- if timer then
- table.remove(timerList, timer)
- end
- until timer == nil
- end
- function timersLoop()
- for id = 1, #timerList do
- local timer = timerList[id]
- if timer.isEnabled and timer.isPaused == false then
- if not timer.isComplete then
- timer.currentTime = timer.currentTime + 500
- if timer.currentTime >= timer.time then
- timer.currentTime = 0
- timer.currentLoop = timer.currentLoop + 1
- if timer.loops > 0 then
- if timer.currentLoop >= timer.loops then
- timer.isComplete = true
- if eventTimerComplete ~= nil then
- eventTimerComplete(id, timer.label)
- end
- removeTimer(id)
- end
- end
- if timer.callback ~= nil then
- timer.callback(timer.currentLoop, table.unpack(timer.arguments))
- end
- end
- end
- end
- end
- end
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoScore (true)
- tfm.exec.disableAutoTimeLeft (true)
- tfm.exec.disablePhysicalConsumables (true)
- tfm.exec.disableAfkDeath (true)
- tfm.exec.setRoomMaxPlayers (16)
- system.disableChatCommandDisplay (nil, true)
- tfm.exec.disableMortCommand(true)
- tfm.exec.disableAllShamanSkills(true)
- local admins = {
- ["Refletz#6472"] = true,
- ["Soristl1#0000"] = true,
- ["Ipionle#0000"] = true,
- ["Ccfoudre#0000"] = true,
- ["Potinho1234#0000"] = true
- }
- local shamanSpawner = {
- [1] = {name = ''}
- }
- local teamSurvive = {
- [1] = {name = '', isLive = true},
- [2] = {name = '', isLive = true},
- [3] = {name = '', isLive = true},
- [4] = {name = '', isLive = true},
- [5] = {name = '', isLive = true}
- }
- local initGame = os.time() + 15000
- local gameTime = os.time() + 30000
- local gameTimeEnd = os.time() + 5000
- local maps = {
- [1] = '<C><P /><Z><S><S H="10" L="10" X="463" c="3" Y="60" T="1" P="0,0,0,0.2,0,0,0,0" /><S H="10" L="10" X="564" c="3" Y="60" T="1" P="0,0,0,0.2,0,0,0,0" /><S H="10" L="10" X="513" c="3" Y="102" T="1" P="0,0,0,0.2,0,0,0,0" /><S H="10" L="10" X="460" c="3" Y="124" T="1" P="0,0,0,0.2,0,0,0,0" /><S H="10" L="10" X="564" c="3" Y="124" T="1" P="0,0,0,0.2,0,0,0,0" /><S H="84" L="10" o="324650" X="193" c="3" v="10000" Y="86" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="10" o="324650" X="268" c="3" v="10000" Y="86" T="12" H="84" /><S H="84" L="10" o="324650" X="230" c="3" v="10000" Y="49" T="12" P="0,0,0.3,0.2,90,0,0,0" /><S P="0,0,0.3,0.2,90,0,0,0" L="10" o="324650" X="230" c="3" v="10000" Y="123" T="12" H="84" /><S P="0,0,0.3,0,0,0,0,0" L="10" X="419" c="3" Y="169" T="19" H="53" /><S P="0,0,0,0.2,60,0,0,0" L="10" X="390" c="3" Y="206" T="1" H="60" /><S P="0,0,0,0.2,0,0,0,0" L="76" X="334" c="3" Y="224" T="1" H="10" /><S P="0,0,0,0.2,0,0,0,0" L="10" H="10" c="3" Y="170" T="1" X="511" /><S X="460" L="10" H="10" c="3" Y="200" T="1" P="0,0,0,0.2,0,0,0,0" /><S X="564" L="10" H="10" c="3" Y="201" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="10" X="774" H="63" Y="376" T="3" P="0,0,0,20,50,0,0,0" /><S L="10" H="63" X="27" Y="380" T="3" P="0,0,0,20,-50,0,0,0" /><S P="0,0,0,0.2,0,0,0,0" L="10" X="309" c="3" Y="274" T="1" H="10" /><S P="0,0,0,0.2,0,0,0,0" L="10" X="385" c="3" Y="278" T="1" H="10" /><S P="0,0,0,0.2,0,0,0,0" L="10" X="461" c="3" Y="266" T="1" H="10" /><S P="0,0,0,0.2,0,0,0,0" L="10" X="515" c="3" Y="239" T="1" H="10" /><S H="10" L="10" X="253" c="3" Y="256" T="1" P="0,0,0,0.2,0,0,0,0" /></S><D><DS Y="105" X="461" /></D><O /></Z></C>'
- }
- local playersJoined = {}
- local mode = ""
- local gameStats = {
- msgWinner = '',
- modePlayersSurviveSkills = true,
- modePortals = false,
- modeSurvive = false,
- modeDefense = false,
- modeThreeLifes = true
- }
- local playerDirection = {}
- local playerActions = {}
- local playerLife = {}
- local playersOnPageCommands = {}
- local x = {280, 460, 640, 280, 460}
- local y = {100, 100, 100, 160, 160}
- for name, data in pairs(tfm.get.room.playerList) do
- tfm.exec.setPlayerScore(name, 0, false)
- playersJoined[name] = false
- playerDirection[name] = 0
- playerActions[name] = {canShoot = true, canAttachBallon = true}
- playerLife[name] = 0
- playersOnPageCommands[name] = false
- end
- function ui.addWindow(id, text, player, x, y, width, height, alpha, corners, closeButton, buttonText)
- id = tostring(id)
- ui.addTextArea(id.."0", "", player, x+1, y+1, width-2, height-2, 0x8a583c, 0x8a583c, alpha, true)
- ui.addTextArea(id.."00", "", player, x+3, y+3, width-6, height-6, 0x2b1f19, 0x2b1f19, alpha, true)
- ui.addTextArea(id.."000", "", player, x+4, y+4, width-8, height-8, 0xc191c, 0xc191c, alpha, true)
- ui.addTextArea(id.."0000", "", player, x+5, y+5, width-10, height-10, 0x2d5a61, 0x2d5a61, alpha, true)
- ui.addTextArea(id.."00000", text, player, x+5, y+6, width-10, height-12, 0x142b2e, 0x142b2e, alpha, true)
- local imageId = {}
- if corners then
- table.insert(imageId, tfm.exec.addImage("155cbe97a3f.png", "&1", x-7, (y+height)-22, player))
- table.insert(imageId, tfm.exec.addImage("155cbe99c72.png", "&1", x-7, y-7, player))
- table.insert(imageId, tfm.exec.addImage("155cbe9bc9b.png", "&1", (x+width)-20, (y+height)-22, player))
- table.insert(imageId, tfm.exec.addImage("155cbea943a.png", "&1", (x+width)-20, y-7, player))
- end
- if closeButton then
- ui.addTextArea(id.."000000", "", player, x+8, y+height-22, width-16, 13, 0x7a8d93, 0x7a8d93, alpha, true)
- ui.addTextArea(id.."0000000", "", player, x+9, y+height-21, width-16, 13, 0xe1619, 0xe1619, alpha, true)
- ui.addTextArea(id.."00000000", "", player, x+9, y+height-21, width-17, 12, 0x314e57, 0x314e57, alpha, true)
- ui.addTextArea(id.."", buttonText, player, x+9, y+height-24, width-17, nil, 0x314e57, 0x314e57, 0, true)
- end
- return imageId
- end
- function closeWindow(id, name)
- local id = tostring(id)
- local str = "0"
- ui.removeTextArea(id, name)
- for i = 1, 9 do
- ui.removeTextArea(id..""..str.."", name)
- str = ""..str.."0"
- end
- end
- function init()
- mode = "startGame"
- tfm.exec.disableAllShamanSkills(true)
- for name, data in pairs(tfm.get.room.playerList) do
- playersJoined[name] = false
- playerDirection[name] = 0
- playerActions[name] = {canShoot = true, canAttachBallon = true}
- playerLife[name] = 0
- for j = 0, 3 do
- system.bindKeyboard(name, j, true, false)
- system.bindKeyboard(name, j, false, false)
- end
- system.bindKeyboard(name, 32, false, false)
- end
- tfm.exec.newGame('<C><P /><Z><S><S L="800" H="50" X="400" Y="385" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S m="" L="10" H="404" X="2" Y="202" T="1" P="0,0,0,0.2,0,0,0,0" /><S m="" L="10" X="795" H="404" Y="203" T="1" P="0,0,0,0.2,0,0,0,0" /><S m="" L="10" H="800" X="396" Y="7" T="1" P="0,0,0,0.2,90,0,0,0" /></S><D><DS Y="349" X="400" /><P P="0,0" Y="359" T="6" X="217" /><P P="0,0" Y="363" T="4" X="580" /><P P="0,0" Y="360" T="5" X="319" /><P P="0,0" Y="0" T="257" X="0" /></D><O /></Z></C>')
- shamanSpawner = {
- [1] = {name = ''}
- }
- gameStats = {
- msgWinner = '',
- modePlayersSurviveSkills = true,
- modePortals = false,
- modeSurvive = false,
- modeDefense = false,
- modeThreeLifes = true
- }
- teamSurvive = {
- [1] = {name = '', isLive = true},
- [2] = {name = '', isLive = true},
- [3] = {name = '', isLive = true},
- [4] = {name = '', isLive = true},
- [5] = {name = '', isLive = true}
- }
- ui.addTextArea(6, "<p align='center'>", nil, 375, 50, 30, 20, 0x161616, 0x161616, 1, false)
- ui.addTextArea(0, "<p align='center'><font size='14px'><a href='event:shamanSpawner'>Join", nil, 100, 100, 150, 40, 0xE14747, 0xE14747, 1, false)
- for i = 1, 5 do
- ui.addTextArea(i, "<p align='center'><font size='14px'><a href='event:joinTeam"..i.."'>Join", nil, x[i], y[i], 150, 40, 0x184F81, 0x184F81, 1, false)
- end
- initGame = os.time() + 15000
- end
- function eventTextAreaCallback(id, name, c)
- if c == "shamanSpawner" and not playersJoined[name] and shamanSpawner[1].name == '' then
- shamanSpawner[1].name = name
- playersJoined[name] = true
- ui.addTextArea(0, "<p align='center'><font size='14px'><a href='event:shamanSpawnerLeave'>"..shamanSpawner[1].name.."", nil, 100, 100, 150, 40, 0x871F1F, 0x871F1F, 1, false)
- elseif c == "shamanSpawnerLeave" and shamanSpawner[1].name == name then
- shamanSpawner[1].name = ''
- playersJoined[name] = false
- ui.addTextArea(0, "<p align='center'><font size='14px'><a href='event:shamanSpawner'>Join", nil, 100, 100, 150, 40, 0xE14747, 0xE14747, 1, false)
- elseif string.sub(c, 1, 8) == "joinTeam" and not playersJoined[name] and teamSurvive[tonumber(string.sub(c, 9))].name == '' then
- local index = tonumber(string.sub(c, 9))
- teamSurvive[index].name = name
- playersJoined[name] = true
- ui.addTextArea(index, "<p align='center'><font size='14px'><a href='event:leaveTeam"..index.."'>"..name.."", nil, x[index], y[index], 150, 40, 0x0B3356, 0x0B3356, 1, false)
- elseif string.sub(c, 1, 9) == "leaveTeam" and teamSurvive[tonumber(string.sub(c, 10))].name == name then
- local index = tonumber(string.sub(c, 10))
- playersJoined[name] = false
- teamSurvive[index].name = ''
- ui.addTextArea(index, "<p align='center'><font size='14px'><a href='event:joinTeam"..index.."'>Join", nil, x[index], y[index], 150, 40, 0x184F81, 0x184F81, 1, false)
- elseif c == "closeInterfaceListCommands" then
- closeWindow(22, name)
- for i = 19994, 19997 do
- ui.removeTextArea(i, name)
- end
- playersOnPageCommands[name] = false
- end
- if admins[name] then
- if c == "mode1" then
- if gameStats.modePlayersSurviveSkills then
- gameStats.modePlayersSurviveSkills = false
- reloadInterfaceListCommands()
- return
- end
- gameStats.modePlayersSurviveSkills = true
- reloadInterfaceListCommands()
- elseif c == "mode2" then
- if gameStats.modePortals then
- gameStats.modePortals = false
- reloadInterfaceListCommands()
- return
- end
- gameStats.modePortals = true
- reloadInterfaceListCommands()
- elseif c == "mode3" then
- if gameStats.modeSurvive then
- gameStats.modeSurvive = false
- reloadInterfaceListCommands()
- return
- end
- gameStats.modeSurvive = true
- reloadInterfaceListCommands()
- elseif c == "mode4" then
- if gameStats.modeDefense then
- gameStats.modeDefense = false
- reloadInterfaceListCommands()
- return
- end
- gameStats.modeDefense = true
- reloadInterfaceListCommands()
- elseif c == "mode5" then
- if gameStats.modeThreeLifes then
- gameStats.modeThreeLifes = false
- reloadInterfaceListCommands()
- return
- end
- gameStats.modeThreeLifes = true
- reloadInterfaceListCommands()
- end
- end
- end
- function reloadInterfaceListCommands()
- for name, data in pairs(tfm.get.room.playerList) do
- if playersOnPageCommands[name] then
- interfaceListCommands(name)
- end
- end
- end
- function interfaceListCommands(name)
- ui.addWindow(22, "<p align='center'>Lista de comandos", name, 125, 60, 650, 300, 1, false, true, "<p align='center'><a href='event:closeInterfaceListCommands'>Fechar</a>")
- ui.addTextArea(19994, "Habilidades para o rato<br>Modo de portais<br>Modo sobrevivência<br>", name, 140, 90, 200, 220, 0xc191c, 0xc191c, 1, true)
- ui.addTextArea(19995, ""..verifyIsModeEnable(gameStats.modePlayersSurviveSkills, 'mode1').."<br>"..verifyIsModeEnable(gameStats.modePortals, 'mode2').."<br>"..verifyIsModeEnable(gameStats.modeSurvive, 'mode3').."", name, 360, 90, 50, 220, 0xc191c, 0xc191c, 1, true)
- ui.addTextArea(19996, "Modo de defesa<br>Modo de três vidas", name, 480, 90, 200, 220, 0xc191c, 0xc191c, 1, true)
- ui.addTextArea(19997, ""..verifyIsModeEnable(gameStats.modeDefense , 'mode4').."<br>"..verifyIsModeEnable(gameStats.modeThreeLifes, 'mode5').."", name, 700, 90, 50, 220, 0xc191c, 0xc191c, 1, true)
- playersOnPageCommands[name] = true
- end
- function verifyIsModeEnable(mode, callback)
- if mode then
- return "<vp><a href='event:"..callback.."'>[ Sim ]</a><n>"
- end
- return "<r><a href='event:"..callback.."'>[ Não ]</a><n>"
- end
- function eventLoop(elapsedTime, remainingTime)
- if mode == "startGame" then
- local x = math.ceil((initGame - os.time())/1000)
- local c = string.format("%d", x)
- ui.addTextArea(6, "<p align='center'>"..c.."", nil, 375, 50, 30, 20, 0x161616, 0x161616, 1, false)
- if x == 0 then
- local playersOnGame = quantityPlayers()
- if playersOnGame.shaman == 1 and playersOnGame.players >= 1 then
- mode = "gameStart"
- startGame()
- else
- initGame = os.time() + 15000
- end
- end
- elseif mode == "gameStart" then
- local x = math.ceil((gameTime - os.time())/1000)
- local c = string.format("%d", x)
- ui.addTextArea(6, "<p align='center'>"..c.."", nil, 375, 380, 30, 20, 0x161616, 0x161616, 1, false)
- if x == 0 then
- local playersOnGame = quantityPlayers()
- if playersOnGame.players == 0 then
- gameStats.msgWinner = "O totem do shaman venceu!"
- tfm.exec.setPlayerScore(shamanSpawner[1].name, 10, true)
- else
- gameStats.msgWinner = "Os sobreviventes venceram!"
- for i = 1, 5 do
- if teamSurvive[i].name ~= '' then
- tfm.exec.setPlayerScore(teamSurvive[i].name, 10, true)
- end
- end
- end
- gameTimeEnd = os.time() + 5000
- mode = "gameEnd"
- end
- elseif mode == "gameEnd" then
- local x = math.ceil((gameTimeEnd - os.time())/1000)
- local c = string.format("%d", x)
- ui.addTextArea(6, "<p align='center'><font size='30px'><textformat leading='150'><br>"..gameStats.msgWinner.."", nil, 0, 0, 800, 400, 0x161616, 0x161616, 0.8, true)
- if x == 0 then
- removeTimer('mode_portals')
- removeTimer('mode_survive')
- init()
- end
- end
- timersLoop()
- end
- function eventChatCommand(name, c)
- if admins[name] then
- if c == "rr" and mode == "gameStart" then
- gameTime = os.time() + 5000
- elseif c == "resettimer" then
- initGame = os.time() + 15000
- elseif c == "test" then
- shamanSpawner[1].name = 'asdasd'
- elseif c == "cmds" then
- interfaceListCommands(name)
- end
- end
- end
- function startGame()
- tfm.exec.newGame(maps[1])
- for name, data in pairs(tfm.get.room.playerList) do
- if not playersJoined[name] then
- tfm.exec.killPlayer(name)
- end
- end
- removeTextAreasOfLobby()
- teleportPlayers()
- killShaman()
- addBonus()
- PlayersSurviveSkills()
- modePortals()
- modeSurvive()
- modeDefense()
- gameTime = os.time() + 30000
- modeThreeLifes()
- end
- function modeThreeLifes()
- if gameStats.modeThreeLifes then
- gameTime = os.time() + 5 * 60000 -- 5 minutes
- for i = 1, 5 do
- if teamSurvive[i].name ~= '' then
- playerLife[teamSurvive[i].name] = 2
- end
- end
- end
- end
- function modePortals()
- if gameStats.modePortals then
- mode_portals = addTimer(function(i)
- local portals_spawn_x = {461, 461, 513, 563, 563, 514, 588, 384, 355}
- local portals_spawn_y = {105, 40, 81, 105, 40, 216, 269, 256, 204}
- local portal_orange = math.random(1, #portals_spawn_x)
- local portal_blue = math.random(1, #portals_spawn_x)
- local portal_orange_id = tfm.exec.addShamanObject(27, portals_spawn_x[portal_orange], portals_spawn_y[portal_orange], 0, 0, 0, true)
- local portal_blue_id = tfm.exec.addShamanObject(26, portals_spawn_x[portal_blue], portals_spawn_y[portal_blue], 0, 0, 0, true)
- if i == 5 then
- tfm.exec.removeObject(portal_orange_id)
- tfm.exec.removeObject(portal_blue_id)
- end
- end, 5000, 5, "mode_portals")
- end
- end
- function modeSurvive()
- if gameStats.modeSurvive then
- mode_survive = addTimer(function(i)
- local spawn_x = {461, 461, 513, 563, 563, 514, 588, 384, 355}
- local spawn_y = {105, 40, 81, 105, 40, 216, 269, 256, 204}
- local randomIndex = math.random(1, #spawn_x)
- tfm.exec.addBonus(2, spawn_x[randomIndex], spawn_y[randomIndex], math.random(), 0, true, nil)
- end, 5000, 5, "mode_survive")
- end
- end
- function modeDefense()
- if gameStats.modeDefense then
- tfm.exec.addPhysicObject(1, 431, 161, {
- type = 8,
- width = 10,
- height = 620,
- miceCollision = false,
- groundCollision = true
- })
- mode_defense = addTimer(function(i)
- tfm.exec.removePhysicObject(1)
- end, 7000, 1, "mode_defense")
- end
- end
- function PlayersSurviveSkills()
- if gameStats.modePlayersSurviveSkills then
- for i = 1, 5 do
- if teamSurvive[i].name ~= '' then
- for j = 0, 3 do
- system.bindKeyboard(teamSurvive[i].name, j, true, true)
- system.bindKeyboard(teamSurvive[i].name, j, false, true)
- end
- system.bindKeyboard(teamSurvive[i].name, 32, true, true)
- system.bindKeyboard(teamSurvive[i].name, 32, false, true)
- end
- end
- end
- end
- function eventKeyboard(name, key, down, x, y, xPlayerVelocity, yPlayerVelocity)
- if key >= 0 and key <= 3 then
- tfm.get.room.playerList[name].x = x
- tfm.get.room.playerList[name].y = y
- if key == 0 or key == 2 then
- playerDirection[name] = key
- elseif key == 3 and playersJoined[name] and playerActions[name].canShoot then
- playerActions[name].canShoot = false
- local xVelocity = 0
- local xPlayer = 0
- if playerDirection[name] == 0 then
- xVelocity = -170
- xPlayer = -2
- elseif playerDirection[name] == 2 then
- xVelocity = 170
- xPlayer = 2
- end
- local cannonId = tfm.exec.addShamanObject(17, 0, 0, 0, 0, 0, false)
- tfm.exec.moveObject(cannonId, x - xPlayer, y+8, false, xVelocity, -10, false, 0, false)
- cannonShoot = addTimer(function(i)
- if i == 1 then
- tfm.exec.removeObject(cannonId)
- end
- end, 3000, 1, "cannonShoot")
- end
- elseif key == 32 and playersJoined[name] and playerActions[name].canAttachBallon then
- playerActions[name].canAttachBallon = false
- local ballonId = tfm.exec.attachBalloon(name, true, 1, true, 1)
- AttachBallon = addTimer(function(i)
- if i == 1 then
- tfm.exec.removeObject(ballonId)
- end
- end, 10000, 1, "AttachBallon")
- end
- end
- function teleportPlayers()
- local coordinateSpawnSurvives = {
- x = {461, 461, 513, 563, 563},
- y = {105, 40, 81, 105, 40}
- }
- local coordinateSpawnShaman = {x = 230, y = 90}
- tfm.exec.movePlayer(shamanSpawner[1].name, coordinateSpawnShaman.x, coordinateSpawnShaman.y)
- tfm.exec.setShaman(shamanSpawner[1].name, true)
- for i = 1, 5 do
- local randomIndex = math.random(1, 5)
- tfm.exec.movePlayer(teamSurvive[i].name, coordinateSpawnSurvives.x[randomIndex], coordinateSpawnSurvives.y[randomIndex])
- end
- end
- function quantityPlayers()
- local quantity = {shaman = 0, players = 0}
- if shamanSpawner[1].name ~= '' then
- quantity.shaman = 1
- end
- for i = 1, 5 do
- if teamSurvive[i].name ~= '' then
- quantity.players = quantity.players + 1
- end
- end
- return quantity
- end
- function removeTextAreasOfLobby()
- for i = 0, 6 do
- ui.removeTextArea(i)
- end
- end
- function killShaman()
- tfm.exec.disableAllShamanSkills(false)
- kill_Shaman = addTimer(function(i)
- if i == 1 then
- tfm.exec.killPlayer(shamanSpawner[1].name)
- tfm.exec.disableAllShamanSkills(true)
- end
- end, 10000, 1, "kill_Shaman")
- end
- function addBonus()
- local x = {254, 422, 539}
- for i = 1, 3 do
- tfm.exec.addBonus(3, x[i], 331, i, 0, true, nil)
- end
- end
- function eventNewPlayer(name)
- tfm.exec.setPlayerScore(name, 0, false)
- tfm.exec.respawnPlayer(name)
- playersJoined[name] = false
- playersOnPageCommands[name] = false
- playerDirection[name] = 0
- playerLife[name] = 0
- playerActions[name] = {canShoot = true, canAttachBallon = true}
- if mode == "startGame" then
- if shamanSpawner[1].name == '' then
- ui.addTextArea(0, "<p align='center'><font size='14px'><a href='event:shamanSpawner'>Join", nil, 100, 100, 150, 40, 0xE14747, 0xE14747, 1, false)
- else
- ui.addTextArea(0, "<p align='center'><font size='14px'><a href='event:shamanSpawnerLeave'>"..shamanSpawner[1].name.."", nil, 100, 100, 150, 40, 0x871F1F, 0x871F1F, 1, false)
- end
- for i = 1, 5 do
- if teamSurvive[i].name == '' then
- ui.addTextArea(i, "<p align='center'><font size='14px'><a href='event:joinTeam"..i.."'>Join", nil, x[i], y[i], 150, 40, 0x184F81, 0x184F81, 1, false)
- else
- ui.addTextArea(i, "<p align='center'><font size='14px'><a href='event:leaveTeam"..i.."'>"..teamSurvive[i].name.."", nil, x[i], y[i], 150, 40, 0x0B3356, 0x0B3356, 1, false)
- end
- end
- end
- end
- function eventPlayerLeft(name)
- if mode == "startGame" then
- for i = 1, 5 do
- if teamSurvive[i].name == name then
- teamSurvive[i].name = ''
- ui.addTextArea(i, "<p align='center'><font size='14px'><a href='event:joinTeam"..i.."'>Join", nil, x[i], y[i], 150, 40, 0x184F81, 0x184F81, 1, false)
- end
- if shamanSpawner[1].name == name then
- ui.addTextArea(0, "<p align='center'><font size='14px'><a href='event:shamanSpawner'>Join", nil, 100, 100, 150, 40, 0xE14747, 0xE14747, 1, false)
- end
- end
- end
- if mode ~= "startGame" then
- for i = 1, 5 do
- if teamSurvive[i].name == name then
- teamSurvive[i].name = ''
- end
- end
- verifyQuantityPlayers()
- end
- end
- function eventPlayerDied(name)
- if mode == "gameStart" then
- if gameStats.modeThreeLifes then
- if playerLife[name] == 0 then
- for i = 1, 5 do
- if teamSurvive[i].name == name then
- teamSurvive[i].name = ''
- end
- end
- else
- playerLife[name] = playerLife[name] - 1
- respawnPlayer = addTimer(function(i)
- if i == 1 then
- tfm.exec.respawnPlayer(name)
- local coordinateSpawnSurvives = {
- x = {461, 461, 513, 563, 563},
- y = {105, 40, 81, 105, 40}
- }
- local randomIndex = math.random(1, 5)
- tfm.exec.movePlayer(name, coordinateSpawnSurvives.x[randomIndex], coordinateSpawnSurvives.y[randomIndex])
- if gameStats.modePlayersSurviveSkills then
- playerActions[name] = {canShoot = true, canAttachBallon = true}
- end
- end
- end, 3000, 1, "respawnPlayer")
- end
- else
- for i = 1, 5 do
- if teamSurvive[i].name == name then
- teamSurvive[i].name = ''
- end
- end
- end
- verifyQuantityPlayers()
- end
- end
- function verifyQuantityPlayers()
- local playersOnGame = quantityPlayers()
- if playersOnGame.players == 0 then
- gameStats.msgWinner = "O totem do shaman venceu!"
- gameTimeEnd = os.time() + 5000
- tfm.exec.setPlayerScore(shamanSpawner[1].name, 10, true)
- mode = "gameEnd"
- end
- end
- init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement