AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Modindependent way to count team and enemies? (https://forums.alliedmods.net/showthread.php?t=50475)

Isobold 01-27-2007 07:24

Modindependent way to count team and enemies?
 
Is there a mod independent / generic way to count players per team? I need to know at player respawn, how much players I have in each team and than to decide for each player what to do with him, depending on his team and the player number in each team ...

I could easily do this with cs or dod, but how to do this with any mod?

Is get_players still my friend in this case or do I have to add some code lines for each mod?

get_user_team is quite good to have a generic way to get a players team, but how to know which teams exist to count the number of players in each team? I would really not like to use some "pre parse" on each respawn of a player to get to know, which teams exist and than to count how many players are in there ...

schnitzelmaker 01-27-2007 10:01

Re: Modindependent way to count team and enemies?
 
yes, very easy.
Code:
for(new i=0;i<=32;i++)   new team = pev(i,pev_team)

Here a litle complete example:You only need the team id number.
I am NOT 100% sure(1= CT,Axis/2= Terror,Allies/0= Spectator)
Code:
public count_players() {  new teamA,teamB  for(new i=0;i<=32;i++)  {   new team = pev(i,pev_team)   if(team == 1)    teamA++   else if(team == 2)    teamB++   client_print(0,print_chat,"TeamA have %d Player,TeamB have %d Player",teamA,teamB)  } }

For the teamnames there exist an event:http://wiki.amxmodx.org/index.php/Ha...t for all Mods

Isobold 02-11-2007 12:23

Re: Modindependent way to count team and enemies?
 
Works quite well, karma++ for this.


All times are GMT -4. The time now is 22:27.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.