Jump to content

Delay() function


SheriFF

Recommended Posts

I'd like to sugest a delay() function because, in my opinion, it will be helpful and it will save you from using plenty of setTimers or any function like that.

How can this function can be helpful?:

  • Delay between two actions( switching two images )
  • Some interesting effects etc...

(I'm sorry if this kind of function exists, i didn't notice it)

Link to comment
  • MTA Team

You can already do this with Lua coroutines.

function pausableFunction(co)
	if not co then 
		co = coroutine.create(pausableFunction)
		coroutine.resume(co, co)
		return 
	end
	
	local function resume()
		coroutine.resume(co)
	end
	
	local function wait(time)
		setTimer(resume, time, 1)
	end 
	
	outputChatBox("Countdown!")
	outputChatBox("3...")
	wait(1000)
	outputChatBox("2...")
	wait(1000)
	outputChatBox("1...")
	wait(1000)
	outputChatBox("Go!")
end 

 

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...