Raised This Month: $ Target: $400
 0% 

Solved [HELP] Finding Players Around Point


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
hellmonja
Senior Member
Join Date: Oct 2015
Old 09-06-2019 , 14:25   Re: [HELP] Finding Players Around Point
Reply With Quote #8

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
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode