Stopsound for a certain user only
8 replies



04.06.20 08:19:07 pm
When you join my server you will hear a sound just for you:
And when you choose a look (skin) the sound will stop:
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?
Code:
1
2
3
4
2
3
4
addhook('join', 'SoundOnJoin')
function SoundOnJoin(id)
parse("sv_sound2 "..id.." music.ogg")
end
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
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
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?
It's weird how
sv_stopsound is "sv_stopsound <soundfile> <player>" but
sv_sound2 is "sv_sound2 <player> <soundfile>". Try swapping the parameters in your


parse("sv_stopsound "..id.." music.ogg")
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
Like this? Still doesn't work.
parse("sv_stopsound \"music.ogg\" "..id)
edited 1×, last 04.06.20 09:19:08 pm

It's weird how
sv_stopsound is "sv_stopsound <soundfile> <player>" but
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

I just improved the documentation accordingly.
@
DC: Can you also add that
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



