AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Emit_sound error (https://forums.alliedmods.net/showthread.php?t=245150)

Gian_Yagami 07-29-2014 01:22

Emit_sound error
 
I'd like to replace player noise if they use character Female, Here's my code:
PHP Code:

/* Plugin generated by AMXX-Studio */

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

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


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)

    
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])
    }

new 
model[32]

public 
fw_EmitSound(idchannel, const sample[], Float:volumeFloat:attnflagspitch)
{
    if (!
is_user_connected(id)){
        return 
FMRS_IGNORED;
    }
    
get_user_info(idmodel31)
    if(
equal(model"yuri")
    new 
sound[101]
    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;
        }
    }
    
    
//client_print(id, print_chat, "[%s]", sample)
    
return FMRES_IGNORED;


compile error message:
Quote:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Warning: Loose indentation on line 41
Error: Invalid expression, assumed zero on line 43
Error: Undefined symbol "id" on line 43
Error: Invalid expression, assumed zero on line 43
Error: Too many error messages on one line on line 43

Compilation aborted.
4 Errors.
Could not locate output file C:\Users\Compaq\Desktop\woman_sounds.amx (compile failed).


Gian_Yagami 07-29-2014 08:32

Re: Emit_sound error
 
I fix my code all day, It's works when compiling. But, sound didn't hear...

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];
// 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);
}

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 1;

    
cs_get_user_model(idmodel[id], 31);
    
    if(
equal(model[id], "sas")){
        if(
emit_sound(idCHAN_VOICESound1.0ATTN_NORM0PITCH_NORM))
        {
            if(
equal(Sound"player/bhit_flesh-%i.wav"random_num(13)))
            {
                
format(Soundcharsmax(Sound), "player/f_bhit_flesh-%i.wav"random_num(13))
                
emit_sound(idCHAN_VOICESound1.0ATTN_NORM0PITCH_NORM)
                return 
FMRES_SUPERCEDE;
            }
        }
}


Please someone Help me fix it!

Gian_Yagami 07-29-2014 14:03

Re: Emit_sound error
 
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.

schmurgel1983 07-29-2014 16:13

Re: Emit_sound error
 
2 Attachment(s)
No one will Help you huh? O.o

A bit optimize and I do it more "readable".

Gian_Yagami 07-29-2014 20:15

Quote:

Originally Posted by schmurgel1983 (Post 2175897)
No one will Help you huh? O.o

A bit optimize and I do it more "readable".

Yeah :cry:
and Thank you for help :)

In normal mode It's works fine. but in ZP, the Sounds turned to default with BOT, but sometimes correct. I don't know why.

and how to add more model? I write like this, but isn't work
PHP Code:

if (equali(model"yuri") || equali(model,"heroine") || equali(model"natasha") || equali(model,"ritsuka") || equali(model"natasha2") || equali(model,"jennifer2") || equali(model"blair") || equali(model,"sas" )) g_bFemale[id] = true 

MERGE EDIT:
Bump, Please help..
I'd like to use many models here, I use this code
PHP Code:

    if (equal(model"sas")) g_bFemale[id] = true
    
else if (equal(model"leet")) g_bFemale[id] = true 

anyone know how to make this shorter?


All times are GMT -4. The time now is 12:58.

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