Raised This Month: $32 Target: $400
 8% 

Solved [HELP] Finding Players Around Point


Post New Thread Reply   
 
Thread Tools Display Modes
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-07-2019 , 03:17   Re: [HELP] Finding Players Around Point
Reply With Quote #11

find_sphere_class can do that.

https://www.amxmodx.org/api/engine/find_sphere_class
Specify -1 for the entity and pass origin as the last parameter.
__________________

Last edited by HamletEagle; 09-07-2019 at 03:18.
HamletEagle is offline
Old 09-08-2019, 12:50
Xalus
This message has been deleted by Xalus. Reason: Looks like "Bugsy" told the answer on page2.
hellmonja
Senior Member
Join Date: Oct 2015
Old 09-10-2019 , 08:50   Re: [HELP] Finding Players Around Point
Reply With Quote #12

Sorry for the late reply guys. Was busy with work. I was also tinkering with the code Crazy. gave me. It seem it has some problems listing all of the players or something related to that. I haven't explored Bugsy's recommendation yet. But I ended up using find_sphere_class like HamletEagle suggested. I didn't use it before because I didn't know what to put in the entity parameter. I didn't know you can actually put -1 there if there's no entity to base the radius around. Haven't done a hard test but so far it's working well. Here's the code:
PHP Code:
RegisterHam(Ham_TraceAttack"worldspawn""SotB_Sniper_Warning"false);
...
public 
SotB_Sniper_Warning(victimattackerFloat:damageFloat:direction[3], prtdamage_bits)
{
    if(
g_sniperspotted_time[attacker] + 10.0 get_gametime())
        return 
HAM_IGNORED
    
    
new wpn_id get_user_weapon(attacker);
    new 
team get_user_team(attacker);
    
    if(
CSW_ALL_SNIPERRIFLES << wpn_id)
    {
        new 
players[MAX_PLAYERS], iplayernum;
        new 
spotters[MAX_PLAYERS], Float:origin[3];
        
        
get_tr2(prtTR_vecEndPosorigin);
        
find_sphere_class(-1"player"350.0playersMAX_PLAYERSorigin);
        
        for(new 
0MAX_PLAYERSi++)
        {
            
iplayer players[i];

            if(
is_user_alive(iplayer) && iplayer != attacker
            
&& get_user_team(iplayer) != team && !g_is_sneaking[iplayer])
            {
                
spotters[num] = iplayer;
                
num++;
            }
        }
        
        if(
num <= 0) return HAM_IGNORED
        
        
new audio_id  random_num(0sizeof SND_SNIPER_WARNING 1);
        
emit_sound(spotters[0], CHAN_VOICESND_SNIPER_WARNING[audio_id], VOL_NORMATTN_NORM0PITCH_NORM);
        
        
g_sniperspotted_time[attacker] = get_gametime();
    }
    
    return 
HAM_IGNORED

Basically what it does is when an enemy player fires a sniper rifle somewhere near you, it takes everyone around where the shot landed then picks a player to yell, "There's a sniper!"...
__________________
hellmonja is offline
Reply



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 14:12.


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