0% found this document useful (0 votes)
15 views12 pages

Lua Mix

This document outlines the commands and setup for an admin panel for a multiplayer game. It defines admin users, game settings like score to win and time limits, and commands for team management, starting the game, and changing settings. Functions are included for game logic like scoring and new rounds.

Uploaded by

gustvic1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views12 pages

Lua Mix

This document outlines the commands and setup for an admin panel for a multiplayer game. It defines admin users, game settings like score to win and time limits, and commands for team management, starting the game, and changing settings. Functions are included for game logic like scoring and new rounds.

Uploaded by

gustvic1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 12

--[[

CMDS:
1. !team1 "playername" "playername" \\Assign players to team1 , ex: !team1
Ctmce Ziggy_z
2. !team2 "playername "playername" \\Assign players to team2 , ex: !team2
Ctmce Ziggy_z
3. !add team1 "playername" "playername" \\Adds the player team1.
4. !add team2 "playername" "playername" \\Adds the player team2.
5. !remove team1 "playername" "playername" \\Removes the player/'s from team1!
6. !remove team2 "playername" "playername" \\Removes the player/'s from team2!
7. !exit \\Closing the Admin Panel//
8. !start \\Shows the Admin Panel back//
9. !sp team1 23 \\Sets the points for team1 to 23 or whatever you choose!
10. !sp team2 15 \\Sets the points for team1 to 15 or whatever you choose!
11. !aj on / off \\Turns AutoJoin On and Off.
12. !pause //the game will be paused until you put !pause again => it has been
not implemented yet
--]]

--Admin/Game Setup--
local admin = {"Vesgv#0000","MelaSudan#6969"} -- only the first position of the
array will be shown in the gui
local ScoreToWin = 20 --Type here the amount of points need to win the game(Leave
it at the same number it is right now if you want to change it in the Setup
Panel)--
local autoJoin = true
local team1Color = "Blue"
local team2Color = "Red"
local mod = "Bootcamp"

--^^^^^^^^^^^^^^^^^^^CHANGE ONLY THE THINGS ABOVE^^^^^^^^^^^^^^^^^^^--


--------------

--DO NOT CHANGE THE SCRIPT!--


local teams = {Team1 = {}, Team2 = {}}
--Team score--
local teamScore = {Team1 = 0, Team2 = 0}
--------------
local teamColors = {Blue = '2F7FCC', Red = 'CB546B'}
local first = false
---Game Time Settings----
local gameTime = {Minutes = 1,Seconds = 2}
local Ticker = 0
----Variable for mix game---------------------
local mix_v = true
----array for maps already played------------------------
local already_maps = {}
local b_c = true
-----------------------------
local gameStarted = false
currentMap = 0
team1C = team1Color
team2C = team2Color

function main()
tfm.exec.disableAllShamanSkills(true)
tfm.exec.disableAutoNewGame(true)
tfm.exec.disableAutoShaman(true)
tfm.exec.disableAutoScore(true)
tfm.exec.disableAutoTimeLeft(true)
tfm.exec.disableDebugCommand(true)
tfm.exec.disablePhysicalConsumables(true)
checkColor()
ShowStartBoard()
end

function establecerEquipos()
teams.Team1 = {}
teams.Team2 = {}
local equipo = 1
local jugadoresTotal = {}

for name, p in pairs(tfm.get.room.playerList) do


table.insert(jugadoresTotal, name)
end

