English Stopsound for a certain user only

8 replies
Goto Page
To the start Previous 1 Next To the start
Up
mrc
User
Offline Off
When you join my server you will hear a sound just for you:

Code:
1
2
3
4
addhook('join', 'SoundOnJoin')
function SoundOnJoin(id)
     parse("sv_sound2 "..id.." music.ogg")
end


And when you choose a look (skin) the sound will stop:

Code:
1
2
3
4
5
6
addhook("team","stopsound")
function stopsound(id,team,look)
     if look >= 0 then
          parse("sv_stopsound "..id.." music.ogg")
     end
end


But the problem is, if I'm listening the music and OTHER player joins and select a look (skin) the sound stop for me but it may stop just for him. Anyone knows how to fix this?
IMG:https://cdn.discordapp.com/attachments/1048445028361584671/1064255558372302979/cs2dbr.png
04.06.20 08:43:16 pm
Up
TrialAndError
User
Offline Off
It's weird how cs2d cmd sv_stopsound is "sv_stopsound <soundfile> <player>" but cs2d cmd sv_sound2 is "sv_sound2 <player> <soundfile>". Try swapping the parameters in your
parse("sv_stopsound "..id.." music.ogg")
04.06.20 08:49:34 pm
Up
mrc
User
Offline Off
This parameter is wrong and doesn't work:

Code:
1
parse("sv_stopsound music.ogg "..id)
edited 2×, last 04.06.20 09:18:49 pm
IMG:https://cdn.discordapp.com/attachments/1048445028361584671/1064255558372302979/cs2dbr.png
04.06.20 08:51:38 pm
Up
TrialAndError
User
Offline Off
you need quotes around the soundfile in cs2d cmd sv_stopsound
04.06.20 08:56:06 pm
Up
mrc
User
Offline Off
Like this? Still doesn't work.

parse("sv_stopsound \"music.ogg\" "..id)
edited 1×, last 04.06.20 09:19:08 pm
IMG:https://cdn.discordapp.com/attachments/1048445028361584671/1064255558372302979/cs2dbr.png
04.06.20 09:02:03 pm
Up
TrialAndError
User
Offline Off
Code:
1
parse("sv_stopsound \"music.ogg\" "..id)


Works great for me
04.06.20 09:11:11 pm
Up
mrc
User
Offline Off
Wtf, now it just worked for no reason. ty
IMG:https://cdn.discordapp.com/attachments/1048445028361584671/1064255558372302979/cs2dbr.png
04.06.20 10:03:12 pm
Up
DC
Admin
Offline Off
user TrialAndError has written:
It's weird how cs2d cmd sv_stopsound is "sv_stopsound <soundfile> <player>" but cs2d cmd sv_sound2 is "sv_sound2 <player> <soundfile>". Try swapping the parameters in your
parse("sv_stopsound "..id.." music.ogg")

Yes, it's weird and confusing. I agree.
The reason for the swapped parameter order is that cs2d cmd sv_stopsound originally had only one parameter. The second parameter (player) has been added later on. I always have to append new parameters to the end to keep commands compatible with existing scripts.

I just improved the documentation accordingly.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
04.06.20 10:54:19 pm
Up
TrialAndError
User
Offline Off
@user DC: Can you also add that cs2d cmd sv_stopsound needs quotes (specifically double quotes) for the soundfile parameter for it to actually do anything.
edited 1×, last 04.06.20 11:13:16 pm
To the start Previous 1 Next To the start