Lua Farm

Descargar como txt, pdf o txt
Descargar como txt, pdf o txt
Está en la página 1de 15

--[[

FALTA
restart sin recargar lua
poder cambiar la cantidad de tiempo y mapas en la interfaz y no en el codigo
[Se puede desde el chat]

▄▄▄█████▓█ █░▒█████ ▄▄▄█████▓█████▄▄▄ ███▄ ▄███▓ ██████


▓ ██▒ ▓▓█░ █ ░█▒██▒ ██▒ ▓ ██▒ ▓▓█ ▒████▄ ▓██▒▀█▀ ██▒██ ▒
▒ ▓██░ ▒▒█░ █ ░█▒██░ ██▒ ▒ ▓██░ ▒▒███ ▒██ ▀█▄ ▓██ ▓██░ ▓██▄
░ ▓██▓ ░░█░ █ ░█▒██ ██░ ░ ▓██▓ ░▒▓█ ░██▄▄▄▄██▒██ ▒██ ▒ ██▒
▒██▒ ░░░██▒██▓░ ████▓▒░ ▒██▒ ░░▒████▓█ ▓██▒██▒ ░██▒██████▒▒
▒ ░░ ░ ▓░▒ ▒ ░ ▒░▒░▒░ ▒ ░░ ░░ ▒░ ▒▒ ▓▒█░ ▒░ ░ ▒ ▒▓▒ ▒ ░
░ ▒ ░ ░ ░ ▒ ▒░ ░ ░ ░ ░▒ ▒▒ ░ ░ ░ ░▒ ░ ░
░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ▒ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░
by Blood#3565 and Misterthepro#0000
version 1.0

]]

--[[
Comandos:
!team1 [player] -- Establece los jugadores del equipo 1
!team2 [player] -- Establece los jugadores del equipo 2
!add team1 [player] -- Añade jugadores al equipo 1
!add team2 [player] -- Añade jugadores al equipo 2
!next o !n -- Cambia al siguiente mapa en el lobby
!timemap [segundos] o !maptime [segundos] o !tm [segundos] o !mt [segundos] --
Cambia en segundos el tiempo de cada mapa
!maps [cantidad] o !mapas [cantidad] o !m [cantidad] -- Cambia la cantidad
total de mapas a jugar
!addtime [segundos] -- Añade segundos al mapa actual
!admin [jugador] -- Añade un nuevo admin
!unadmin [jugador] -- Elimina a un admin

]]

local _, msg = pcall(nil)


local admin = string.match(msg, "^(.-)%.")

