Delay: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server & Client|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|Delay(Milliseconds, LuaFunction [, UserArgs])}} {{FuncParameters}} {{FuncParam|Millisecon..." |
No edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server & Client|1.0}} | {{Info|Function|Server & Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Create a delayed function just like a timer but only once. ([[DelayFor]])}} | ||
{{FuncSyntax|Delay(Milliseconds, LuaFunction [, UserArgs])}} | {{FuncSyntax|Delay(Milliseconds, LuaFunction [, UserArgs])}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|Milliseconds| | {{FuncParam|Milliseconds|The interval in milliseconds.}} | ||
{{FuncParam|LuaFunction| | {{FuncParam|LuaFunction|The Lua function to delay.}} | ||
{{FuncParamOptional|UserArgs| | {{FuncParamOptional|UserArgs (optional)|The user arguments.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns the id of this delay, same as for timers.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
AddEvent("OnPlayerSpawn", function(player) | |||
SetPlayerOutline(player, true) | |||
Delay(10000, function(player) | |||
SetPlayerOutline(player, false) | |||
end, player) | |||
end) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
*[[GetTimerCount]] | |||
*[[GetAllTimers]] | |||
*[[IsValidTimer]] | |||
*[[CreateTimer]] | |||
*[[CreateCountTimer]] | |||
*[[DestroyTimer]] | |||
*[[PauseTimer]] | |||
*[[UnpauseTimer]] | |||
*[[GetTimerRemainingTime]] |
Latest revision as of 15:03, 31 August 2020
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)