• How to delay this function?
    1 replies, posted
Can someone quickly help me on delaying this function. [CODE]local function PlayMusic(wintype) if wintype == WIN_INNOCENT then BroadcastLua('surface.PlaySound("inowon'..math.random(1,3)..'.wav")') elseif wintype == WIN_TRAITOR then BroadcastLua('surface.PlaySound("trawon'..math.random(1,3)..'.wav")') elseif wintype == WIN_TIMELIMIT then BroadcastLua('surface.PlaySound("timelimitreached.wav")') end end hook.Add("TTTEndRound", "MyMusic", PlayMusic)[/CODE] I want it to start 2 seconds after the round has ended because it conflicts with something else. I tried timer.Simple( 2, PlayMusic ) but I don't know if i put it in the right place or if it would work seeing how the function works by itself. Can someone help me? [highlight](User was banned for this post ("wrong section" - Gran PC))[/highlight]
Can't see why a timer wouldn't work, try this [lua]local function PlayMusic(wintype) timer.Create("TTTSound", 2, 1, function() if wintype == WIN_INNOCENT then BroadcastLua('surface.PlaySound("inowon'..math.random(1,3)..'.wav")') elseif wintype == WIN_TRAITOR then BroadcastLua('surface.PlaySound("trawon'..math.random(1,3)..'.wav")') elseif wintype == WIN_TIMELIMIT then BroadcastLua('surface.PlaySound("timelimitreached.wav")') end end) end hook.Add("TTTEndRound", "MyMusic", PlayMusic) [/lua]
Sorry, you need to Log In to post a reply to this thread.