AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Sound won't play (https://forums.alliedmods.net/showthread.php?t=62933)

BigDontCry 11-07-2007 18:37

Sound won't play
 
I want to play a sound file (wav) for a client when he gains XP in a mod I'm working on... But the sound won't play (or atleast I can't hear it)...

Here's my hook_death code:
PHP Code:

public hook_death() {
 new 
Killer read_data(1)
 new 
Victim read_data(2)
 
 new 
KillerName[32], VictimName[32]
 
get_user_name(KillerKillerName31)
 
get_user_name(VictimVictimName31)
 
 if(
is_user_connected(Killer) && !is_user_alive(Victim)) {
  
p_xp[Killer] += XP_PER_KILL
  client_print
(Killerprint_chat"[%s] %s recieved %d XP for killing %s"MODKillerNameXP_PER_KILLVictimName)
 
  
emit_sound(Killer,CHAN_ITEM"sound/mymod/gainxp.wav"1.0ATTN_NORM0PITCH_NORM)
 } 

...and yeah, the wav file exist... ;)

Arkshine 11-07-2007 18:46

Re: Sound won't play
 
"sound/mymod/gainxp.wav"

No need to specify 'sound/' folder with *.wav sounds.

Code:
emit_sound(Killer,CHAN_ITEM, "mymod/gainxp.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)

BigDontCry 11-07-2007 18:54

Re: Sound won't play
 
Quote:

Originally Posted by arkshine (Post 550642)
"sound/mymod/gainxp.wav"

No need to specify 'sound/' folder with *.wav sounds.


Code:
</p><p>emit_sound(Killer,CHAN_ITEM, "mymod/gainxp.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)</p><p>

I've tried that also, same result... no error messages in console or anything like that...
I'm thinking set_task(0.5, "play_gainxp_sound", Killer) or something?

Arkshine 11-07-2007 19:20

Re: Sound won't play
 
Try using CHAN_AUTO.

Also, be sure that the sound gainxp.wav exists in sound/mymod/ folder.

BigDontCry 11-07-2007 19:39

Re: Sound won't play
 
Quote:

Originally Posted by arkshine (Post 550653)
Try using CHAN_AUTO.

Yep, that worked... Thanks alot!

BigDontCry 11-08-2007 16:48

Re: Sound won't play
 
I have another question about this...
First of all, why can't I use CHAN_ITEM? It should work... The next thing is; if I want to play a sound from the Valve/sound directory it won't work either, why is that?

I'm playing and coding for CZ btw...


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

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