Team Balance | Help pls

Ok so I have this:


		if team.GetPlayers( TEAM_PROPS ) != team.GetPlayers( TEAM_HUNTERS ) + 1 then
		local BTPT = {}
            table.insert( BTPT, player.GetAll()[math.random(1, #player.GetAll())] )
				if BTPT:Team() == TEAM_HUNTERS then
				BTPT:SetTeam( TEAM_PROPS )   
				end
				
		elseif team.GetPlayers( TEAM_HUNTERS ) != team.GetPlayers( TEAM_PROPS ) + 1 then
		local BTPT = {}
            table.insert( BTPT, player.GetAll()[math.random(1, #player.GetAll())] )
				if BTPT:Team() == TEAM_HUNTERS then
				BTPT:SetTeam( TEAM_PROPS )   
				end
		end

Would this work? And how can I fix it? because all I want is:

  • If there are more Hunters then Props then place a RANDOM player on props to EVEN teams.
  • Because if there is 1 more player on Hunters then Props. I don’t want it to spaz out, so I added the + 1. Because usually there is 1 more hunter or prop. I only want it if its behind 2, or aboth 2.

Tell me if this is right, please help!

[editline]4th September 2016[/editline]

I was trying > and < symbols but I dont think that will check if its aboth 2.

Excuse my semi-colons, I just prefer having them.

Not tested
[lua]
– snip not doing ur ScriptFodder job for you
https://scriptfodder.com/jobs/view/11852
[/lua]

[editline]4th September 2016[/editline]

ripperoni code

Have you ever tried testing stuff on your own, Jacob?

It’s okay, he’s doing this for a ScriptFodder job that he apparently can’t complete.

SF Job.

I would make a custom command that admins could use

Example:


for k, v in pairs( player.GetAll() ) do
	if (k % 2) then
		-- Code to force v *player* to Hunters
	else
		-- Code to force v *player* to Props
	end
end

I am, but the problem is I had it working before. And now its just broken? I sent it to the guy, and he said it was working then something broke?

[editline]5th September 2016[/editline]

Its hard to test with bots… on gamemodes.

[editline]5th September 2016[/editline]

Well, I know what im doing. Its just, can you call a player via uniqueid? Can I use the Table.Insert random player’s UniqueID()?

[editline]5th September 2016[/editline]


	local BTPT = {}
	if team.GetPlayers( TEAM_PROPS ) < team.GetPlayers( TEAM_HUNTERS ) then

            table.insert( BTPT, player.GetAll()[math.random(1, #player.GetAll())] )
				if BTPT:Team() == TEAM_HUNTERS then
				BTPT:SetTeam( TEAM_PROPS )  
                               table.Empty( BTPT )
                               else
                                table.Empty( BTPT )				
				end
				
		elseif team.GetPlayers( TEAM_HUNTERS ) > team.GetPlayers( TEAM_PROPS ) then
		
            table.insert( BTPT, player.GetAll()[math.random(1, #player.GetAll())] )
				if BTPT:Team() == TEAM_HUNTERS then
				BTPT:SetTeam( TEAM_PROPS )
				table.Empty( BTPT )
                                else
                                table.Empty( BTPT )
				end
		end 

This post alone shows you don’t.

Don’t apply for jobs you can’t complete.

Why would you ask how to fix something without even knowing if it works or not?

“Would this work? And how can I fix it?”

If its hard testing all the time I’d use this while I’m working on it to constantly know what’s happening and if anything is wrong.

You just write your logic down here, if there’s anything wrong its gonna be apparent.

Ok, but how do I test it… you cant use bots… aswell I would have to play a hole round./