Raised This Month: $ Target: $400
 0% 

[code] infinity loop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JusTGo
Veteran Member
Join Date: Mar 2013
Old 12-30-2015 , 08:06   Re: [code] infinity loop
Reply With Quote #1

Quote:
Originally Posted by addons_zz View Post
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 View Post
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 View Post
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.)
__________________
JusTGo 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 17:57.


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