maybe try this one...but i think there are ways to optimize this function...
I have cuted "if( (is_user_alive(players[i]) && is_user_alive(id)) && (is_user_connected(players[i]) && is_user_connected(id)) )" this out because of this --> get_players(players, num, "a")
You already get alive("a") players....and to be alive you have to be connected ;)
Code:
public function(id)
{
new players[32];
new num;
new bool:inside
get_players(players, num, "a");
for(new i = 0; i < num; i++) {
new distance;
new origin1[3], origin2[3];
new radius = 700;
new tempname[33];
get_user_name(players[i], tempname, 32);
get_user_origin(players[i], origin1);
get_user_origin(id, origin2);
distance = get_distance(origin1, origin2);
if(distance < radius)
{
// WITHIN RADIUS OF PLAYER
inside = true;
set_hudmessage(255, 212, 42, -1.0, -1.0, 0, 15.0, 30.0, 0.0, 0.99, 4);
show_hudmessage(id, "You are INSIDE RANGE of %s", tempname);
}
}
if(!inside) {
for(new i = 0; i < num; i++) {
new distance;
new origin1[3], origin2[3];
new radius = 700;
new tempname[33];
get_user_name(players[i], tempname, 32);
get_user_origin(players[i], origin1);
get_user_origin(id, origin2);
distance = get_distance(origin1, origin2);
if(distance > radius)
{
// OUTSIDE RADIUS OF PLAYER
set_hudmessage(255, 212, 42, -1.0, -1.0, 0, 15.0, 30.0, 0.0, 0.99, 4);
show_hudmessage(id, "You are OUTSIDE RANGE of %s", tempname);
}
}
}
set_task(1.0, "function", id);
return 0;
}