|
Senior Member
|
09-06-2019
, 14:25
Re: [HELP] Finding Players Around Point
|
#7
|
Quote:
Originally Posted by CrazY.
Hook Ham_TraceAttack, get the TR_vecEndPos and use the following code to search for players within a radius.
PHP Code:
#include <engine>
...
#if !defined MAX_PLAYERS
#define MAX_PLAYERS 32
#endif
...
get_players_in_radius(players[MAX_PLAYERS], &num, const Float:origin[3], const Float:radius)
{
// a - Do not include dead players
// h - Do not include HLTV proxies
new _players[MAX_PLAYERS], _num;
get_players(_players, _num, "ah");
num = 0;
for (new i = 0, player, Float:_origin[3]; i < _num; i++)
{
player = _players[i];
entity_get_vector(player, EV_VEC_origin, _origin);
if (vector_distance(origin, _origin) > radius)
continue;
players[num] = player;
num++;
}
}
...
// Usage example
new players[MAX_PLAYERS], num, Float:origin[3];
get_players_in_radius(players, num, origin, 240.0);
|
I will try this next, thank you. Right after I've fiddled enough with what E1_531G suggested. I think he meant using both functions. I'm still new to vectors, origins, velocities and all that so I want to experiment with as much methods as I can...
__________________
|
|
|
|