Lua Farm
Lua Farm
Lua Farm
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]
]]
--[[
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
]]
--[[
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'>"
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()
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
putColor = function(name)
if inTeam(name) then
local color = teams[playerIn].color:gsub("<font color='#", "0x"):gsub("'>",
"")
tfm.exec.setNameColor(name, color)
end
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")
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
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
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
info[1] = info[1] + 1
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
end
end
tfm.exec.newGame(7692636)