for i = 1, #jugadoresTotal do
numJugador = math.random(#jugadoresTotal)
agregarJugador = jugadoresTotal[numJugador]
table.remove(jugadoresTotal, numJugador)
if equipo == 1 then
table.insert(teams.Team1, agregarJugador)
equipo = 2
elseif equipo == 2 then
table.insert(teams.Team2, agregarJugador)
equipo = 1
end
end

ui.addTextArea(3, "<p align='center'><font color='#CB546B'>" ..


(table.concat(teams.Team1,"\n") or ""), nil, 15, 72, 180, 266, 0x2B2B2B, 0x121212,
1, true)
ui.addTextArea(4, "<p align='center'><font color='#2F7FCC'>" ..
(table.concat(teams.Team2,"\n") or ""), nil, 605, 72, 180, 266, 0x2B2B2B, 0x121212,
1, true)
end

function eventNewGame()
if gameStarted then
currentMap = tostring(tfm.get.room.currentMap)
setTimeMode()
for n,p in pairs(tfm.get.room.playerList) do
if not PlayerInTeam(n) then
tfm.exec.killPlayer(n)
end
end
SetPlayerNameColor()
first = false
if mod == "Bootcamp" then
tfm.exec.setUIMapName(currentMap .."
<font color='#"..team1Color .."'>" ..team1C ..": ".. teamScore.Team1 .."</font> /
<font color='#"..team2Color .."'>" ..team2C ..": "..teamScore.Team2.."</font> /
<n>D:" ..ScoreToWin .."</n> Time left: 0" ..
gameTime.Minutes ..":" ..gameTime.Seconds .."\n")
elseif mod =="Racing" then
tfm.exec.setUIMapName(currentMap .."
<font color='#"..team1Color .."'>" ..team1C ..": ".. teamScore.Team1 .."</font> /
<font color='#" ..team2Color .."'>" ..team2C ..": "..teamScore.Team2 .."</font> /
<n>D:"..ScoreToWin .."</n> Time left: 0" .. gameTime.Minutes
..":0" ..gameTime.Seconds .."\n")
elseif mod =="Mix" then
tfm.exec.setUIMapName(currentMap .."
<font color='#"..team1Color .."'>" ..team1C ..": ".. teamScore.Team1 .."</font> /
<font color='#" ..team2Color .."'>" ..team2C ..": "..teamScore.Team2 .."</font> /
<n>D:"..ScoreToWin .."</n> Time left: 0" .. gameTime.Minutes
..":0" ..gameTime.Seconds .."\n")
end
end
end

function eventNewPlayer(plr)
if gameStarted then
if PlayerInTeam(plr) then tfm.exec.killPlayer(plr) return end
if autoJoin then
if #teams.Team1 == #teams.Team2 then
table.insert(teams.Team1,plr)
elseif #teams.Team1 > #teams.Team2 then
table.insert(teams.Team2,plr)
end
end
end
end

function eventPlayerDied(plr)
if gameStarted then
local plrCount = 0
for n,p in pairs(tfm.get.room.playerList) do
if not p.isDead then
plrCount = plrCount + 1
end
end
if plrCount <= 0 then
newMap()
print("WTF3")
end
end
end

function eventPlayerWon(plr, TT, wonTime)


if gameStarted then
if PlayerInTeam(plr) then
if not first then
if table.contain(teams.Team1,plr) then
first = true
teamScore.Team1 = teamScore.Team1 + 1
tfm.exec.setPlayerScore(plr, 1,true)
gameTime.Minutes = 0
gameTime.Seconds = 3
if tonumber(teamScore.Team1) >= tonumber(ScoreToWin) then
print("Team 1 won the game! The last point made by: "..plr)
gameStarted = false
tfm.exec.newGame(7692692,true)
ShowStartBoard()
ui.addTextArea(16, "<font size='13'
color='#ffffff'><i>Team</font><font color='#" ..team1Color .."'> " ..team1C
.."</font> won the game!</font></font>", nil, 8, 166, 202, 60, 0x000000, 0x5eff6e,
0, true)
ui.addTextArea(17, "<font size='13' color='#ffffff'><i>The
Player:<font color='#"..team1Color .."'> "..plr .."</font> made the last point!",
nil, 602, 166, 188, 61, 0xffffff, 0x5eff6e, 0, true)
end
else
first = true
--if the plr form team2 then
teamScore.Team2 = teamScore.Team2 + 1
tfm.exec.setPlayerScore(plr, 1,true)
gameTime.Minutes = 0
gameTime.Seconds = 3
if tonumber(teamScore.Team2) >= tonumber(ScoreToWin) then
print("Team 2 won the game! The last point made by: "..plr)
gameStarted = false
tfm.exec.newGame(7692692,true)
ShowStartBoard()
ui.addTextArea(16, "<font size='13'
color='#ffffff'><i>Team</font><font color='#" ..team2Color .."'> " ..team2C
.."</font> won the game!</font></font>", nil, 8, 166, 202, 60, 0x000000, 0x5eff6e,
0, true)
ui.addTextArea(17, "<font size='13' color='#ffffff'><i>The
Player:<font color='#"..team2Color .."'> "..plr .."</font> made the last point!",
nil, 602, 166, 188, 61, 0xffffff, 0x5eff6e, 0, true)
end
end
end
end
end
end

if_admin = function (name)


for p = 1, #admin do
if name == admin[p] then
return true
end
end
return false
end

function eventTextAreaCallback(id, player, callback)


if if_admin(player) then
if id == 8 then
if callback == "bc" then
mod = "Bootcamp"
ShowStartBoard()
end
elseif id == 9 then
if callback == "rc" then
mod = "Racing"
ShowStartBoard()
end
elseif id == 18 then
if callback == "mix" then
mod = "Mix"
ShowStartBoard()
end
elseif id == 10 then
if callback == "start" then
math.randomseed(os.time())
for i=0, 18,1 do
ui.removeTextArea(i)
end
gameStarted = true
teamScore.Team1 = 0
teamScore.Team2 = 0
resetScore()
newMap()
end
elseif id == 11 then
if callback == "dec" then
if tonumber(ScoreToWin) > 1 then
ScoreToWin = ScoreToWin - 1
ShowStartBoard()
end
elseif callback == "inc" then
if tonumber(ScoreToWin) < 99 then
ScoreToWin = ScoreToWin + 1
ShowStartBoard()
end
end
elseif id == 12 then
if callback == "OnAndOff" then
autoJoin = not autoJoin
ShowStartBoard()
end
elseif id == 15 then
if callback == "Fill" then
establecerEquipos()
ShowStartBoard()
end
end
end
end

function eventChatCommand(name, command)


if if_admin(name) then
local arg={}
for argument in command:gmatch("[^%s]+") do
table.insert(arg,argument)
end
if arg[1]:lower() == "team1" and arg[2] ~= nil then
teams.Team1 = {}
for i,v in pairs(arg) do
if i > 1 then
if PlayerCheck(v) then
if TeamFix(v) == "team2"then
table.clear(teams.Team2,v)
table.insert(teams.Team1,v)
if not gameStarted then
ShowStartBoard()
end
else
table.insert(teams.Team1,v)
if not gameStarted then
ShowStartBoard()
end
end
else
print("Sory couldn't found: " .. tostring(v))
end
end
end
elseif arg[1]:lower() == "team2" and arg[2] ~= nil then
teams.Team2 = {}
for i,v in pairs(arg) do
if i > 1 then
if PlayerCheck(v) then
if TeamFix(v) == "team1"then
table.clear(teams.Team1,v)
table.insert(teams.Team2,v)
if not gameStarted then
ShowStartBoard()
end
else
table.insert(teams.Team2,v)
if not gameStarted then
ShowStartBoard()
end
end
else
print("Sory couldn't found: " .. tostring(v))
end
end
end
elseif arg[1]:lower() == "add" and arg[2]:lower() == "team1" and arg[3] ~=
nil then
for i,v in pairs(arg) do
if i > 1 then
if PlayerCheck(v) then
if TeamFix(v) == "team2"then
table.clear(teams.Team2,v)
table.insert(teams.Team1,v)
if not gameStarted then
ShowStartBoard()
end
else
table.insert(teams.Team1,v)
if not gameStarted then
ShowStartBoard()
end
end
end
end
end
elseif arg[1]:lower() == "add" and arg[2]:lower() == "team2" and arg[3] ~=
nil then
for i,v in pairs(arg) do
if i > 1 then
if PlayerCheck(v) then
if TeamFix(v) == "team1"then
table.clear(teams.Team1,v)
table.insert(teams.Team2,v)
if not gameStarted then
ShowStartBoard()
end
else
table.insert(teams.Team2,v)
if not gameStarted then
ShowStartBoard()
end
end
end
end
end
elseif arg[1] == "remove" and arg[2] == "team1" and arg[3] ~= nil then
if TeamFix(arg[3]) == "team1" then
if not gameStarted then
table.clear(teams.Team1,arg[3])
ShowStartBoard()
else
table.clear(teams.Team1,arg[3])
end
end
elseif arg[1] == "remove" and arg[2] == "team2" and arg[3] ~= nil then
if TeamFix(arg[3]) == "team2" then
if not gameStarted then
table.clear(teams.Team2,arg[3])
ShowStartBoard()
else
table.clear(teams.Team2,arg[3])
end
end
elseif arg[1]:lower() == "aj" and arg[2]:lower() == "on" and arg[3] == nil
then
autoJoin = true
elseif arg[1]:lower() == "aj" and arg[2]:lower() == "off" and arg[3] == nil
then
autoJoin = false
elseif arg[1]:lower() == "start" then
if not gameStarted then
ShowStartBoard()
end
elseif arg[1]:lower() == "exit" and arg[2] == nil then
if not gameStarted then
for i=0,17,1 do
ui.removeTextArea(i)
end
end
elseif arg[1]:lower() == "finish" and arg[2] == "script" and arg[3] == nil
then
system.exit()
elseif arg[1]:lower() == "reset" and arg[2] == nil then
if gameStarted then
gameStarted = false
tfm.exec.newGame(7692692)
ShowStartBoard()
end
elseif arg[1]:lower() == "d" and tonumber(arg[2]) ~= nil and arg[3] == nil
then
if tonumber(arg[2]) > 0 and tonumber(arg[2]) <= 100 then
ScoreToWin = arg[2]
else
print("The limit of the WinScore is between 0-500!")
end
elseif arg[1]:lower() == "skip" and arg[2] == nil then
newMap()
elseif arg[1]:lower() == "sp" then
if arg[2]:lower() == "team1" then
if tonumber(arg[3]) ~= nil then
if tonumber(arg[3]) < tonumber(ScoreToWin) and tonumber(arg[3])
> 0 then
teamScore.Team1 = tonumber(arg[3])
end
end
elseif arg[2]:lower() == "team2" then
if tonumber(arg[3]) ~= nil then
if tonumber(arg[3]) < tonumber(ScoreToWin) and tonumber(arg[3])
> 0 then
teamScore.Team2 = tonumber(arg[3])
end
end

end
end
end
end

function eventLoop(current, left)


if gameStarted then
Ticker = Ticker + 1
if Ticker%2 == 0 then
if gameTime.Minutes <= 0 and gameTime.Seconds <= 0 then
newMap()
elseif gameTime.Seconds < 1 then
gameTime.Minutes = gameTime.Minutes - 1
gameTime.Seconds = 59
end
if gameTime.Seconds > 9 then
tfm.exec.setUIMapName(currentMap .."
<font color='#"..team1Color .."'>" ..team1C ..": ".. teamScore.Team1 .."</font> /
<font color='#"..team2Color .."'>" ..team2C ..": "..teamScore.Team2.."</font> /
<n>D:" ..ScoreToWin .."</n> Time left: 0" ..
gameTime.Minutes ..":" ..gameTime.Seconds .."\n")
elseif gameTime.Seconds < 10 then
-- tfm.exec.setUIMapName(currentMap .."| Time left: 0" ..
gameTime.Minutes ..":0".. gameTime.Seconds .." | " ..team1C ..": "..
teamScore.Team1 .."/ "..team2C ..": "..teamScore.Team2 .."\n")
tfm.exec.setUIMapName(currentMap .."
<font color='#"..team1Color .."'>" ..team1C ..": ".. teamScore.Team1 .."</font> /
<font color='#" ..team2Color .."'>" ..team2C ..": "..teamScore.Team2 .."</font> /
<n>D:"..ScoreToWin .."</n> Time left: 0" .. gameTime.Minutes
..":0" ..gameTime.Seconds .."\n")
end
gameTime.Seconds = gameTime.Seconds - 1
Ticker = 0
end
end
end

esta = function(p, L) -- L lista de jugadores --


for _, v in pairs(L) do
if p == v then
return true
end
end
return false
end

new_map = function(L)
local k = true
local r = L[math.random(#L)]
while k == true do
if esta(r, already_maps) == true then
print(r)
r = L[math.random(#L)]
else
table.insert(already_maps, r)
k = false
end
end
return r
end

function newMap()
if mod == "Bootcamp" then
if b_c == true then
tfm.exec.newGame'#13'
b_c = false
else
tfm.exec.newGame'#3'
b_c = true
end
elseif mod == "Racing" then
tfm.exec.newGame'#17'
elseif mod == "Mix" then
if mix_v == true then
if b_c == true then
tfm.exec.newGame'#13'
b_c = false
else
tfm.exec.newGame'#3'
b_c = true
end
mix_v = false
else
tfm.exec.newGame'#17'
mix_v = true
end
end
end

function SetPlayerNameColor()
checkColor()
for i,v in pairs(teams.Team1) do
tfm.exec.setNameColor(v, "0x"..team1Color)
end

for i,v in pairs(teams.Team2) do


tfm.exec.setNameColor(v, "0x"..team2Color)
end
end
function setTimeMode()
if mod == "Bootcamp" then
gameTime.Minutes = 1
gameTime.Seconds = 50
elseif mod == "Racing" then
--Game Time for Racing.--
gameTime.Minutes = 1
gameTime.Seconds = 3
elseif mod == "Mix" then
gameTime.Minutes = 1
gameTime.Seconds = 50
elseif mod == nil then
mod = "Racing"
gameTime.Minutes = 1
gameTime.Seconds = 2
end
end

function FillTeams()
local t = 1
teams.Team1 = {}
teams.Team2 = {}
for n,p in pairs(tfm.get.room.playerList) do
if t == 1 then
table.insert(teams.Team1,n)
t = 2
elseif t == 2 then
table.insert(teams.Team2,n)
t = 1
end
end
end

function checkColor()
local c = false
for key,v in pairs(teamColors) do
if key == team1Color then
team1Color = v
c = true
elseif key == team2Color then
team2Color = v
c = true
elseif team1Color == v then
c = true
elseif team2Color == v then
c = true
end
end
if c then
print("Team colors succesfully setted!")
else
team1Color = teamColors.Green
team2Color = teamColors.Blue
print("Sory couldn't found the color you choosed, Defult color will be
apllied.")
end
end

function table.clear(t,obj)
for i,v in ipairs(t) do
if v==obj then
table.remove(t,i)
end
end
end

function table.contain(t,obj)
for i,v in pairs(t) do
if v==obj then
return true
end
end
return false
end

function resetScore()
for n,p in pairs(tfm.get.room.playerList) do
tfm.exec.setPlayerScore(n, 0,false)
end
end

function TeamFix(plr)
local char = plr
for i,v in pairs(teams.Team1) do
if v == char then
return "team1"
end
end
for i,n in pairs(teams.Team2) do
if n == char then
return "team2"
end
end
return false
end

function PlayerCheck(plr)
local playerToSerch = plr
for n,p in pairs(tfm.get.room.playerList) do
if n == plr then
return true
end
end
return false
end

function PlayerInTeam(plr)
local player = plr
for i,v in pairs(teams.Team1) do
if v == player then
return true
end
end
for i,n in pairs(teams.Team2) do
if n == player then
return true
end
end
return false
end

function ShowStartBoard()
ui.addTextArea(0, "<p align='center'>Administrador: <font
color='#00ff40'><b>" .. admin[1] .. " ".. admin[2], nil, 263, 365, 265, 20,
0x324650, 0x000000, 0.8, true)
ui.addTextArea(1, "", nil, 209, 33, 381, 326, 0x324650, 0x000000, 1, true)
ui.addTextArea(2, "<p align='center'><font size='12'
color='#" ..team1Color .."'>" .. (table.concat(teams.Team1,"\n") or ""), nil, 208,
66, 151, 254, 0x324650, 0x000000, 1, true)
ui.addTextArea(3, "<p align='center'><font size='12'
color='#" ..team2Color .."'> " .. (table.concat(teams.Team2,"\n") or ""), nil, 438,
66, 151, 254, 0x324650, 0x000000, 1, true)
ui.addTextArea(4, "<p align='center'>Mod:" ..(mod or "Racing"), nil, 354, 60,
89, 19, 0x324650, 0x000000, 1, true)
ui.addTextArea(5, "<font size='12'><p align='center'><b>\\ LUA /", nil, 209,
33, 381, 21, 0x324650, 0x000000, 1, true)
ui.addTextArea(8, "<p align='center'><b><a href='event:bc'>Bootcamp</a>", nil,
365, 180, 69, 20, 0x001f3f, 0x000000, 1, true)
ui.addTextArea(9, "<p align='center'><b><a href='event:rc'>Racing</a>", nil,
365, 124, 69, 20, 0x001f3f, 0x000000, 1, true)
ui.addTextArea(18, "<p align='center'><b><a href='event:mix'>Mix</a>", nil,
365, 152, 69, 20, 0x540c0c, 0x000000, 1, true)
ui.addTextArea(10, "<p align='center'><font size='13'><b><a
href='event:start'>Start</a>", nil, 359, 236, 82, 23, 0x120D0D, 0x000000, 1, true)
ui.addTextArea(11, "<p align='center'>Score: <a href='event:dec'>-</a>
"..ScoreToWin .." <a href='event:inc'>+</a>", nil, 435, 335, 87, 20, 0x324650,
0x000000, 1, true)
ui.addTextArea(12, "<p align='center'>Auto Join: <a href='event:OnAndOff'>"..
(autoJoin and "on" or not autoJoin and "off") .."</a>", nil, 277, 335, 87, 20,
0x324650, 0x000000, 1, true)
ui.addTextArea(15, "<p align='center'><a href='event:Fill'>Fill</a>", nil, 376,
335, 47, 20, 0x324650, 0x000000, 1, true)
end
main()

You might also like