Forum

> > CS2D > Scripts > sv_sound doesn't work in my script
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch sv_sound doesn't work in my script

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt sv_sound doesn't work in my script

JugadorXEI
User Off Offline

Zitieren
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!

alt Re: sv_sound doesn't work in my script

mafia_man
User Off Offline

Zitieren
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

alt It works!

JugadorXEI
User Off Offline

Zitieren
user mafia_man hat geschrieben
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:
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht