Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- admin = "Suguuru"
- teamPlayers = {
- {"Suguuru#0000", "", "", "", ""};
- {"Minifinny#0000", "", "", "", "", ""};
- }
- goalScore = 15
- maps = {424361,5813783,6607378,3209087,7424218,6571685,7386817,3549484,3603802,5886096,7611818,
- 7611847}
- ------------------------------------------------------------
- teamColor = {0xCC0000, 0x0033FF}
- teamScore = {0,0}
- gameStarted = nil
- gameFinished = nil
- currentMap = nil
- playersAlive = nil
- playersInRoom = 0
- players = {}
- team = {}
- first = nil
- teamList = {"",""}
- for i=1,2 do
- for _,name in pairs(teamPlayers[i]) do
- team[name] = i
- teamList[i] = teamList[i] .. name .. "\n"
- end
- end
- function main()
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoTimeLeft(true)
- for name in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- tfm.exec.newGame(0)
- local x = {110,690}
- for name,t in pairs(team) do
- tfm.exec.movePlayer(name, x[t], 350)
- end
- tfm.exec.movePlayer(admin, 400, 350)
- ui.addTextArea(1, "<font size='16'>Equipo 1</font>\n\n"..teamList[1], nil, 30, 54, 160, 320, 0x4a4d60, 0x3a3d4b, 0.8, true)
- ui.addTextArea(2, "<font size='16'>Equipo 2</font>\n\n"..teamList[2], nil, 610, 54, 160, 320, 0x4a4d60, 0x3a3d4b, 0.8, true)
- ui.addTextArea(3, "<p align='center'><font size='16'><a href='event:start'> Empezar </a></font></p>", admin, 320, 180, 160, 32, 0x4a4d60, 0x3a3d4b, 1, true)
- end
- function startGame()
- local newMap
- repeat
- newMap = math.random(#maps)
- until newMap ~= currentMap
- currentMap = newMap
- tfm.exec.newGame(maps[newMap])
- end
- function endGame()
- startGame()
- end
- function eventNewGame()
- playersAlive = playersInRoom
- first = false
- for name,t in pairs(team) do
- tfm.exec.setNameColor(name, teamColor[t])
- end
- tfm.exec.setGameTime(60)
- end
- function eventNewPlayer(name)
- if team[name] then
- playersInRoom = playersInRoom + 1
- end
- end
- function eventPlayerLeft(name)
- if team[name] then
- playersInRoom = playersInRoom - 1
- end
- end
- function eventPlayerDied(name)
- if not gameStarted then return end
- if team[name] then
- playersAlive = playersAlive - 1
- checkPlayers()
- end
- end
- function eventPlayerWon(name)
- if not gameStarted then return end
- if team[name] then
- if not first then
- first = true
- local t = team[name]
- teamScore[t] = teamScore[t] + 1
- updateScore()
- tfm.exec.setGameTime(5)
- if teamScore[t] == goalScore then
- gameStarted = false
- gameFinished = true
- local c = {"#F90505","#0045FF"}
- ui.addTextArea(5, "<p align='center'><font size='20' color='" .. c[t] .. "'>¡El equipo " .. t .. " ha ganado!</font></p>", nil, 0, 170, 800, 60, 0, 0, 0, true)
- end
- end
- playersAlive = playersAlive - 1
- checkPlayers()
- end
- end
- function checkPlayers()
- if playersAlive == 0 then
- endGame()
- end
- end
- function eventLoop(t, tr)
- if gameFinished then
- for i=1,8 do
- local x,y = math.random(0,800), math.random(0,400)
- for j=1,5 do
- tfm.exec.displayParticle(math.random(21,24), x, y, math.random(-5,5), 0, 0, math.random(10)/10, nil)
- end
- end
- end
- if not gameStarted then return end
- if tr <= 0 then
- endGame()
- end
- end
- function eventTextAreaCallback(id, name, cb)
- if id == 3 and not gameStarted then
- gameStarted = true
- for i=1,3 do
- ui.removeTextArea(i)
- end
- updateScore()
- startGame()
- end
- end
- function updateScore()
- local t = string.format("<p align='center'><font size='32'><font color='#F90505'>%02d</font> - <font color='#0045FF'>%02d</font></font></p>", teamScore[1], teamScore[2])
- ui.addTextArea(4, t, nil, 320, 20, 160, 43, 0x4a4d60, 0x3a3d4b, 0, true)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement