Raised This Month: $51 Target: $400
 12% 

spawnStaticSound soundindex


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
VoivoDpl
Junior Member
Join Date: Apr 2017
Old 04-28-2017 , 00:30   spawnStaticSound soundindex
Reply With Quote #1

PHP Code:
/* Script generated by Pawn Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#define PLUGIN    "Sound Attenuator"
#define AUTHOR    "Voi"
#define VERSION    "0.1"
#define clamp_byte(%1)                                (clamp(%1, 0, 255)) 
#define clamp_short(%1)                             (clamp(%1, 0, 65535)) 

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_forward(FM_EmitSound,"fw_emitsound");
}

public 
fw_emitsound(ent,channelSound[],Float:fvol,Float:attn,flags,pitch)
{
    
    
    new 
Float:origin[3]
    new 
players[32], num
    get_players
(playersnum)
    
    new 
Float:distance_to_send = (attn == ATTN_NONE) ? 1000000.0 : (1600 attn)
    
    for (new 
i=0;i<num;i++)
    {
        if (
entity_range(entplayers[i]) > distance_to_send)
            continue
        
        
        
        if(
is_user_connected(players[i]))
        {
            if(
ent == players[i])
                continue
            if(!
is_visible(entplayers[i]))
            {
                
fvol *= 0.5
                
            
}
        }
        
spawnStaticSound(players[i], entoriginSoundfvolattnpitchflags)
        
    }
    
    return 
FMRES_SUPERCEDE
}
stock spawnStaticSound(const sendto, const index, const Float:origin[3], const soundIndex[], const Float:vol, const Float:atten, const pitch, const flags

    
message_begin(sendto MSG_ONE MSG_ALLSVC_SPAWNSTATICSOUND, .player sendto);
    {
        
write_coord_f(origin[0]); 
        
write_coord_f(origin[1]); 
        
write_coord_f(origin[2]);
        
write_short(soundIndex);
        
write_byte(clamp_byte(floatround(vol 255)))
        
write_byte(clamp_byte(floatround(atten 64)))
        
write_short(index)        
        
write_byte(pitch)
        
write_byte(flags)
    }
    
message_end()

How to copy the sound file string from the hooked function into spawnStaticSound soundindex ?
VoivoDpl is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-28-2017 , 05:27   Re: spawnStaticSound soundindex
Reply With Quote #2

Looks like you can just do
PHP Code:
new const soundIndex engfunc(EngFunc_PrecacheSoundSound); 
PrecacheSound will return an index, given that the sound is already precached. I believe it's guaranteed to be precached in EmitSound.
klippy is offline
VoivoDpl
Junior Member
Join Date: Apr 2017
Old 04-28-2017 , 08:37   Re: spawnStaticSound soundindex
Reply With Quote #3

Thanks. I can now debug the plugin, but it doesn't block the sounds. Also how do I block weapon sounds and send artificial ones ? I want to block only other player weapon sounds.
VoivoDpl is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-28-2017 , 09:11   Re: spawnStaticSound soundindex
Reply With Quote #4

I believe shooting sounds aren't emitted from the server but found in models themselves, meaning they are played by clients.
I believe there have been topics on blocking shooting sounds around here.
klippy 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 09:04.


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