Raised This Month: $ Target: $400
 0% 

Get player by distance


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 04-22-2013 , 17:02   Re: Get player by distance
Reply With Quote #4

you exit the function after first iteration of the for loop

Code:
public FindClosesEnemy(entid) {     new Float:Dist     new Float:maxdistance=4000.0     new indexid=0             for(new i=1;i<=g_iMaxPlayers;i++)     {                         if(is_user_alive(i) || is_user_bot(i) && is_valid_ent(i) && can_see_fm(entid, i))         {             Dist = entity_range(entid, i)                                     if(Dist <= maxdistance)             {                 maxdistance=Dist                 indexid=i             }         }         }         return (indexid) ? indexid : 0 }

Last edited by jimaway; 04-22-2013 at 17:03.
jimaway is offline
 



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 10:51.


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