Jump to content

Delay() function


SheriFF

Recommended Posts

Posted

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)

Posted
5 hours ago, Mr.Solo said:

It would be better if we added timer to Client commands! like /settimer 10000 reconnect

THIS IS WHAT I ALWAYS WANTED

with binds though, like

bind 1 f hi

bind 1 setTimer(f hi, 100) <-:Oed the syntax, you got it

Posted
2 hours ago, Gourmet. said:

THIS IS WHAT I ALWAYS WANTED

with binds though, like

bind 1 f hi

bind 1 setTimer(f hi, 100) <-:Oed the syntax, you got it

 

It'd actually be possible to script this very easily.

Posted
On 5/2/2017 at 14:02, Gourmet. said:

THIS IS WHAT I ALWAYS WANTED

with binds though, like

bind 1 f hi

bind 1 setTimer(f hi, 100) <-:Oed the syntax, you got it

That would allow people to hack servers easily...

Posted
30 minutes ago, Simple01 said:

That would allow people to hack servers easily...

Yep, but getting this feature working like a delayed bind, not setting timers with the functions could make it work.

  • MTA Team
Posted

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 

 

  • Recently Browsing   0 members

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