Hey there! I run a TDM Conquest Server, and I'm running into a few problems here and there, I'm very limited in time and investments into coding currently (70 hr/w Job / Family and Kids).
One of the problems that I have right now is that currently we have two(2)teams, and when one team is losing, people from that team will switch to the other team (winning team)to avoid the loss.
I know there's probably add-ons or things that can combat this, but currently our developer is working on bigger issues at the moment, so I've come here for some helpful advice / help!
What I want to happen is that when someone switches from one team to another after 3 minutes have passed to be forced into spectator for (x) amount of time (Configurable), and the punishment to gradually increase for insert.player.
A few pieces of information.
It's a custom-coded game mode, Each (Match) has a 30 minute timer, unless it's Conquest where as we use a (Ticket reducing) system to concur who the winner is.
We do use ULX, and I'm hoping that we can integrate something from ULX to combat our issues above.
I'm unsure of what other information is pertinent for this, so if you do need any other information, please let me know below!
I do have several ways of communication, so please let me know your preferred method!
We've already a system in place to auto-balance each team as seen below:
SetGlobalInt( "Unbalanced", 0 )
local teamPrevent = 0
hook.Add( "Think", "TeamBalance", function()
if CurTime() > teamPrevent then
teamPrevent = CurTime() + 4
local amtB = #team.GetPlayers( 2 )
local amtR = #team.GetPlayers( 1 )
if amtB - amtR >= 3 then
if GetGlobalInt( "Unbalanced" ) ~= 2 then
SetGlobalInt( "Unbalanced", 2 )
end
elseif amtR - amtB >= 3 then
if GetGlobalInt( "Unbalanced" ) ~= 1 then
SetGlobalInt( "Unbalanced", 1 )
end
elseif amtB - amtR < 3 and amtR - amtB < 3 then
if GetGlobalInt( "Unbalanced" ) ~= 0 then
SetGlobalInt( "Unbalanced", 0 )
end
end
end
end )
function team.GetSortedPlayers( tea )
local tab = team.GetPlayers( tea )
table.sort( tab, function( a, b ) return a:Frags() > b:Frags() end )
return tab
end
timer.Create( "TeamBalance", 30, 0, function()
if GetGlobalInt( "Unbalanced" ) > 0 then
local more
local less
if GetGlobalInt( "Unbalanced" ) == 1 then
more = 1
less = 2
elseif GetGlobalInt( "Unbalanced" ) == 2 then
more = 2
less = 1
end
local tmore = team.GetSortedPlayers( more )
local tless = team.GetSortedPlayers( less )
local diff = math.floor( ( #tmore - #tless ) / 2 )
local temp = {}
for i = 1, diff do
local ply = tmore[ #tmore - ( i - 1 ) ]
ply:ConCommand( "tdm_setteam " .. less )
table.insert( temp, ply:Nick() )
end
local exp = table.concat( temp, ", " )
ULib.tsayColor( nil, false, Color( 255, 255, 255 ), "Player(s) " .. exp .. " moved for team balance." )
end
end )