AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   playing a sound when a player die (https://forums.alliedmods.net/showthread.php?t=11805)

Cheap_Suit 03-28-2005 21:32

playing a sound when a player die
 
how do i play a certain sound when a player die in a certain model?

soo far:

Code:

public fdeath(id) {
       
        new model[33]
        cs_get_user_model(id, model, 32)

        if(equal(model, "model",5)) {

        emit_sound(id, CHAN_VOICE, "misc/die.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
       
        }else{
       
        }
        return PLUGIN_CONTINUE
}

public plugin_init() {
        register_event( "DeathMsg", "fdeath", "a" )
}

but i get this

L 03/28/2005 - 19:09:48: [AMXX] Native error in "cs_get_user_model" on some line (file "test.sma").
L 03/28/2005 - 19:09:48: [CSTRIKE] Player out of range (0)

any help or example would be greatly appreciated :wink:

XxAvalanchexX 03-28-2005 22:08

a) WTF is the else statement there for? I certainly don't see anything in it. Why is it there?

b) When you registered the event you register it as global ("a"), this means that all players receive it at once, meaning the id is going to be 0, and 0 is not a valid entity so you can't emit a sound from it. You have to use read_data(2) (if I recall correctly) to get the victim.

Cheap_Suit 03-29-2005 00:12

can you help me out? I dont know how to use read_data

xeroblood 03-29-2005 00:13

new id = read_data(2)

Cheap_Suit 03-29-2005 00:36

i got this
Code:

public death() {

        new id = read_data(2)

        new model[33]
        cs_get_user_model(id, model, 32)
       
        if(equal(model, "F_",2))
         
        emit_sound(id, CHAN_VOICE, "misc/die.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
       
}

but no it doesnt play the sound. please help me fix it

xeroblood 03-29-2005 12:26

Did you precache the sound file?


All times are GMT -4. The time now is 10:01.

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