Raised This Month: $ Target: $400
 0% 

Emit_sound error


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Gian_Yagami
Member
Join Date: Apr 2014
Old 07-29-2014 , 14:03   Re: Emit_sound error
Reply With Quote #3

LOL, I fix it by myself
Here's an example. For somebody have same trouble like me
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Sound replace"
#define VERSION "Testing"
#define AUTHOR "Gian_Yagami"


new model[33][32];
new 
sound[101];
new 
sex[32]
// sound female
new const SOUND_F_BHIT[3][] = { "player/f_bhit_flesh-1.wav",
            
"player/f_bhit_flesh-2.wav",
            
"player/f_bhit_flesh-3.wav"}
new const 
SOUND_F_DIE[3][] = { "player/f_die1.wav",
            
"player/f_die2.wav",
            
"player/f_die3.wav"}
new const 
SOUND_F_HS[3][] = { "player/f_headshot1.wav",
            
"player/f_headshot2.wav",
            
"player/f_headshot3.wav"}


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_Spawn"player""PlayerSpawn"1);
    
register_forward(FM_EmitSound"fw_EmitSound")
}

public 
plugin_precache()
for (new 
0<= 2i++)
{
    
engfunc(EngFunc_PrecacheSoundSOUND_F_BHIT[i])
    
engfunc(EngFunc_PrecacheSoundSOUND_F_DIE[i])
    
engfunc(EngFunc_PrecacheSoundSOUND_F_HS[i])
}

public 
PlayerSpawn(id) {
    if(!
is_user_alive(id)) return;
    
    
cs_get_user_model(idmodel[id], 31);
    if(
equal(model[id], "yuri")){
        
sex[id]= 1;} else sex[id]= 0
}
    
public 
fw_EmitSound(idchannel, const sample[], Float:volumeFloat:attnflagspitch)
{
    if(!
is_user_connected(id))
        return 
FMRES_IGNORED;
    if(
sex[id] != 1) return FMRES_IGNORED;
    
    for (new 
0<= 2i++)
    {
        
// Hit
        
format(soundcharsmax(sound), "%s"SOUND_F_BHIT[i])
        
replace(soundcharsmax(sound), "player/f_""player/")
        if (
equal(samplesound))
        {
            
emit_sound(idchannelSOUND_F_BHIT[i], volumeattnflagspitch)
            return 
FMRES_SUPERCEDE;
        }
        
// Die
        
format(soundcharsmax(sound), "%s"SOUND_F_DIE[i])
        
replace(soundcharsmax(sound), "player/f_""player/")
        if (
equal(samplesound))
        {
            
emit_sound(idchannelSOUND_F_DIE[i], volumeattnflagspitch)
            return 
FMRES_SUPERCEDE;
        }
        
// Headshot
        
format(soundcharsmax(sound), "%s"SOUND_F_HS[i])
        
replace(soundcharsmax(sound), "player/f_""player/")
        if (
equal(samplesound))
        {
            
emit_sound(idchannelSOUND_F_HS[i], volumeattnflagspitch)
            return 
FMRES_SUPERCEDE;
        }
    }
    return 
FMRES_IGNORED;

just need Sound forwarding. and you need a variable to checked if your model is female, because you can't write check model statement in fw_emitsound action.

Last edited by Gian_Yagami; 07-30-2014 at 00:42.
Gian_Yagami 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 12:58.


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