Need help with 2 things

First thing, im trying to make a sound play every 900 seconds, here is my code



local tab = {
 "sound/announcement.mp3"
 }

function Purge()
sound.Play( "announcement.mp3", vPos )
end
timer.Create("soundemmit", 900, 0, Purge())


The code doesn’t run the song at all at 900 seconds

Secondly

I want to paint a timer on the HUD, which counts down 900 seconds,then 30 seconds, then 900 seconds then it loops

I didn’t start a script on that but i don’t know how to do it, If someone could help me out that would be amazing!

I hope this is the correct section, Im new here and im not sure if this is correct

That function is unnecessarily global. What is vPos defined as? Also, be sure that the file is being downloaded.

Remove the parenthesis from Purge() in the timer.

The file is downloaded to clients yeah,
I tried this code



local tab = {
 "sound/announcement.mp3"
 }

function Purge()
surface.PlaySound( "announcement.mp3" )
end
timer.Create("soundemmit", 900, 0, Purge())


That didn’t seem to work


timer.Create("soundemmit", 900, 0, Purge())

That should just be Purge, not Purge( ).

When you put Purge( ), you call the function, which in this case returns nothing - so the timer never runs your code since it thinks you sent it nothing.

OMFG THANKS SO MUCH

I have been working on that for like 3 days now lol

Now to see if anyone can help me out with the timer on the hud

[editline]4th August 2014[/editline]

Yeah i see that now xD

In your function Purge, do something like this:


NextRun = CurTime( ) + 900

And then, in your HUD, you can do


Remainder = math.Round( ( NextRun or CurTime( ) ) - CurTime( ) )
draw.DrawText( string.ToMinutesSeconds( Remainder ), font, ... )

There is more work involved if you are running this on the server - you’ll need to network the time to the client.

Should i reload my server when i put that code into my hud?

[editline]4th August 2014[/editline]

Can someone help me again

With the sound script, After 900 seconds i want to to play a different sound then loop, Can someone help me out with that?

[editline]4th August 2014[/editline]

Also is my current sound script server side?

[editline]4th August 2014[/editline]

Changed the function



BroadcastLua('surface.PlaySound("announcement.mp3")')
end


The bottom script gave me a lua error near …

Because it was an example. It’s not the whole function… http://wiki.garrysmod.com/page/draw/DrawText