Hi, I thought I had this fixed, but it seems if more than 2 players are in the game it won't work or something.
What I am trying to do is have it give each player a radius. If it detects another player in the radius, they will both be set to SOLID_NOT. If it doesn't detect a player in the radius, they will be set to SOLID_BBOX.
Here is the code i'm using now that doesn't work all the time (seems if more than 2 players are in it doesn't work).
Code:
new players[32];
new num;
get_players(players, num, "a");
for(new i = 1; i <= num; i++) {
if( (is_user_alive(players[i]) && is_user_alive(id)) ) {
if(!(players[i] == id)) {
new distance;
new origin1[3], origin2[3];
new radius = 95;
get_user_origin(players[i], origin1);
get_user_origin(id, origin2);
distance = get_distance(origin1, origin2);
if(distance < radius) {
entity_set_int(id, EV_INT_solid, SOLID_NOT);
entity_set_int(players[i], EV_INT_solid, SOLID_NOT);
} else {
entity_set_int(id, EV_INT_solid, SOLID_BBOX);
entity_set_int(players[i], EV_INT_solid, SOLID_BBOX);
}
}
}
}
I then tried to use a suggestion with "find_sphere_class". This only gets the number of players I think though, and I need the players id. Here is the code I used for that...
Code:
new players[32];
new num;
get_players(players, num);
for(new i = 1; i <= num; i++) {
new Float:origin[3];
new testplayer;
entity_get_vector(players[i], EV_VEC_origin, origin);
testplayer = find_sphere_class(0, "player", 100.0, players, 33, origin);
client_print(0, print_chat, "Players in radius... %d", testplayer);
}