Forum

> > CS2D > Scripts > sv_sound doesn't work in my script
Forums overviewCS2D overview Scripts overviewLog in to reply

English sv_sound doesn't work in my script

3 replies
To the start Previous 1 Next To the start

old sv_sound doesn't work in my script

JugadorXEI
User Off Offline

Quote
Hello! I'm trying to do a LUA script that plays a song when someone joins, but it seems to be not working and I don't know what's wrong in the code (obviously).

The weird part, it's the error.

1
ERROR: cannot play sound "sfx/gameover.mp31" - file does not exist (sv_sound)

And I didn't put "gameover.mp31", I did put "gameover.mp3"

Code:
1
2
3
4
addhook("join", "gameover")
function gameover(soundfile)
     parse("sv_sound gameover.mp3"..soundfile)
end

If someone could help me fixing my code would be great (:

Thanks for reading!

old Re: sv_sound doesn't work in my script

mafia_man
User Off Offline

Quote
You're doing it wrong.

Here's working script:
1
2
3
4
5
6
playsound = {"sfx/hostage/hos1.wav", "sfx/hostage/hos2.wav"};

addhook("join", "onJoin")
function onJoin(id)
	parse("sv_sound ".. playsound[math.random(1,#playsound)]);
end

old It works!

JugadorXEI
User Off Offline

Quote
user mafia_man has written
You're doing it wrong.

Here's working script:
1
2
3
4
5
6
playsound = {"sfx/hostage/hos1.wav", "sfx/hostage/hos2.wav"};

addhook("join", "onJoin")
function onJoin(id)
	parse("sv_sound ".. playsound[math.random(1,#playsound)]);
end


Many thanks, it did work!

Have a nice day c:
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview