From engine_stocks.inc:
Code:
/* Get the distance between two entities */
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)
}
So just include <engine_stocks> at the top of your code, and you can use that function..
And instead of looping every 0.1 seconds, you could call it in client_PreThink( id )..
Code:
public client_PreThink( id )
{
new players[32], inum
get_players( players, inum, "a" )
for( new i = 0; i < inum; ++i )
{
if( id == players[i] ) continue
if( get_entity_distance(id, players[i]) > 90 )
{
// id <-- is close to --> players[i]
// Do stuff here..
}
}
return PLUGIN_CONTINUE
}
I hope that helps..