Raised This Month: $ Target: $400
 0% 

Get player by distance


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Killer zm
Senior Member
Join Date: Jun 2011
Old 04-22-2013 , 13:13   Get player by distance
Reply With Quote #1

My code

PHP 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(entidi))
        {
            
Dist entity_range(entidi)
            
            
            if(
Dist <= maxdistance)
            {
                
maxdistance=Dist
                indexid
=i
                
                
return indexid
            
}
        }    
    }    
    return 
0

Why is always return indexid = 1
and i saw that when i change new i=1 with another number new i=5 indexid will be returned like 5

Please help me .Thank You
Killer zm 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