Alright, so i'm working on a test gamemode, and for some reason, this wont work:
[CODE]function ES( ply )
local ES = math.random(3, 4)
if ES == 3 then
ply:SetTeam( 3 )
end
if ES == 4 then
ply:SetTeam( 4 )
end
function SPAWN( ply )
Republic = team.NumPlayers( 3 )
Cis = team.NumPlayers( 4 )
if Republic > Cis then
ply:SetTeam( 4 )
end
if Cis > Republic then
ply:SetTeam( 3 )
end
end
end[/CODE]
Players join, and it puts them on one team, and i'm on the other, it doesn't let them spawn as my team.
-snip- silly me, page didn't load fully and I didn't see the whole code
Try this:
[CODE] local rand = math.random(1,2)
if rand == 1 then
if team.NumPlayers(3) < team.NumPlayers(4) then
ply:SetTeam(3)
end
end
if rand == 2 then
if team.NumPlayers(4) < team.NumPlayers(3) then
ply:SetTeam(4)
end
end
[/CODE]
EDIT: Forget the last part... i just noticed you are doing it when someone joins... not when a amount of players join. Just do that ^
[QUOTE=thekiller123;44715148]Alright, so i'm working on a test gamemode, and for some reason, this wont work:
[CODE]function ES( ply )
local ES = math.random(3, 4)
if ES == 3 then
ply:SetTeam( 3 )
end
if ES == 4 then
ply:SetTeam( 4 )
end
function SPAWN( ply )
Republic = team.NumPlayers( 3 )
Cis = team.NumPlayers( 4 )
if Republic > Cis then
ply:SetTeam( 4 )
end
if Cis > Republic then
ply:SetTeam( 3 )
end
end
end[/CODE]
Players join, and it puts them on one team, and i'm on the other, it doesn't let them spawn as my team.[/QUOTE]
Here's a thing you might like for checking balance:
[url]http://wiki.garrysmod.com/page/team/BestAutoJoinTeam[/url]
[QUOTE=HumbleTH;44715393]Here's a thing you might like for checking balance:
[url]http://wiki.garrysmod.com/page/team/BestAutoJoinTeam[/url][/QUOTE]
Hmm I never knew there was something like that...
[QUOTE=HumbleTH;44715393]Here's a thing you might like for checking balance:
[url]http://wiki.garrysmod.com/page/team/BestAutoJoinTeam[/url][/QUOTE]
Hmmmm so I just delete the old code and replace it with team.BestAutoJoinTeam( 3, 4 )
?
Just wanted to point out that in the original code you had
[CODE]
local ES = math.random(3, 4)
if ES == 3 then
ply:SetTeam( 3 )
end
if ES == 4 then
ply:SetTeam( 4 )
end
[/CODE]
which could easily be changed to
[CODE]
local ES = math.random(3, 4)
ply:SetTeam(ES)
[/CODE]
[QUOTE=AnonTakesOver;44717230]Just wanted to point out that in the original code you had
[CODE]
local ES = math.random(3, 4)
if ES == 3 then
ply:SetTeam( 3 )
end
if ES == 4 then
ply:SetTeam( 4 )
end
[/CODE]
which could easily be changed to
[CODE]
local ES = math.random(3, 4)
ply:SetTeam(ES)
[/CODE][/QUOTE]
He wants the teams to be balanced, not just people randomly placed...
Sorry, you need to Log In to post a reply to this thread.