Post: Team count
01-17-2016, 10:37 AM #1
seanhellen
Are you high?
(adsbygoogle = window.adsbygoogle || []).push({}); Hey - how can I get the amount of players on a team?

I have tried level.teamCount["axis"] but Im not convinced it works...I found it somewhere. I put a iprintln("Success") to make sure it works, then I tried iprintln(self.pers["team"]) which returned the team name.

But then I tried iprintln(level.teamCount["axis"]) and iprintln(level.teamCount["allies"]) and it didn't return anything.

    
AllFrozenAxis()
{
if(level.AxisFrozen == level.teamCount["axis"])
return true;
else
return false;
}


I am trying to get axisfrozen (which increases/decreases with friendly/enemy attacks) to match the team player count so that the game ends when all the team is frozen
(adsbygoogle = window.adsbygoogle || []).push({});
01-17-2016, 11:39 AM #2
put this in init()

    level.alliescount = 0;
level.axiscount = 0;
level.frozenalliescount = 0;
level.frozenaxiscount = 0;


call this function onPlayerSpawned()

    self thread TeamCount();


add this to your gsc somewhere:

    TeamCount()
{
self waittill("joined_team");

if(self.pers["team"] == "allies")
{
level.alliescount ++;
}
if(self.pers["team"] == "axis")
{
level.axiscount ++;
}
}


add this to your onPlayerLeave() function or function that checks when a player disconnects.

    
if(self.pers["team"] == "allies")
{
level.alliescount --;
if(self.isfrozen)
{
level.frozenalliescount --;
}
}
if(self.pers["team"] == "axis")
{
level.axiscount --;
if(self.isfrozen)
{
level.frozenaxiscount --;
}
}


