• Stoping PlaySound.
    9 replies, posted
What is the most effective way to stop a surface.PlaySound?
Just use a [URL=http://wiki.garrysmod.com/?title=Csoundpatch]CSoundPatch[/URL] instead?
No idea how to use that lol, I'm just adding some spawn music to a game mode
[QUOTE=101kl;21284477]No idea how to use that lol, I'm just adding some spawn music to a game mode[/QUOTE] 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?
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: [b]Code: [/b] [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
Sorry, you need to Log In to post a reply to this thread.