Raised This Month: $ Target: $400
 0% 

Help me with code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Apokalipsisa
Member
Join Date: May 2012
Old 05-22-2013 , 17:55   Help me with code
Reply With Quote #1

Please tell me how to make the entity follow the closest player to him?Now the entity follow only the first player catched in that radius and i want to make it follow every player in it (change to closest target).

PHP Code:
public FindClosesEnemy(entid)
{
    new 
Float:Dist
    
new Float:maxdistance=4000.0
    
new indexid=0    
    
for(new i=1;i<=get_maxplayers();i++){
        if(
is_user_alive(i) && is_valid_ent(i) && can_see_fm(entidi))
        {
            
Dist entity_range(entidi)
            if(
Dist <= maxdistance)
            {
                
maxdistance=Dist
                indexid
=i
                
                
return indexid
            
}
        }    
    }    
    return 
0

Apokalipsisa 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 16:17.


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