View Single Post
hellmonja
Senior Member
Join Date: Oct 2015
Old 09-06-2019 , 14:25   Re: [HELP] Finding Players Around Point
Reply With Quote #7

Quote:
Originally Posted by CrazY. View Post
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 
0playerFloat:_origin[3]; _numi++)
    {
        
player _players[i];
        
entity_get_vector(playerEV_VEC_origin_origin);

        if (
vector_distance(origin_origin) > radius)
            continue;

        
players[num] = player;
        
num++;
    }
}

...

// Usage example
new players[MAX_PLAYERS], numFloat:origin[3];
get_players_in_radius(playersnumorigin240.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...
__________________
hellmonja is offline