--[[
players = almacena la lista de jugadores de cada equipo
points = los puntos de cada equipo
countPlayers = la cantidad de jugadores de cada equipo
]] -- Variables más globales
local admins = {
[admin] = true, -- Este pertenece a quien cargó el lua, no es necesario que lo
cambies
["Blood#3565"] = true,
["Alditohacker#0000"] = true,
["S_hippo#0000"] = true}
local teams = {team1 = {players = {}, points = 0, countPlayers = 1, color = "<font
color='#CB546B'>", totalPlayers = 0},
team2 = {players = {}, points = 0, countPlayers = 1, color = "<font
color='#2F7FCC'>", totalPlayers = 0}}
local playerInfo = {}
local playerIn, index = "", 0 -- variable que se modifica para saber en que equipo
está el jugador
local mapTime = 180 -- tiempo de cada mapa bootcamp
local autoJoin = "OFF"
local watchingRecords = {} -- personas que tienen abierta la lista de records
(Letra L)
watchingRecords["always"] = true
local maps = {'#3', '#3'}
--local maps = {'7053913', '7053913'}
local mapsPlayed, mapsToPlay = 0, 3 -- Mapas Jugados / Mapas por jugar
local actualMap = 666666 -- código del mapa
local os_time = os.time

-- Colores
local verde = "<font color='#00C17C'>"
local morado = "<font color='#C53DFF'>"

-- Variables que se deberían resetear al iniciar un nuevo mapa:


main = function()
toRespawn = {}
primerPuesto, segundoPuesto, tercerPuesto = false, false, false
times = {}
countTimes = 1
recordsString = "\n<textformat tabstops='[29, 205]'>"
putAmount()
end

-- Variables que se deberían resetear al iniciar una nueva partida


restart = function()
inGame = false
mapBc = true
bestTimes, countBestTimes = {}, 1
infoText = "<p align='center'><font color='#00C17C' size='15'><b>Pasando al
siguiente mapa</b>"
end

putAmount = function()
for name in next, playerInfo do --
playerInfo[name].totalAmount = playerInfo[name].totalAmount +
playerInfo[name].amount
playerInfo[name].amount = 0
playerInfo[name].alreadyRespawn = false
end
end

main()
restart()

keys = function(name) -- activa las teclas necesarias


tfm.exec.bindKeyboard(name, 76, false, true) -- L
tfm.exec.bindKeyboard(name, 46, false, true) -- Supr
tfm.exec.bindKeyboard(name, 17, false, true) -- Ctrl
end

tfm.exec.disableAutoScore()
tfm.exec.disableAutoShaman()
tfm.exec.disableAutoTimeLeft()
tfm.exec.disableAutoNewGame()
tfm.exec.disableAfkDeath()
tfm.exec.disablePhysicalConsumables()
removeText = function(min, max, name)
for min = min, max do
ui.removeTextArea(min, name)
end
end

inTeam = function(player) -- verifica si el jugador ya está en un team, guarda en


una variable global cuál es su team y su index
for i, name in next, teams.team1.players do
if name == player then
playerIn = "team1"
index = i
return true
end
end
for i, name in next, teams.team2.players do
if name == player then
playerIn = "team2"
index = i
return true
end
end
end

putColor = function(name)
if inTeam(name) then
local color = teams[playerIn].color:gsub("<font color='#", "0x"):gsub("'>",
"")
tfm.exec.setNameColor(name, color)
end
end

addPoints = function(name, points)


inTeam(name)
teams[playerIn].points = teams[playerIn].points + points
playerInfo[name].scorePoints = playerInfo[name].scorePoints + points
tfm.exec.setPlayerScore(name, points, true)
end

addPlayerTeam = function(team, player) -- Agrega un nuevo jugador a el equipo


asignado.
if tfm.get.room.playerList[player] then
if inTeam(player) then
teams[playerIn].players[index] = false
end
team.players[team.countPlayers] = player
team.countPlayers = team.countPlayers + 1
tfm.exec.respawnPlayer(player)
putColor(player)
else
print(player .. " no encontrado, no se añadió al equipo.")
end
end

concatTeam = function(team) -- Retorna en string a todos los jugadores de un team,


exceptuando los que sean false
local totalPlayers = ""
team.totalPlayers = 0
for _, name in next, team.players do
if name then
totalPlayers = totalPlayers .. name .. "\n"
team.totalPlayers = team.totalPlayers + 1
end
end
return totalPlayers
end

sortByAmount = function(typeAmount) -- Puede ser amount o totalAmount


local aux, countAux, playersAmount = {}, 1, ""
for name in next, playerInfo do
aux[countAux] = {name, playerInfo[name][typeAmount]}
countAux = countAux + 1
end
table.sort(aux, function(k, v) return k[2] > v[2] end)

for _, playerAmount in next, aux do


if playerAmount[2] > 0 then
inTeam(playerAmount[1])
local amount = verde .. playerAmount[2] .. "</font>"
local name = teams[playerIn].color .. playerAmount[1] .. "</font>"
playersAmount = playersAmount .. "\n" .. name .. "\t" .. amount
end
end
return playersAmount
end

mapStats = function()
local firstsPlace, playersTime, playersAmount = "", "", "<textformat
tabstops='[190]'>"
-- obtengo los primeros puestos
if primerPuesto then
inTeam(primerPuesto)
primerPuesto = teams[playerIn].color .. primerPuesto .. "</font>"
firstsPlace = firstsPlace .. verde .. "\n\n01</font> " .. primerPuesto
end
if segundoPuesto then
inTeam(segundoPuesto)
segundoPuesto = teams[playerIn].color .. segundoPuesto .. "</font>"
firstsPlace = firstsPlace .. verde .."\n02</font> " .. segundoPuesto
end
if tercerPuesto then
inTeam(tercerPuesto)
tercerPuesto = teams[playerIn].color .. tercerPuesto .. "</font>"
firstsPlace = firstsPlace .. verde .."\n03</font> " .. tercerPuesto
end
-- los tiempos totales del mapa
watchRecords("always")
playersTime = recordsString:gsub("01", "</textformat><textformat tabstops='[29,
175]'>01")
-- las cantidades de cada jugador, tiene su propia funcion
playersAmount = playersAmount .. sortByAmount("amount")

ui.addTextArea(31, "<p align='center'> <font size ='16'


color='#00C17C'><b>Estadísticas", nil, 20, 137, 760, 220, 0x1E1E1E, 0x121212,
1, true)
ui.addTextArea(32, "<p align='center'><font size ='15'
color='#00C17C'><b>Primeros Puestos</b></font>" .. firstsPlace, nil, 35, 170, 230,
170, 0x2B2B2B, 0x2B2B2B, 1, true)
ui.addTextArea(33, "<p align='center'><font size ='15'
color='#00C17C'><b>Cantidades</b></font></p>" .. playersAmount, nil, 285, 170, 230,
170, 0x2B2B2B, 0x2B2B2B, 1, true)
ui.addTextArea(34, "<p align='center'><font size ='15'
color='#00C17C'><b>Tiempos</b></font></p>" .. playersTime, nil, 535, 170, 230,
170, 0x2B2B2B, 0x2B2B2B, 1, true)
end

scoreTimes = function()
for i, time in ipairs(times) do -- recorro toda la tabla times
if i == 1 then
addPoints(time.name, 5)
bestTimes[countBestTimes] = {name = time.name, time = time.time, map =
time.map}
countBestTimes = countBestTimes + 1
elseif i == 2 then
addPoints(time.name, 4)
elseif i == 3 then
addPoints(time.name, 3)
else
return
end
end
end

finalStats = function()
-- equipo ganador --
local teamWinner, totalTimes, totalAmounts = "", "\n<textformat tabstops='[72,
300]'>", "\n<textformat tabstops='[29, 325]'>"
if teams.team1.points > teams.team2.points then
teamWinner = "<font color = '#CB546B'>Team Red Wins</font>"
elseif teams.team1.points < teams.team2.points then
teamWinner = "<font color = '#2F7FCC'>Team Blue Wins</font>"
else
teamWinner = "<font color='#00C17C'>Empate jajaencerio</font>"
end
-- fin equipo ganador
-- mejores tiempos
for i, time in ipairs(bestTimes) do -- recorro toda la tabla times
if i < 10 then i = 0 .. i end -- le agrego el 0 al inicio para que se vea
01, 02, 03 etc los 9 primeros end
inTeam(time.name)
name = teams[playerIn].color .. time.name .. "</font>"
totalTimes = totalTimes .. verde .. "@" .. time.map .. " \t" .. name .. "\t
" .. verde .. time.time .. "s\n</font>" -- almaceno todos los times en un string
end
totalTimes = totalTimes .. "</textformat>"
--fin mejores tiempos

-- mejor jugador
local scoreTop = -1
local mvpPlayer = ""
for name in pairs(playerInfo) do
if playerInfo[name].scorePoints > scoreTop then
scoreTop = playerInfo[name].scorePoints
mvpPlayer = name
end
end
inTeam(mvpPlayer)
mvpPlayer = teams[playerIn].color .. mvpPlayer .. "</font>"
-- fin mejor jugador
-- cantidades

totalAmounts = totalAmounts .. sortByAmount("totalAmount")


-- fin cantidades
texto = "<textformat tabstops='[310, 550]'><p align='left'>" .. mvpPlayer .. "
MVP\t" .. teamWinner .. "\t<font color='#CB546B'><b>Red: " .. teams.team1.points ..
"<font color='#2F7FCC'> Blue: " .. teams.team2.points

ui.addTextArea(60, "<p align='center'><font size ='16'


color='#00C17C'><b>Estadísticas Finales\n\n\n\n\n\n\n\n\n\n\n\n" .. texto, nil, 20,
127, 760, 260, 0x1E1E1E, 0x121212, 1, true)
ui.addTextArea(61, "<p align='center'><font size ='15'
color='#00C17C'><b>Cantidades Totales</b></font></p>" .. totalAmounts, nil, 35,
160, 350, 170, 0x2B2B2B, 0x2B2B2B, 1, true)
ui.addTextArea(62, "<p align='center'><font size ='15'
color='#00C17C'><b>Mejores Tiempos</b></font></p>" .. totalTimes, nil, 415, 160,
350, 170, 0x2B2B2B, 0x2B2B2B, 1, true)

end

newMap = function() -- Empieza un nuevo mapa.


if mapsPlayed == mapsToPlay then -- JUEGO TERMINADO!
putAmount()
inGame = false
print("Juego terminado!")
removeText(31, 34, nil)
finalStats()
tfm.exec.newGame(7692636)
else
if mapBc then -- Verifica si tiene que cargar un nuevo mapa de bootcamp
local map = maps[math.random(2)] -- Acordarse de cambiar el #map por el
número total de mapas
tfm.exec.newGame(map)
mapBc = false
main()
removeText(31, 34, nil)
tfm.exec.setGameTime(mapTime)

else -- Si no, es porque es el fin de un mapa de bootcamp.


tfm.exec.newGame(7692636)
scoreTimes()
mapBc = true
mapsPlayed = mapsPlayed + 1 -- Al final del mapa en lobby, se suma +1
los mapas jugados
mapStats()
--------- TextAre de Botón
for name in next, admins do
ui.addTextArea(8, "", name, 770, 35, 20, 20, 0x2B2B2B, 0x121212, 1,
true)
ui.addTextArea(9, "<V><a href='event:nextMap'><font
size='18'><b>»",
name, 771, 32, 40, 20, 0, 0, 1, true)
end
-------------
tfm.exec.setGameTime(99999)
end
end
end

updateMapName = function()
local space = "\t<font color='#6A7495'>|\t"
local text = ""
if mapBc then
text = "By Blood#3565 and Misterthepro" .. space ..
"<font color='#CB546B'>Red: " .. teams.team1.points .. space ..
"<font color='#2F7FCC'> Blue: ".. teams.team2.points .. space ..
"<J>Quedan " .. mapsToPlay - mapsPlayed .. " mapas."
else
local bestTime = "None"
if countTimes > 1 then
bestTime = times[1].name .. " " .. times[1].time .. "s"
end
text = "@" .. actualMap .. space ..
"<font color='#CB546B'>Red: " .. teams.team1.points .. space ..
"<font color='#2F7FCC'> Blue: ".. teams.team2.points .. space ..
"<J>" .. bestTime
end
tfm.exec.setUIMapName(text)
end

watchRecords = function(name)
if watchingRecords[name] then -- Si no está abierto la lista de records, la
abro actualizando los records.
recordsString = "\n<textformat tabstops='[29, 205]'>"
for i, time in ipairs(times) do -- recorro toda la tabla times
if i > 14 then break end
if i < 10 then
i = 0 .. i -- le agrego el 0 al inicio para que se vea 01, 02, 03
etc los 9 primeros
end
if #recordsString < 1850 then
inTeam(time.name)
local playerName = teams[playerIn].color .. time.name .. "</font>"
recordsString = recordsString .. verde .. i .. " \t" ..
playerName .. "\t " .. verde .. time.time .. "s\n</font>" -- almaceno todos los
times en un string
end
end
ui.addTextArea(20, "", name, 275, 80, 250, 200, 0x2B2B2B, 0x121212, 1, true)
-- textArea de fondo gris
ui.addTextArea(21, recordsString, name, 275, 80, 0, 0, 0, 0, 1, true) --
tiempos totales
ui.addTextArea(22, "<p align='center'><font size ='13'
color='#00C17C'><b>Tiempos", name, 352, 65, 100, 20, 0x2B2B2B, 0x121212, 1, true)
else -- Si está abierta, entonces la cierro
removeText(20, 22, name)
end
end

nextMap = function()
removeText(8, 9, nil)
if mapsPlayed == mapsToPlay then -- JUEGO TERMINADO!
infoText = "Enfrentamiento terminado"
end
ui.addTextArea(10, infoText, nil, 283, 23, 0, 25, 0x2B2B2B, 0x121212, 0.7,
true)
tfm.exec.setGameTime(5)
end

fillTeams = function ()
teams.team1.players = {}
teams.team2.players = {}
local intTeam, countPlayers = 1, 0
local playersWithoutTeam = {}
-- añado a todos los jugadores al mismo array
for name, p in pairs(tfm.get.room.playerList) do
countPlayers = countPlayers + 1
playersWithoutTeam[countPlayers] = name
end

for i = 1, countPlayers do
local numJugador = math.random(countPlayers)
local playerToAdd = playersWithoutTeam[numJugador]
table.remove(playersWithoutTeam, numJugador) -- D:
if intTeam == 1 then
addPlayerTeam(teams.team1, playerToAdd)
intTeam = 2
elseif intTeam == 2 then
addPlayerTeam(teams.team2, playerToAdd)
intTeam = 1
end
countPlayers = countPlayers - 1
end
updateTexts()
end

local macro_time = 2000 -- time to reset


local macro_warn = 22 -- sends a warning to the admins
local macro_freeze = 30 -- freezes them
local macro_keys = { -- keys that antimacro detects
[38] = "Up",
[87] = "W",
[90] = "Z"
}
local macro_info = {}
local concatenation = {}

updateTexts = function()
if not inGame then
ui.updateTextArea(2, "<p align='center'><font size='15'
color='#CB546B'><b>Team 1</font><font size='12'><N>\n\n" ..
concatTeam(teams.team1), nil)
ui.updateTextArea(3, "<p align='center'><font size='15'
color='#2F7FCC'><b>Team 2</font><font size='12'><N>\n\n" ..
concatTeam(teams.team2), nil)
ui.addTextArea(4, "<p align='center'><font size
='15'><b>Configuración</b></font><font size='12'>"
.. verde .. "\n\nAdministrador: </font>" .. morado .. admin .. "</font>"
.. "\n" .. verde .. "Mapas por jugar: </font>" .. morado .. mapsToPlay
.. "\n" .. verde .. "Tiempo por mapa: </font>" .. morado .. mapTime .. "s
(" .. math.floor(mapTime / 60) .. " minutos)"
.. "\n" .. verde .. "Jugadores: </font>" .. morado ..
teams.team1.totalPlayers .. "vs" .. teams.team2.totalPlayers
.. "\n" .. verde .. "AutoJoin: </font>" .. morado .. "<a
href='event:autojoin'>" .. autoJoin .. "</a>"
.. "\n\n" .. verde .. "<b><a href='event:fillTeams'>Llenar
Equipos</font></a></b>"
.. verde .. "\n\n\n<b><font size='14'><p align='center'><a
href='event:startGame'>Empezar</a>", nil, 285, 170, 230, 190, 0x2B2B2B, 0x2B2B2B,
1, true)
end
end

--removeStats = function()

--end

-- Eventos de tfm

eventKeyboard = function(player, key)


if key == 76 then
if watchingRecords[player] then
watchingRecords[player] = false
watchRecords(player)
else
watchingRecords[player] = true
watchRecords(player)
end
elseif key == 46 or key == 17 then
tfm.exec.killPlayer(player)
end -- End if key Principal
if not macro_keys[key] then return end -- solo sigue si la tecla fue UP, W o Z
-- By tocutoeltocu
local info = macro_info[player][key]
local now = os_time()

info[1] = info[1] + 1

if now >= info[2] then


if info[4] then
local count = 3
concatenation[1] = "<r>[AntiMacro] <bv>"
concatenation[2] = player
concatenation[3] = "<bl> fue congelado por usar trampas!"
local data
for _key, name in next, macro_keys do
data = macro_info[player][_key]
count = count + 4
concatenation[count - 3] = " "
concatenation[count - 2] = name
concatenation[count - 1] = ": "
if now >= data[2] and info ~= data then
concatenation[count] = "0"
else
concatenation[count] = data[1]
end
end
local msg = table.concat(concatenation, "", 1, count)
--tfm.exec.chatMessage(msg)
print(msg)
tfm.exec.freezePlayer(player)
end
info[1] = 1
info[2] = now + macro_time
info[3] = false
info[4] = false
return
elseif not info[3] and info[1] >= macro_warn then
info[3] = true
local count = 3
concatenation[1] = "<j>[AntiMacro] <bv>"
concatenation[2] = player
concatenation[3] = "<bl> puede estar usando macros."
local data
for _key, name in next, macro_keys do
data = macro_info[player][_key]
count = count + 4
concatenation[count - 3] = " "
concatenation[count - 2] = name
concatenation[count - 1] = ": "
if now >= data[2] then
concatenation[count] = "0"
else
concatenation[count] = data[1]
end
end
local msg = table.concat(concatenation, "", 1, count)
print(msg)
elseif not info[4] and info[1] >= macro_freeze then
info[4] = true
end
end

eventNewPlayer = function(name)
tfm.exec.setPlayerScore(name, 0)
updateMapName()
if not playerInfo[name] then
playerInfo[name] = {totalAmount = 0, amount = 0, alreadyRespawn = false,
scorePoints = 0}
else
tfm.exec.setPlayerScore(name, playerInfo[name].scorePoints)
end
keys(name)
if not inGame then
startGui(name)
else
if autoJoin == "ON" and (not inTeam(name)) then
concatTeam(teams.team1)
concatTeam(teams.team2)
if teams.team1.totalPlayers <= teams.team2.totalPlayers then
addPlayerTeam(teams.team1, name)
else
addPlayerTeam(teams.team2, name)
end
end
end
local info = {}
for key in next, macro_keys do
info[key] = {0, os_time() + macro_time, false, false}
system.bindKeyboard(name, key, true, true)
end
macro_info[name] = info
end

eventChatCommand = function(name, cmd)


if admins[name] then
local args, count = {}, 1
-- Lo que hace lo siguiente, es que por cada espacio (" ") que tengas en el
comando que hayas escrito, lo separa y lo guarda todo en el array args.
-- por ejemplo, por el comando:
-- !add team1 Blood#3565
-- Lo separaria en:
---------------------------
-- [add][team1][blood#3565]
-- 1 2 3
-----------------------------
for arg in cmd:gmatch("[^%s]+") do
args[count] = arg
count = count + 1
end
if args[1] == "team1" or args[1] == "team2" then -- Agrega un jugador a
algún team
teams[args[1]].players = {}
teams[args[1]].countPlayers = 1
for i = 2, count - 1 do addPlayerTeam(teams[args[1]], args[i]) end
updateTexts()
elseif args[1] == "add" then
if args[2] == "team1" or args[2] == "team2" then
for i = 3, count - 1 do
addPlayerTeam(teams[args[2]], args[i])
end
end
updateTexts()
elseif args[1] == "next" or args[1] == "n" then
if mapBc then
nextMap()
end
elseif args[1] == "skip" then
if not mapBc then
--if countTimes > 1 then
-- removeStats()
--end
mapBc = true
newMap()
end
elseif args[1] == "addtime" then
local timeForMap = tonumber(args[2])
restante = restante / 1000
if timeForMap ~= nil then
tfm.exec.setGameTime(restante + timeForMap)
end
elseif args[1] == "admin" and args[2] ~= nil then
admins[args[2]] = true
elseif args[1] == "unadmin" and args[2] ~= nil and args[2] ~= admin then
admins[args[2]] = false
elseif args[1] == "timemap" or args[1] == "maptime" or args[1] == "tm" or
args[1] == "mt" then
local timeForMap = tonumber(args[2])
if timeForMap ~= nil then
mapTime = timeForMap
if not inGame then
ui.addTextArea(4, "<p align='center'><font size
='15'><b>Configuración</b></font><font size='12'>"
.. verde .. "\n\nAdministrador: </font>" .. morado .. admin ..
"</font>"
.. "\n" .. verde .. "Mapas por jugar: </font>" .. morado ..
mapsToPlay
.. "\n" .. verde .. "Tiempo por mapa: </font>" .. morado ..
mapTime .. "s (" .. math.floor(mapTime / 60) .. " minutos)"
.. "\n" .. verde .. "Jugadores: </font>" .. morado ..
teams.team1.totalPlayers .. "vs" .. teams.team2.totalPlayers
.. "\n" .. verde .. "AutoJoin: </font>" .. morado .. "<a
href='event:autojoin'>" .. autoJoin .. "</a>"
.. "\n\n" .. verde .. "<b><a href='event:fillTeams'>Llenar
Equipos</font></a></b>"
.. verde .. "\n\n\n<b><font size='14'><p align='center'><a
href='event:startGame'>Empezar</a>", nil, 285, 170, 230, 190, 0x2B2B2B, 0x2B2B2B,
1, true)
end
else
print("Número invalido. No se pudo cambiar el tiempo de cada
mapa.")
end
elseif args[1] == "maps" or args[1] == "mapas" or args[1] == "m" then
local mapsPlay = tonumber(args[2])
if mapsPlay ~= nil then
mapsToPlay = mapsPlay
if not inGame then
updateMapName()
ui.addTextArea(4, "<p align='center'><font size
='15'><b>Configuración</b></font><font size='12'>"
.. verde .. "\n\nAdministrador: </font>" .. morado .. admin ..
"</font>"
.. "\n" .. verde .. "Mapas por jugar: </font>" .. morado ..
mapsToPlay
.. "\n" .. verde .. "Tiempo por mapa: </font>" .. morado ..
mapTime .. "s (" .. math.floor(mapTime / 60) .. " minutos)"
.. "\n" .. verde .. "Jugadores: </font>" .. morado ..
teams.team1.totalPlayers .. "vs" .. teams.team2.totalPlayers
.. "\n" .. verde .. "AutoJoin: </font>" .. morado .. "<a
href='event:autojoin'>" .. autoJoin .. "</a>"
.. "\n\n" .. verde .. "<b><a href='event:fillTeams'>Llenar
Equipos</font></a></b>"
.. verde .. "\n\n\n<b><font size='14'><p align='center'><a
href='event:startGame'>Empezar</a>", nil, 285, 170, 230, 190, 0x2B2B2B, 0x2B2B2B,
1, true)
end
else
print("Número invalido. No se pudo cambiar los mapas totales.")
end
end -- End IF principal sobre comandos de administrador
end -- end if admins
if cmd == "records" then
if watchingRecords[name] then
watchingRecords[name] = false
watchRecords(name)
else
watchingRecords[name] = true
watchRecords(name)
end
end
end

eventLoop = function(currentTime, remaining)


restante = remaining
for name, time in next, toRespawn do -- Respawnea a cualquier jugador que haya
muerto o ganado con 1s de descanso.
if time <= os_time() - 1000 then tfm.exec.respawnPlayer(name)
putColor(name) end
end
if (remaining < 500 and inGame) then newMap() end
end

eventPlayerDied = function(name) -- Lo respawneo si está en un equipo


if inTeam(name) then
toRespawn[name] = os_time()
playerInfo[name].alreadyRespawn = true
end
end

eventNewGame = function() -- Mato a todas las personas que no estén en un equipo


if inGame then
for name in pairs(tfm.get.room.playerList) do
putColor(name)
if (autoJoin == "OFF") and (not inTeam(name)) then
tfm.exec.killPlayer(name)
else
if not inTeam(name) then
concatTeam(teams.team1)
concatTeam(teams.team2)
if teams.team1.totalPlayers <= teams.team2.totalPlayers then
addPlayerTeam(teams.team1, name)
else
addPlayerTeam(teams.team2, name)
end
end
end
end
end
if inGame then actualMap = tfm.get.room.xmlMapInfo.mapCode end
ui.removeTextArea(10, nil)
updateMapName()
end

eventTextAreaCallback = function (id, name, callback)


if not admins[name] then return end -- Si cualquiera que haga click no es
admin, no hace nada

if callback == "startGame" then


inGame = true
removeText(1, 4, nil) -- Se remueven los textareas del inicio
newMap()
elseif callback == "nextMap" then
nextMap()
elseif callback == "fillTeams" then
fillTeams()
elseif callback == "autojoin" then
if autoJoin == "ON" then
autoJoin = "OFF"
else
autoJoin = "ON"
end
ui.addTextArea(4, "<p align='center'><font size
='15'><b>Configuración</b></font><font size='12'>"
.. verde .. "\n\nAdministrador: </font>" .. morado .. admin .. "</font>"
.. "\n" .. verde .. "Mapas por jugar: </font>" .. morado .. mapsToPlay
.. "\n" .. verde .. "Tiempo por mapa: </font>" .. morado .. mapTime .. "s
(" .. math.floor(mapTime / 60) .. " minutos)"
.. "\n" .. verde .. "Jugadores: </font>" .. morado ..
teams.team1.totalPlayers .. "vs" .. teams.team2.totalPlayers
.. "\n" .. verde .. "AutoJoin: </font>" .. morado .. "<a
href='event:autojoin'>" .. autoJoin .. "</a>"
.. "\n\n" .. verde .. "<b><a href='event:fillTeams'>Llenar
Equipos</font></a></b>"
.. verde .. "\n\n\n<b><font size='14'><p align='center'><a
href='event:startGame'>Empezar</a>", name, 285, 170, 230, 190, 0x2B2B2B, 0x2B2B2B,
1, true)

end
end

eventPlayerWon = function(player, timeElapsed, timeRespawn)


-- consigo el team del jugador
local completedIn = timeRespawn / 100
-- dependiendo del puesto en el que llegó, le doy puntos a él y a su equipo
if not primerPuesto then
primerPuesto = player
addPoints(player, 5)
elseif not segundoPuesto then
segundoPuesto = player
addPoints(player, 4)
elseif not tercerPuesto then
tercerPuesto = player
addPoints(player, 3)
else
addPoints(player, 2)
end
-- le aumento en 1 sus cantidades
playerInfo[player].amount = playerInfo[player].amount + 1
toRespawn[player] = os_time()
if not playerInfo[player].alreadyRespawn then
completedIn = completedIn - 3
playerInfo[player].alreadyRespawn = true
end
-- Almaceno el time en la variable que tiene todos los tiempos del mapa:
times[countTimes] = {time = completedIn, name = player, map = actualMap}
countTimes = countTimes + 1
-- Ordeno los tiempos:
table.sort(times, function(i, v) return i.time < v.time end)
--
for name in next, watchingRecords do
watchRecords(name)
end
updateMapName()
end
startGui = function(name) -- interfaz gráfica inicial
ui.addTextArea(1, "<p align='center'> <font size ='16'
color='#00C17C'><b>Información Inicial", name, 20, 137, 760, 240, 0x1E1E1E,
0x121212,
1, true)
ui.addTextArea (2, "<p align='center'><font size='15' color='#CB546B'><b>Team
1</font><font size='12'><N>\n\n" .. concatTeam(teams.team1), name, 35, 170, 230,
190, 0x2B2B2B, 0x2B2B2B, 1, true)
ui.addTextArea(3, "<p align='center'><font size='15' color='#2F7FCC'><b>Team
2</font><font size='12'><N>\n\n" .. concatTeam(teams.team2), name, 535, 170, 230,
190, 0x2B2B2B, 0x2B2B2B, 1, true)
ui.addTextArea(4, "<p align='center'><font size
='15'><b>Configuración</b></font><font size='12'>"
.. verde .. "\n\nAdministrador: </font>" .. morado .. admin .. "</font>"
.. "\n" .. verde .. "Mapas por jugar: </font>" .. morado .. mapsToPlay
.. "\n" .. verde .. "Tiempo por mapa: </font>" .. morado .. mapTime .. "s (" ..
math.floor(mapTime / 60) .. " minutos)"
.. "\n" .. verde .. "Jugadores: </font>" .. morado .. teams.team1.totalPlayers ..
"vs" .. teams.team2.totalPlayers
.. "\n" .. verde .. "AutoJoin: </font>" .. morado .. "<a
href='event:autojoin'>" .. autoJoin .. "</a>"
.. "\n\n" .. verde .. "<b><a href='event:fillTeams'>Llenar Equipos</font></a></b>"
.. verde .. "\n\n\n<b><font size='14'><p align='center'><a
href='event:startGame'>Empezar</a>", name, 285, 170, 230, 190, 0x2B2B2B, 0x2B2B2B,
1, true)
end

for name in pairs(tfm.get.room.playerList) do eventNewPlayer(name) end

tfm.exec.newGame(7692636)

También podría gustarte