Raised This Month: $51 Target: $400
 12% 

How can Detect distance


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Saint Sinner
Senior Member
Join Date: Feb 2016
Old 02-26-2018 , 08:12   How can Detect distance
Reply With Quote #1

Hy guys

I want to detect distance between player and entity!

Can help me someone?

Code:
CreateEntity()
{     
    Entity = create_entity( "info_target" );

    new Float:PlayerOrigin[3]
    new Float:fDistance    
    
    for(new i = 1 ; i <= maxplayers; i++)
    {
        pev(i, pev_origin, PlayerOrigin)
        fDistance = get_distance_f( Entity , PlayerOrigin )
        
        if( fDistance <= 500.0)
        {
            client_print(i , print_center, "Distance to entity: %.2f", fDistance )
        }
    }

    if( is_valid_ent(Entity) )
    {
        entity_set_string( Entity , EV_SZ_classname, "fox_wall");
        entity_set_int( Entity , EV_INT_solid, SOLID_BBOX);
        entity_set_model( Entity , DATE );
        entity_set_size( Entity , Float:{ -350.0, -10.0, 0.0 }, Float:{ 350.0, 10.0, 10.0 } );      
        entity_set_origin( Entity, Float:{ 1066.52, -1025.00, -551.00 } );
    }
        
    return;
}

Last edited by Saint Sinner; 02-26-2018 at 08:13.
Saint Sinner 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 20:14.


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