Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoldNux
Senior Member
Join Date: Mar 2018
Old 04-27-2018 , 11:17   [HELP] How do I count the number of players in both team?
Reply With Quote #1

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")     } }
__________________
Try my version of de_dust2, I think it's great and you should check it out!
https://gamebanana.com/mods/83731

Last edited by GoldNux; 04-27-2018 at 11:22.
GoldNux is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-27-2018 , 11:27   Re: [HELP] How do I count the number of players in both team?
Reply With Quote #2

Can call get_players() twice using the team flag. The count is passed by reference to a variable.
__________________
Bugsy is offline
GoldNux
Senior Member
Join Date: Mar 2018
Old 04-27-2018 , 12:07   Re: [HELP] How do I count the number of players in both team?
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
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")         } }
__________________
Try my version of de_dust2, I think it's great and you should check it out!
https://gamebanana.com/mods/83731
GoldNux is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 04-27-2018 , 12:09   Re: [HELP] How do I count the number of players in both team?
Reply With Quote #4

Quote:
Originally Posted by GoldNux View Post
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") }

Last edited by iceeedr; 04-27-2018 at 12:10. Reason: .
iceeedr is offline
Send a message via Skype™ to iceeedr
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-27-2018 , 14:03   Re: [HELP] How do I count the number of players in both team?
Reply With Quote #5

Also, to change cvars use set_pcvar_num instead of console_cmd.
__________________
klippy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-27-2018 , 15:14   Re: [HELP] How do I count the number of players in both team?
Reply With Quote #6

For cvars you are not creating use get_cvar_pointer() to get the pointer to pass to get_pcvar_X()
__________________
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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