AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_entity_distance (https://forums.alliedmods.net/showthread.php?t=22052)

Jordan 12-17-2005 14:33

get_entity_distance
 
Question: What do I do with get_entity_distance?

Can I have like:

Code:
if (get_entity_distance(id, id2)) > 30

I figured that I would need coordinates, so what is the point of get_entity_distance?

Cheap_Suit 12-17-2005 14:53

Code:

stock get_entity_distance(ent1, ent2)
{
        new Float:orig1[3], Float:orig2[3], origin1[3], origin2[3]
        entity_get_vector(ent1, EV_VEC_origin, orig1)
        for(new a = 0; a < 3; a++)
                origin1[a] = floatround(orig1[a])

        entity_get_vector(ent2, EV_VEC_origin, orig2)
        for(new b = 0; b < 3; b++)
                origin2[b] = floatround(orig2[b])

        return get_distance(origin1, origin2)
}

It does it for you.

Code:
if(get_entity_distance(id, id2) > 30)

Jordan 12-17-2005 18:51

Thank you :) Just one thing though - how far exactly is 30? o.O

Twilight Suzuka 12-17-2005 19:24

Thirty units. Well, 16 is a player, so...yeah.

Jordan 12-17-2005 19:25

Got ya. Thanks a lot :)

v3x 12-17-2005 20:25

I usually do this:
Code:
new distance = floatround(entity_range(ent1, ent2));

XxAvalanchexX 12-18-2005 04:35

Why?

v3x 12-18-2005 08:54

I dunno, it's all KleeneX's fault! :P


All times are GMT -4. The time now is 16:07.

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