AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   where is the problem (https://forums.alliedmods.net/showthread.php?t=189228)

RuRuRu612754 07-04-2012 20:03

where is the problem
 
Hello

my code is compile miss

compile.exe :
PHP Code:

warning 203symbol is never used"sound_damege" 

sound.sma :
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fakemeta>

new const sound_damage[] =
{
    
"player/damage_1.wav",
    
"player/damage_2.wav",
    
"player/damage_3.wav"
}

public 
plugin_init() 

    
register_plugin("PLUGIN""VERSION""AUTHOR")

    
register_forward(FM_EmitSound"forward_fm_emitsound")
}

public 
plugin_precache()
{
    new 
new_sound random_num(0sizeof(sound_damage))
    
precache_model(new_sound)
}

public 
forward_fm_emitsound(idiChannelsample[], Float:fVolumeFloat:fAttenuationiFlagsiPitch)
{
    if(
is_user_alive(id))
    {
        if(
cs_get_user_team(id) == CS_TEAM_CT)
        {
            if(
equali(sample"weapons/bhit_flesh-1.wav") || equali(sample"weapons/bhit_flesh-2.wav") || equali(sample"weapons/bhit_flesh-3.wav"))
            {
                new 
new_sound random_num(0sizeof(sound_damage))
                
engfunc(EngFunc_EmitSoundidCHAN_STATICnew_sound1.0ATTN_NORM0PITCH_NORM)
            }
        }
    }


Best Regards,

Bugsy 07-04-2012 20:37

Re: where is the problem
 
As the warning says, you're never actually using the sound_damage string array. You need to precache sound not model. Use random( sizeof(var) ) since that returns a value ranging from 0 to max-1 instead of random_num(0,max) which would error if the max value is returned since the array is indexed from 0 to size-1. There may be other things wrong, I didn't look closely.
PHP Code:

public plugin_precache()
{
    new 
new_sound random_num(0sizeof(sound_damage))
    
precache_model(new_sound)
}

..

new 
new_sound random_num(0sizeof(sound_damage))
engfunc(EngFunc_EmitSoundidCHAN_STATICnew_sound1.0ATTN_NORM0PITCH_NORM

:arrow:
PHP Code:

public plugin_precache()
{
    
precache_soundsound_damagerandomsizeofsound_damage ) ) ] )


..

engfunc(EngFunc_EmitSoundidCHAN_STATICsound_damagerandomsizeofsound_damage ) ) ], 1.0ATTN_NORM0PITCH_NORM


RuRuRu612754 07-04-2012 20:53

Re: where is the problem
 
@Bugsy

oh. i easy miss...
PHP Code:

new new_sound random_num(0sizeof(sound_damage))
precache_model(new_sound

thanks!!

RuRuRu612754 07-04-2012 22:16

Re: where is the problem
 
@Bugsy

sorry
error...

Warning: Unable to open sound/3.wav for transfer

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fakemeta>

new const sound_damage[] =
{
    
"player/damage_1.wav",
    
"player/damage_2.wav",
    
"player/damage_3.wav"
}

public 
plugin_init() 

    
register_plugin("PLUGIN""VERSION""AUTHOR")

    
register_forward(FM_EmitSound"forward_fm_emitsound")
}

public 
plugin_precache()
{
    
precache_sound(sound_damage[random(sizeof(sound_damage))])
}

public 
forward_fm_emitsound(idiChannelsample[], Float:fVolumeFloat:fAttenuationiFlagsiPitch)
{
    if(
is_user_alive(id))
    {
        if(
cs_get_user_team(id) == CS_TEAM_CT)
        {
            if(
equali(sample"weapons/bhit_flesh-1.wav") || equali(sample"weapons/bhit_flesh-2.wav") || equali(sample"weapons/bhit_flesh-3.wav"))
            {
                
engfunc(EngFunc_EmitSoundidCHAN_STATICsound_damage[random(sizeof(sound_damage))], 1.0ATTN_NORM0PITCH_NORM)
            }
        }
    }



Bugsy 07-05-2012 03:03

Re: where is the problem
 
Make sure the file exists in the correct folder on the server-side.

RuRuRu612754 07-05-2012 06:25

Re: where is the problem
 
@Bugsy

yes

Warning: Unable to open //sound/damage_3.wav for transfer

OvidiuS 07-05-2012 06:29

Re: where is the problem
 
Show the code you are using, because in code you posted here damage_3 is in player folder.
Code:

new const sound_damage[] =
{
    "player/damage_1.wav",
    "player/damage_2.wav",
    "player/damage_3.wav"
}


RuRuRu612754 07-05-2012 06:39

Re: where is the problem
 
@OvidiuS
I have put in a folder to certainty
"sound/player/damage_*.wav"

RuRuRu612754 07-05-2012 08:05

Re: where is the problem
 
has been resolve
thanks

how to precache all the sound_damage?

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fakemeta>

new const sound_damage[][] =
{
    
"player/damage_1.wav",
    
"player/damage_2.wav",
    
"player/damage_3.wav"
}

public 
plugin_init()

    
register_plugin("PLUGIN""VERSION""AUTHOR")

    
register_forward(FM_EmitSound"forward_fm_emitsound")
}

public 
plugin_precache()
{
    
precache_sound(sound_damage[random(sizeof(sound_damage))])
}

public 
forward_fm_emitsound(idiChannelsample[], Float:fVolumeFloat:fAttenuationiFlagsiPitch)
{
    if(
is_user_alive(id))
    {
        if(
cs_get_user_team(id) == CS_TEAM_CT)
        {
            if(
equali(sample"weapons/bhit_flesh-1.wav") || equali(sample"weapons/bhit_flesh-2.wav") || equali(sample"weapons/bhit_flesh-3.wav"))
            {
                
engfunc(EngFunc_EmitSoundidCHAN_STATICsound_damage[random(sizeof(sound_damage))], 1.0ATTN_NORM0PITCH_NORM)
            }
        }
    }



jimaway 07-05-2012 08:20

Re: where is the problem
 
Code:
public plugin_precache() {     for (new i = 0; i < sizeof(sound_damage); i++)     {         precache_sound(sound_damage[i])     } }


All times are GMT -4. The time now is 15:14.

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