Munkdev I believe posted this to stop sounds playing (if it was someone else, apologies and please let me know). Should also work for PlaySoundFile():
Lua Code:
local mutex = false -- need this so it doesn't recurse when PlaySound is called from within
hooksecurefunc('PlaySound', function(id)
if mutex then return end -- we called this time, just return
mutex = true -- flag mutex
-- play another sound to figure out the ID.
-- can't play the same sound because it's occupied by another handle.
local played, handle = PlaySound(id+1) -- just use the ID+1 to guarantee it's different
mutex = false -- unflag mutex
if played then
StopSound(handle-1) -- stop the sound you wanted to stop in the first place
StopSound(handle) -- stop your dummy sound
end
end)
-- Stop playsound from a specific function
hooksecurefunc("BNToastFrame_Show", function()
local played, handle = PlaySound(SOUNDKIT.AMB_GLUESCREEN_WORGEN)
StopSound(handle-1)
StopSound(handle)
end)
There's no pause/restart functions.