1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
addhook("say","onsay") function onsay(id,txt) if txt=="!start" then parse("sv_sound ZombieCrown/ambience1.wav") elseif txt=="!stop" then parse("sv_stopsound ZombieCrown/ambience1.wav 0") end end
but it's not working
addhook("say","onsay") function onsay(id,txt) if txt=="!start" then parse("sv_sound ZombieCrown/ambience1.wav") elseif txt=="!stop" then parse("sv_stopsound ZombieCrown/ambience1.wav 0") end end
addhook("say","onsay") function onsay(id,txt) if string.sub(txt,1,6)=="!start" then parse('sv_sound "ZombieCrown/ambience1.wav"') elseif string.sub(txt,1,5)=="!stop" then parse('sv_stopsound "ZombieCrown/ambience1.wav" 0') end end
local playing_sound_list = {} local function attempt_stop_sound(player) 	if playing_sound_list[player] then 		parse(string.format("sv_stopsound %q %d", playing_sound_list, player)) 		playing_sound_list[player] = nil 	end end function play_sound(path, player) 	if type(player) ~= "number" then 		for i = 1, 32 do 			attempt_stop_sound(i) 			playing_sound_list[i] = path 			parse(string.format("sv_sound %q", path)) 		end 	else 		attempt_stop_sound(player) 		playing_sound_list[player] = path 		parse(string.format("sv_sound2 %d %q", player, path)) 	end end
play_sound("sfx/path/to/audio.flac", 1)	-- Play only for ID 1 -- other part in your code -- play_sound("sfx/some_sound.ogg")	-- Play for all players and stop previous playing sound for ID 1
for i = 1, 32 do attempt_stop_sound(i) playing_sound_list[i] = path parse(string.format("sv_sound %q", path)) end
for _,i in pairs(player(0, "table")) do attempt_stop_sound(i) playing_sound_list[i] = path parse(string.format("sv_sound %q", path)) end
for i = 1,32 doand this looping method
for _,i in ipairs(player(0,"table"))are same.