AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] How do I count the number of players in both team? (https://forums.alliedmods.net/showthread.php?t=307128)

GoldNux 04-27-2018 11:17

[HELP] How do I count the number of players in both team?
 
I need a function that checks if there are 5 players in each team.
Something like this:

Code:
public checkPlayerAmount() {     if (playersCT == 5 && playersT == 5)     {         console_cmd(0, "csstats_pause 0")     } }

Bugsy 04-27-2018 11:27

Re: [HELP] How do I count the number of players in both team?
 
Can call get_players() twice using the team flag. The count is passed by reference to a variable.

GoldNux 04-27-2018 12:07

Re: [HELP] How do I count the number of players in both team?
 
Quote:

Originally Posted by Bugsy (Post 2589686)
Can call get_players() twice using the team flag. The count is passed by reference to a variable.

Does this look right?

Code:
public checkPlayerAmount() {     new playersCT[32]     new playersT[32]     new numCT     new numT     get_players(playersCT, numCT "e", "CT")     get_players(playersT, numT "e", "TERRORIST")         if (numCT == 5 && numT == 5)         {             console_cmd(0, "csstats_pause 0")         } }

iceeedr 04-27-2018 12:09

Re: [HELP] How do I count the number of players in both team?
 
Quote:

Originally Posted by GoldNux (Post 2589685)
I need a function that checks if there are 5 players in each team.
Something like this:

Code:
public checkPlayerAmount() {     if (playersCT == 5 && playersT == 5)     {         console_cmd(0, "csstats_pause 0")     } }

Code:
public CheckPlayers() {     new iPlayers[MAX_PLAYERS], iNum[CsTeams]     get_players(iPlayers, iNum[CS_TEAM_T], "e", "TERRORIST")     get_players(iPlayers, iNum[CS_TEAM_CT], "e", "CT")             if(iNum[CS_TEAM_T] == 5 && iNum[CS_TEAM_CT] == 5)         console_cmd(0, "csstats_pause 0") }

klippy 04-27-2018 14:03

Re: [HELP] How do I count the number of players in both team?
 
Also, to change cvars use set_pcvar_num instead of console_cmd.

Bugsy 04-27-2018 15:14

Re: [HELP] How do I count the number of players in both team?
 
For cvars you are not creating use get_cvar_pointer() to get the pointer to pass to get_pcvar_X()


All times are GMT -4. The time now is 04:41.

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