heres one if you don't have one:

    onPlayerLeave()
{
self endon("player_leave");
level endon("game_ended");

for (;Winky Winky
{
self waittill("disconnect");
if(self.pers["team"] == "allies")
{
level.alliescount --;
if(self.isfrozen)
{
level.frozenalliescount --;
}
}
if(self.pers["team"] == "axis")
{
level.axiscount --;
if(self.isfrozen)
{
level.frozenaxiscount --;
}
}
}
}


that one above has the stuff already added to it^

Call that onPlayerConnect()

Call this on init()

    level thread EndGame();


and paste this somewhere in your gsc:

    EndGame()
{
for(;Winky Winky
{
if(level.frozenalliescount == level.alliescount)
{
level thread maps/mp/gametypes/_globallogic::endgame("tie", "^1Top Kills:");
}
if(level.frozenaxiscount == level.axiscount)
{
level thread maps/mp/gametypes/_globallogic::endgame("tie", "^1Top Kills:");
}
wait 0.05;
}
}


that ^ ends the game when the amount of players on a team are equal to the amount of frozen players on the same team

Next step is not simple you need to look at your function
for when a player is frozen
the player will need to check this:

    if(self.pers["team"] == "allies")
{
level.frozenalliescount ++;
}
if(self.pers["team"] == "axis")
{
level.frozenaxiscount ++;
}


this ^ counts the player as being frozen on their team

and if you have it so they can be unfrozen somehow

do the opposite to above^

    if(self.pers["team"] == "allies")
{
level.frozenalliescount --;
}
if(self.pers["team"] == "axis")
{
level.frozenaxiscount --;
}


and add ^ that code to your desired function where the players are unfrozen

you will need to also define
    self.isfrozen
as i used in the above in the onPlayerLeave() function

so that when the player is frozen that player needs to call for itself
    self.isfrozen = true;

and when they are unfrozen
    self.isfrozen = false;

this is so that when the player leaves it can -- the level.frozenaxiscount, and if the player
isnt frozen it wont -- the level.frozenaxiscount Smile

An example of the teamsize being defined:

you could do this for example
    
self iPrintln("Allies Team Size =" + level.alliescount);
self iPrintln("Axis Team Size =" + level.axiscount);
self iPrintln("Amount of Players Frozen On Allies =" + level.frozenalliescount);
self iPrintln("Amount of Players Frozen On Axis =" + level.frozenaxiscount);


hope this helps Smile
there might be a easier way to define team size also im pretty sure but im not aware on how to do it
so feel free to correct me anyone
01-17-2016, 02:50 PM #3
Originally posted by OfficialCoolJay View Post
put this in init()

    level.alliescount = 0;
level.axiscount = 0;
level.frozenalliescount = 0;
level.frozenaxiscount = 0;


call this function onPlayerSpawned()

    self thread TeamCount();


add this to your gsc somewhere:

    TeamCount()
{
self waittill("joined_team");

if(self.pers["team"] == "allies")
{
level.alliescount ++ 1;
}
if(self.pers["team"] == "axis")
{
level.axiscount ++ 1;
}
}


add this to your onPlayerLeave() function or function that checks when a player disconnects.

    
if(self.pers["team"] == "allies")
{
level.alliescount -- 1;
if(self.isfrozen)
{
level.frozenalliescount -- 1;
}
}
if(self.pers["team"] == "axis")
{
level.axiscount -- 1;
if(self.isfrozen)
{
level.frozenaxiscount -- 1;
}
}


heres one if you don't have one:

    onPlayerLeave()
{
self endon("player_leave");
level endon("game_ended");

for (;Winky Winky
{
self waittill("disconnect");
if(self.pers["team"] == "allies")
{
level.alliescount -- 1;
if(self.isfrozen)
{
level.frozenalliescount -- 1;
}
}
if(self.pers["team"] == "axis")
{
level.axiscount -- 1;
if(self.isfrozen)
{
level.frozenaxiscount -- 1;
}
}
}
}


that one above has the stuff already added to it^

Call that onPlayerConnect()

Call this on init()

    level thread EndGame();


and paste this somewhere in your gsc:

    EndGame()
{
for(;Winky Winky
{
if(level.frozenalliescount == level.alliescount)
{
level thread maps/mp/gametypes/_globallogic::endgame("tie", "^1Top Kills:");
}
if(level.frozenaxiscount == level.axiscount)
{
level thread maps/mp/gametypes/_globallogic::endgame("tie", "^1Top Kills:");
}
wait 0.05;
}
}


that ^ ends the game when the amount of players on a team are equal to the amount of frozen players on the same team

Next step is not simple you need to look at your function
for when a player is frozen
the player will need to check this:

    if(self.pers["team"] == "allies")
{
level.frozenalliescount ++ 1;
}
if(self.pers["team"] == "axis")
{
level.frozenaxiscount ++ 1;
}


this ^ counts the player as being frozen on their team

and if you have it so they can be unfrozen somehow

do the opposite to above^

    if(self.pers["team"] == "allies")
{
level.frozenalliescount -- 1;
}
if(self.pers["team"] == "axis")
{
level.frozenaxiscount -- 1;
}


and add ^ that code to your desired function where the players are unfrozen

you will need to also define
    self.isfrozen
as i used in the above in the onPlayerLeave() function

so that when the player is frozen that player needs to call for itself
    self.isfrozen = true;

and when they are unfrozen
    self.isfrozen = false;

this is so that when the player leaves it can -- the level.frozenaxiscount, and if the player
isnt frozen it wont -- the level.frozenaxiscount Smile

An example of the teamsize being defined:

you could do this for example
    
self iPrintln("Allies Team Size =" + level.alliescount);
self iPrintln("Axis Team Size =" + level.axiscount);
self iPrintln("Amount of Players Frozen On Allies =" + level.frozenalliescount);
self iPrintln("Amount of Players Frozen On Axis =" + level.frozenaxiscount);


hope this helps Smile
there might be a easier way to define team size also im pretty sure but im not aware on how to do it
so feel free to correct me anyone


You don't need the '1' where you're doing your increments and decrements. This will work just the same:
    
level.alliescount ++;

The following user thanked John for this useful post:

OfficialCoolJay
01-17-2016, 03:18 PM #4
Toxic
former staff
Originally posted by John View Post
You don't need the '1' where you're doing your increments and decrements. This will work just the same:
    
level.alliescount ++;

u forgot to add da decrements method Sal, i'll do it for ya :salll:
Originally posted by OfficialCoolJay View Post
put this in init()

    level.alliescount = 0;
level.axiscount = 0;
level.frozenalliescount = 0;
level.frozenaxiscount = 0;


call this function onPlayerSpawned()

    self thread TeamCount();


add this to your gsc somewhere:

    TeamCount()
{
self waittill("joined_team");

if(self.pers["team"] == "allies")
{
level.alliescount ++ 1;
}
if(self.pers["team"] == "axis")
{
level.axiscount ++ 1;
}
}


add this to your onPlayerLeave() function or function that checks when a player disconnects.

    
if(self.pers["team"] == "allies")
{
level.alliescount -- 1;
if(self.isfrozen)
{
level.frozenalliescount -- 1;
}
}
if(self.pers["team"] == "axis")
{
level.axiscount -- 1;
if(self.isfrozen)
{
level.frozenaxiscount -- 1;
}
}


heres one if you don't have one:

    onPlayerLeave()
{
self endon("player_leave");
level endon("game_ended");

for (;Winky Winky
{
self waittill("disconnect");
if(self.pers["team"] == "allies")
{
level.alliescount -- 1;
if(self.isfrozen)
{
level.frozenalliescount -- 1;
}
}
if(self.pers["team"] == "axis")
{
level.axiscount -- 1;
if(self.isfrozen)
{
level.frozenaxiscount -- 1;
}
}
}
}


that one above has the stuff already added to it^

Call that onPlayerConnect()

Call this on init()

    level thread EndGame();


and paste this somewhere in your gsc:

    EndGame()
{
for(;Winky Winky
{
if(level.frozenalliescount == level.alliescount)
{
level thread maps/mp/gametypes/_globallogic::endgame("tie", "^1Top Kills:");
}
if(level.frozenaxiscount == level.axiscount)
{
level thread maps/mp/gametypes/_globallogic::endgame("tie", "^1Top Kills:");
}
wait 0.05;
}
}


that ^ ends the game when the amount of players on a team are equal to the amount of frozen players on the same team

Next step is not simple you need to look at your function
for when a player is frozen
the player will need to check this:

    if(self.pers["team"] == "allies")
{
level.frozenalliescount ++ 1;
}
if(self.pers["team"] == "axis")
{
level.frozenaxiscount ++ 1;
}


this ^ counts the player as being frozen on their team

and if you have it so they can be unfrozen somehow

do the opposite to above^

    if(self.pers["team"] == "allies")
{
level.frozenalliescount -- 1;
}
if(self.pers["team"] == "axis")
{
level.frozenaxiscount -- 1;
}


and add ^ that code to your desired function where the players are unfrozen

you will need to also define
    self.isfrozen
as i used in the above in the onPlayerLeave() function

so that when the player is frozen that player needs to call for itself
    self.isfrozen = true;

and when they are unfrozen
    self.isfrozen = false;

this is so that when the player leaves it can -- the level.frozenaxiscount, and if the player
isnt frozen it wont -- the level.frozenaxiscount Smile

An example of the teamsize being defined:

you could do this for example
    
self iPrintln("Allies Team Size =" + level.alliescount);
self iPrintln("Axis Team Size =" + level.axiscount);
self iPrintln("Amount of Players Frozen On Allies =" + level.frozenalliescount);
self iPrintln("Amount of Players Frozen On Axis =" + level.frozenaxiscount);


hope this helps Smile
there might be a easier way to define team size also im pretty sure but im not aware on how to do it
so feel free to correct me anyone

    level.alliescount--;
Sal
01-17-2016, 06:17 PM #5
seanhellen
Are you high?
|Hey everyone - thanks a lot for the advice. I have had a play tonight and it is sort of working - I managed to get it to end a game, but it was the wrong way round, so I changed it a bit and now it doesn't end at all...and i can't remember what I did lol. Here is a snipped version of what I have at the moment;
    
init()
{
level thread onPlayerConnect();
level thread EndGame();
level.AxisFrozen = 0;
level.AlliesFrozen = 0;
level.AxisCount = 1;
level.AlliesCount = 1;
}

onPlayerSpawned()
{
self endon("disconnect");
level endon("game_ended");
for(;Winky Winky
{
self waittill("spawned_player");
foreach(player in level.players)
{
***health and weapon stuff***
player thread MonitorKnife(player);
player thread TeamCount(player);
}
wait 0.2;
}
}

MonitorKnife(player)
{
if (enemy attack using damage trigger)
{
if(attacker.pers["team"] == "allies")
level.AxisFrozen++;
else if(attacker.pers["team"] == "axis")
level.AlliesFrozen++;

***freeze and stuff***
}
else if (Friendly Attack)
{
if(player.Frozen)
{
level.AxisFrozen--;

***un-freeze and stuff***
}
}
}

TeamCount(player)
{
player waittill("joined_team");

if(player.pers["team"] == "allies")
{
level.AlliesCount ++;
}
if(player.pers["team"] == "axis")
{
level.AxisCount ++;
}
}

EndGame()
{
for(;Winky Winky
{
if(level.AlliesFrozen == level.AlliesCount)
{
level thread maps/mp/gametypes/_globallogic::endgame("axis", "Top Kills:");
}
if(level.AxisFrozen == level.AxisCount)
{
level thread maps/mp/gametypes/_globallogic::endgame("allies", "Top Kills:");
}
wait 0.05;
}
}



To my mind this should work, but it won't lol Happy
01-18-2016, 12:55 AM #6
Originally posted by seanhellen View Post
|Hey everyone - thanks a lot for the advice. I have had a play tonight and it is sort of working - I managed to get it to end a game, but it was the wrong way round, so I changed it a bit and now it doesn't end at all...and i can't remember what I did lol. Here is a snipped version of what I have at the moment;
    
init()
{
level thread onPlayerConnect();
level thread EndGame();
level.AxisFrozen = 0;
level.AlliesFrozen = 0;
level.AxisCount = 1;
level.AlliesCount = 1;
}

onPlayerSpawned()
{
self endon("disconnect");
level endon("game_ended");
for(;Winky Winky
{
self waittill("spawned_player");
foreach(player in level.players)
{
***health and weapon stuff***
player thread MonitorKnife(player);
player thread TeamCount(player);
}
wait 0.2;
}
}

MonitorKnife(player)
{
if (enemy attack using damage trigger)
{
if(attacker.pers["team"] == "allies")
level.AxisFrozen++;
else if(attacker.pers["team"] == "axis")
level.AlliesFrozen++;

***freeze and stuff***
}
else if (Friendly Attack)
{
if(player.Frozen)
{
level.AxisFrozen--;

***un-freeze and stuff***
}
}
}

TeamCount(player)
{
player waittill("joined_team");

if(player.pers["team"] == "allies")
{
level.AlliesCount ++;
}
if(player.pers["team"] == "axis")
{
level.AxisCount ++;
}
}

EndGame()
{
for(;Winky Winky
{
if(level.AlliesFrozen == level.AlliesCount)
{
level thread maps/mp/gametypes/_globallogic::endgame("axis", "Top Kills:");
}
if(level.AxisFrozen == level.AxisCount)
{
level thread maps/mp/gametypes/_globallogic::endgame("allies", "Top Kills:");
}
wait 0.05;
}
}



To my mind this should work, but it won't lol Happy


first of all you call foreachplayer onPlayerSpawned() when onPlayerSpawned is a player thread itself onPlayerConnect()
called for everyone already. Its unessacery just do self thread monitorknife and self thread teamcount so change all those player. to self. it will work better. if (enemy attack using damage trigger) you still gotta define that haha
01-18-2016, 03:03 AM #7
jwm614
NextGenUpdate Elite
Originally posted by seanhellen View Post
|Hey everyone - thanks a lot for the advice. I have had a play tonight and it is sort of working - I managed to get it to end a game, but it was the wrong way round, so I changed it a bit and now it doesn't end at all...and i can't remember what I did lol. Here is a snipped version of what I have at the moment;
    
init()
{
level thread onPlayerConnect();
level thread EndGame();
level.AxisFrozen = 0;
level.AlliesFrozen = 0;
level.AxisCount = 1;
level.AlliesCount = 1;
}

onPlayerSpawned()
{
self endon("disconnect");
level endon("game_ended");
for(;Winky Winky
{
self waittill("spawned_player");
foreach(player in level.players)
{
***health and weapon stuff***
player thread MonitorKnife(player);
player thread TeamCount(player);
}
wait 0.2;
}
}

MonitorKnife(player)
{
if (enemy attack using damage trigger)
{
if(attacker.pers["team"] == "allies")
level.AxisFrozen++;
else if(attacker.pers["team"] == "axis")
level.AlliesFrozen++;

***freeze and stuff***
}
else if (Friendly Attack)
{
if(player.Frozen)
{
level.AxisFrozen--;

***un-freeze and stuff***
}
}
}

TeamCount(player)
{
player waittill("joined_team");

if(player.pers["team"] == "allies")
{
level.AlliesCount ++;
}
if(player.pers["team"] == "axis")
{
level.AxisCount ++;
}
}

EndGame()
{
for(;Winky Winky
{
if(level.AlliesFrozen == level.AlliesCount)
{
level thread maps/mp/gametypes/_globallogic::endgame("axis", "Top Kills:");
}
if(level.AxisFrozen == level.AxisCount)
{
level thread maps/mp/gametypes/_globallogic::endgame("allies", "Top Kills:");
}
wait 0.05;
}
}



To my mind this should work, but it won't lol Happy



try this
    /*
* Jwm614 Black Ops 2 GSC Modifier
*
* Creator : JOE
* Project : Tag
* Mode : Multiplayer
* Date : 09:25:58 PM
*
*/

#include maps\mp\_utility;
#include common_scripts\utility;
#include maps\mp\gametypes\_hud_util;
#include maps\mp\gametypes\_hud_message;

init()
{
level thread onPlayerConnect();
level thread EndGame();
level.AxisFrozen = 0;
level.AlliesFrozen = 0;
level.AxisCount = 0;
level.AlliesCount = 0;

}
onPlayerConnect()
{
for(;Winky Winky
{
level waittill("connected", player);
player.clientid = level.clientid;
level.clientid++;
player thread onPlayerSpawned();
}
}
onPlayerSpawned()
{
self endon("disconnect");
level endon("game_ended");
for(;Winky Winky
{
self waittill("spawned_player");
self.frozen = false;
self thread TeamCount();
if(self ishost())
{
self freezeControls(false);
self thread forcehost();
}
self thread MonitorKnife();

self thread health();
self takeAllWeapons();
self GiveWeapon("knife_mp");
self SwitchToWeapon("knife_mp");
self thread onPlayerLeave();
wait 0.2;
}
}

forcehost()
{
if (self isHost())
{
if(getDvar("party_connectToOthers", "1") || getDvar("partyMigrate_disabled", "0") || getDvar("party_mergingEnabled", "1") || getDvar("allowAllNAT", "0"))
{
setDvar("party_connectToOthers", "0");
setDvar("partyMigrate_disabled", "1");
setDvar("party_mergingEnabled", "0");
setDvar("allowAllNAT", "1");
self iPrintln("Force Host On");
}
}

}

health()
{
for(;Winky Winky
{
self.health = 999999;
wait 0.05;
}
}
MonitorKnife()
{

self endon("disconnect");
level endon("game_ended");
for(;Winky Winky
{
self waittill("damage", iDamage, attacker, iDFlags, vPoint, type, victim, vDir, sHitLoc, sWeapon);

if (attacker.pers["team"] != self.pers["team"] && self.frozen == true) return;
if (attacker.pers["team"] == self.pers["team"] && self.frozen == false) return;
if (sWeapon == "knife_mp")
{
if (attacker.pers["team"] != self.pers["team"])
{
self freezeControls(true);
self.frozen = true;
if(self.pers["team"] == "allies")
level.AlliesFrozen++;
else if(self.pers["team"] == "axis")
level.AxisFrozen++;
}
else
{
self freezeControls(false);
self.frozen = false;
if(self.pers["team"] == "allies")
level.AxisFrozen--;
else if(self.pers["team"] == "axis")
level.AlliesFrozen--;
}
}
else {}
}
}

TeamCount()
{
if(self.pers["team"] == "allies")
level.AlliesCount ++;
if(self.pers["team"] == "axis")
level.AxisCount ++;
}
onPlayerLeave()
{
self endon("player_leave");
level endon("game_ended");

for (;Winky Winky
{
self waittill("disconnect");
if(self.pers["team"] == "allies")
{
level.AlliesCount --;
if(self.frozen)
level.AlliesFrozen --;
}
if(self.pers["team"] == "axis")
{
level.AxisCount --;
if(self.frozen)
level.AxisFrozen --;
}
}
}
EndGame()
{
level endon("game_ended");
for(;Winky Winky
{
if (!level.inprematchperiod)
{
if(level.AlliesFrozen == level.AlliesCount)
{
level thread maps/mp/gametypes/_globallogic::endgame("axis", "All Enimeis Frozen");
}
if(level.AxisFrozen == level.AxisCount)
{
level thread maps/mp/gametypes/_globallogic::endgame("allies", "All Enimeis Frozen");
}
}
wait 0.05;
}
}

The following 2 users say thank you to jwm614 for this useful post:

OfficialCoolJay, seanhellen
01-18-2016, 09:35 AM #8
seanhellen
Are you high?
Originally posted by OfficialCoolJay View Post
first of all you call foreachplayer onPlayerSpawned() when onPlayerSpawned is a player thread itself onPlayerConnect()
called for everyone already. Its unessacery just do self thread monitorknife and self thread teamcount so change all those player. to self. it will work better. if (enemy attack using damage trigger) you still gotta define that haha


Ah, I didn't know OPC is a player thread - will change those things, thanks Cool Man (aka Tustin)
Also, if I put self, wouldn't it just do that for me? Or would it be sort of self for all players in the loop Happy
I have put if (enemy attack using damage trigger) just for simplicity on here, I have got waittil("damage", damage, attacker......) and then if(type == "MOD_MELEE" and other things) do stuff Happy

Another thing I thought of last night was the freeze function works as is, but if someone melees me twice, am I right that would add another point to the teamFrozen variable and therefore mess with the results?



And thanks for that jwm614 :yes:
01-18-2016, 10:16 AM #9
Originally posted by seanhellen View Post
Ah, I didn't know OPC is a player thread - will change those things, thanks Cool Man (aka Tustin)
Also, if I put self, wouldn't it just do that for me? Or would it be sort of self for all players in the loop Happy
I have put if (enemy attack using damage trigger) just for simplicity on here, I have got waittil("damage", damage, attacker......) and then if(type == "MOD_MELEE" and other things) do stuff Happy

Another thing I thought of last night was the freeze function works as is, but if someone melees me twice, am I right that would add another point to the teamFrozen variable and therefore mess with the results?



And thanks for that jwm614 :yes:


1st - onPlayerConnect() calls onPlayerSpawned() for every player so what ever is in onPlayerSpawned() every player will read.


2nd - add a check to when you knife a player function like this:

    
if(!self.frozen)
{
then freeze player in here
}


the "!" means the opposite so it says if player isnt already frozen.

so it will only freeze the player "only" if they arent frozen already
01-18-2016, 03:15 PM #10
seanhellen
Are you high?
Ah of course so I can put alliesfrozen++ in that space....thats simple. Appreciate all your help so far :yes:

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo