Quote:
Originally Posted by fysiks
Use a switch for get_user_team(). Also, no reason to use continue in code so small, it just makes it harder to read.
|
Yes Sir ;)
PHP Code:
getRandPlayer()
{
new players[ 32 ], player, num, pList[ 33 ], count;
get_players( players, num, "a" );
for( new i ; i < num ; i ++ )
{
player = players[ i ];
if( get_user_team( player ) == 1 || get_user_team( player ) == 2 )
{
pList[ count ] = player;
count ++;
}
}
return pList[ random( count ) ];
}
But to use a switch statement in there, wouldn't that make you have the result code would be written there twice? Or can you actually do
PHP Code:
case 1 | 2:
{
//
}
...?
__________________