AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   spawnStaticSound soundindex (https://forums.alliedmods.net/showthread.php?t=296738)

VoivoDpl 04-28-2017 00:30

spawnStaticSound soundindex
 
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 ?

klippy 04-28-2017 05:27

Re: spawnStaticSound soundindex
 
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.

VoivoDpl 04-28-2017 08:37

Re: spawnStaticSound soundindex
 
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.

klippy 04-28-2017 09:11

Re: spawnStaticSound soundindex
 
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.


All times are GMT -4. The time now is 04:37.

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