AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Loop though all players and if is on 1 team do so other do that (https://forums.alliedmods.net/showthread.php?t=95432)

micke1101 06-23-2009 14:36

Loop though all players and if is on 1 team do so other do that
 
Hi im wondering whats the best loop if im going to loop all players check what team and then give them something depending on team?
Ive found some different loops but they dosent work/does it in another way.

Thanks in advanced

Arkshine 06-23-2009 14:50

Re: Loop though all players and if is on 1 team do so other do that
 
Using get_players() :

Code:
new Players[ 32 ]; new Num; get_players( Players, Num, "ae", "TERRORIST" ); for ( new i; i < Num; i++ ) {     GiveMeSomething( Players[ i ] ); }

If you plan to use severals times the player's index, you should save it :

Code:
for ( new i; i < Num; i++ ) {     Player = Players[ i ];         GiveMeSomething( Player );     GiveMeSomething2( Player ); }


Looping through all players :

Code:
for ( new Player = 1; Player <= gMaxClients; Player++ ) {     if( is_user_alive( Player ) && cs_get_user_team( Player ) == CS_TEAM_T )     {         GiveMeSomething( Player );     } }

micke1101 06-23-2009 15:04

Re: Loop though all players and if is on 1 team do so other do that
 
Thank you:mrgreen:


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

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