Counting Players on Team

Posts 1–13 of 13 · Page 1 of 1
Counting Players on Team
How can I count players on each team, so that I can use that variable for ending the game? I'm counting events that happen when players are alive, and need to compare that to total players on each team.

By the way, this is 'Freeze Tag'. I'm trying to end the game after all the players on one team are frozen, making the other team the winners.
players = maps\mp\gametypes\_teams::CountPlayers();
Okay, I'm almost there, but I have to finish that script.

something like:

if(level.Frozen[self.team] == players) //help here... tried players, "players", +players+, "+players+"
{ etc... }

How do I apply it?
just a heads up, level.Frozen at times can be glitchy (ex. counts too many players)


try this:
Code:
if(level.Frozen[self.team] == players[self.team]){ ... }
Code:
for(;;)
{
	self waittill("spawned_player");

	if(self.team == "allies")
	OppsTeam = "axis";
		
	if(self.team == "axis")
	OppsTeam = "allies";

	players = maps\mp\gametypes\_teams::CountPlayers();

	if(level.Frozen[self.team] == players[self.team])
	{
		level thread maps\mp\gametypes\_gamelogic::forceEnd();
	}
	else if(level.Frozen[OppsTeam] == players[OppsTeam])
	{
		level thread maps\mp\gametypes\_gamelogic::forceEnd();
	}
}
Syntax Error.
But, if I change players[self.team] (and same for OppsTeam) to 6, or any other number, it loads fine.

EDIT: My bad. Sleep Deprived, I forgot I changed another part of the script. So... it loads fine now, but instantly ends the game with a DRAW.
[php]maps\mp\gametypes\_gamescore::_setTeamScore("allie s", 2000);

maps\mp\gametypes\_gamescore::_setTeamScore("axis" , 2000);

[/php]
Quote Originally Posted by mathieutje12 View Post
[php]maps\mp\gametypes\_gamescore::_setTeamScore("allie s", 2000);

maps\mp\gametypes\_gamescore::_setTeamScore("axis" , 2000);

[/php]
What's that got to do with counting players?
he said the game ends in a draw:
EDIT: My bad. Sleep Deprived, I forgot I changed another part of the script. So... it loads fine now, but instantly ends the game with a DRAW.

this is the code for set points at the end of the game...
Sorry, clarification, the moment the game loads, before the timer is finished counting down to run off and kill... it ends, and since no one has any kills, it results in a DRAW...

The Draw wasn't the concern, the concern is getting the script to count team players, and compare to frozen players, resulting in Ending the Game if Total Frozen equals Total Team Players.
Quote Originally Posted by chrisdavis97 View Post
Sorry, clarification, the moment the game loads, before the timer is finished counting down to run off and kill... it ends, and since no one has any kills, it results in a DRAW...

The Draw wasn't the concern, the concern is getting the script to count team players, and compare to frozen players, resulting in Ending the Game if Total Frozen equals Total Team Players.
Seems you are not calling this as a level thread but on my site it is onPlayerSpawned()

so...
as soon as anyone spawns and the is no one on the other team it ends early
Yeah, you're right. I changed it up a bit to allow someone to join...
Code:
if((players[self.team] > 0) && (level.Frozen[self.team] == players[self.team]))
{
level thread maps\mp\gametypes\_gamelogic::forceEnd();
}
if((players[OppsTeam] > 0) && (level.Frozen[OppsTeam] == players[OppsTeam]))
{
level thread maps\mp\gametypes\_gamelogic::forceEnd();
}
I got it working, and you're right... level.Frozen is VERY glitchy...

We'll work on another way around it, but for now, it's kinda fun to play with.
btw i got already a mod something like that calls freetag too
Care to share? I did a search, and didn't see anything on MPGH. If not, that's okay too.

So, at this point, it's not very fun to play, because it doesn't work properly. I am thinking of a few ideas I can do to make it better.

1. Keep existing conditions, but give a timer once frozen to unfreeze after 30 seconds.
2. Keep existing conditions, but give a timer, as stated above, but it's a timer of death. (I'm diggin this idea, maybe with S&D settings)
3. Re-write the freezing method, to count the actions, instead of the self.frozen code.

What do you think?

EDIT: Another option would be to place them in a holding cell (Jail) when they are knifed (frozen), with a designated location per map, care package walls, etc.
Posts 1–13 of 13 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Talk with us