Delay: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
 
Line 1: Line 1:
{{Info|Function|Server & Client|1.0}}
{{Info|Function|Server & Client|1.0}}


{{FuncDescription|Create a delayed function just like a timer but with once ([[DelayFor]])}}
{{FuncDescription|Create a delayed function just like a timer but only once. ([[DelayFor]])}}


{{FuncSyntax|Delay(Milliseconds, LuaFunction [, UserArgs])}}
{{FuncSyntax|Delay(Milliseconds, LuaFunction [, UserArgs])}}
Line 7: Line 7:
{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|Milliseconds|The interval in milliseconds.}}
{{FuncParam|Milliseconds|The interval in milliseconds.}}
{{FuncParam|LuaFunction|The lua function name}}
{{FuncParam|LuaFunction|The Lua function to delay.}}
{{FuncParamOptional|UserArgs (optional)|The user arguments}}
{{FuncParamOptional|UserArgs (optional)|The user arguments.}}


{{FuncReturnValue|Returns the id of this delay, same as for timers.}}
{{FuncReturnValue|Returns the id of this delay, same as for timers.}}
Line 18: Line 18:
Delay(10000, function(player)
Delay(10000, function(player)
SetPlayerOutline(player, false)
SetPlayerOutline(player, false)
end)
end, player)
end)
end)
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 15:03, 31 August 2020

Delay

Type: Function
Context: Server & Client
Introduced: v1.0

Description

Create a delayed function just like a timer but only once. (DelayFor)

Syntax

Delay(Milliseconds, LuaFunction [, UserArgs])

Parameters

  • Milliseconds
    The interval in milliseconds.
  • LuaFunction
    The Lua function to delay.
  • UserArgs (optional) (optional)
    The user arguments.

Return Value

  • Returns the id of this delay, same as for timers.

Example

AddEvent("OnPlayerSpawn", function(player)
	SetPlayerOutline(player, true)
	Delay(10000, function(player)
		SetPlayerOutline(player, false)
	end, player)
end)

See also