Quote:
Originally Posted by addons_zz
Nice work. And you can remove the ( g_Players == g_Selected ), because, if all are already selected, should return -1, instead of 0.
Code:
GetRandomPlayer()
{
//No players (alive && ct)
if( !g_Players
|| !GetAliveCt() ) // so it will not return 0 when there is no players to be selected.
{
return 0;
}
|
i put it between /**/ forgot to delete it.
Quote:
Originally Posted by addons_zz
Your function GetAliveCt() do not need to count all cts, unless you need the total alive. Then it just could be:
Code:
GetAliveCt()
{
for( new id = 1; id <= g_Max; id++ )
{
if ( is_user_alive( id )
&& cs_get_user_team( id ) == CS_TEAM_CT )
{
return 1
}
}
return 0;
}
|
oh didn't think about that i will use this from now
Quote:
Originally Posted by addons_zz
But is you need all alive CTs total and their ids, you can use a built-in function which should be faster:
Code:
new players_CT_ids[32]
new players_total_CT_number
get_players(players_CT_ids, players_total_CT_number, "ae", "CT")
|
but i remember get_players with e flag bugs.(i used to have a plugin that use get_players with e flag on amxx 1.8.2 and it randomly bugs and the number of players returned is 0.)
__________________