Stoping PlaySound.

What is the most effective way to stop a surface.PlaySound?

Just use a CSoundPatch instead?

No idea how to use that lol, I’m just adding some spawn music to a game mode

Click the link and read the wiki. Be enlightened.

Well it seems simple enough but it doesn’t give many examples, so would one of you be inclined so as to give an example for a replacement for:
[lua]surface.PlaySound( “pubgamer/Strings.mp3” )[/lua]

[lua]
local csp = CreateSound(LocalPlayer(), “pubgamer/Strings.mp3”)
csp:Play()
[/lua]
csp:Stop() to stop the sound.

So in theory this should work right?
[lua]
roundmusic={
“pubgamer/Prison_break/1.mp3”,
“pubgamer/Prison_break/2.mp3”
}
function shit
local rmusic = CreateSound(LocalPlayer(),(table.Random(roundmusic), 500, 200))
rmusic:Play()-- Start Round Music
end
[/lua]
I tried it and it didn’t play anything. Console gave no errors.
Any ideas?

Multiple errors with that one.

[lua]
local roundmusic= {
“pubgamer/Prison_break/1.mp3”,
“pubgamer/Prison_break/2.mp3”
}

function shit()
local rmusic = CreateSound(LocalPlayer(), table.Random(roundmusic))
rmusic:Play() – Start Round Music
end
hook.Add(“PlayerSpawn”, “Hurr”, shit)
[/lua]
[URL=“file:///C:/srcds/orangebox/garrysmod/gamemodes/perp/content/materials/”]

Still didn’t work. Still not printing errors.
[lua]
function GM:PlayerInitialSpawn( pl )
pl:SetTeam( TEAM_SPECTATOR )
local spawnmusic = CreateSound(LocalPlayer(), “pubgamer/Prison_break/1.mp3”)
spawnmusic:Play()-- Start Spawn Music
end
[/lua]
Maybe you can help with this one?
Same problem. Doesn’t play and no errors are printed.

Try this:

**Code: ** [lua]local soundpath = “pubgamer/1.mp3”

function play_on_spawn(ply)
local spawnmusic = CreateSound(ply, soundpath)
spawnmusic:Play()
end

hook.Add(“PlayerSpawn”, “play_on_spawn”, play_on_spawn)[/lua]

I don’t tested it!

You have to load it Server Side