View Single Post
slLent
Member
Join Date: Apr 2010
Location: Tomsk, Russia
Old 04-12-2014 , 12:10   Re: AMXX Module: EmitSound2
Reply With Quote #5

SVC_SPAWNSTATICSOUND channel has only CHAN_STATIC.
and also playback sound different quality

Can also use this method by PRoSToTeM@

PHP Code:
#include <amxmodx>

#define BIT(%0)            (1<<(%0))
#define BITSUM(%0)        (BIT(%0)-1)

new g_iWritingBits;
new 
g_iCurrentByte;

public 
plugin_init()
{
    
register_clcmd("say /emit2","cmdSound");
}
public 
cmdSound(id)
{
    
message_begin(MSG_ONE,SVC_SOUND,_,id);

    
MSG_StartBitWriting();

    new 
iFlags 0;

    
MSG_WriteBits(iFlags,9);
    
MSG_WriteBits(CHAN_WEAPON,3);
    
MSG_WriteBits(0,11);
    
MSG_WriteBits(precache_sound("weapons/ak47-1.wav"),8);

    
MSG_WriteOneBit(0);
    
MSG_WriteOneBit(0);
    
MSG_WriteOneBit(0);

    
MSG_EndBitWriting();
    
message_end();
}
MSG_StartBitWriting()
{
    
g_iWritingBits 0;
    
g_iCurrentByte 0;
}
MSG_WriteBits(iValue,iBits)
{
    if(
iBits 25)
    {
        return;
    }
    
g_iCurrentByte |= ((iValue BITSUM(iBits)) << g_iWritingBits);
    
g_iWritingBits += iBits;

    while(
g_iWritingBits >= 8)
    {
        
write_byte(g_iCurrentByte BITSUM(8));

        
g_iCurrentByte >>= 8;
        
g_iWritingBits -= 8;
    }
}
MSG_WriteOneBit(iBit)
{
    
MSG_WriteBits(iBit,1);
}
MSG_EndBitWriting()
{
    if(
g_iWritingBits)
    {
        
write_byte(g_iCurrentByte);
    }

EmitSound2 was written mainly for anti-cheat, maybe prove useful for someone

Last edited by slLent; 06-05-2016 at 06:37.
slLent is offline