OnShutdown: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ {{Server event}} {{New feature/item|3.161|1.6.0|22837|This event is triggered when the server is about to be stopped using the server console or the shutdown function.}} ==Parameters== <syntaxhighlight lang="lua"> resource theResource, string reason </syntaxhighlight> *'''theResource:''' The resource that stops the server using the shutdown function. If the server is being stopped from the console, the '''resource''' is set to '''nil'''. *'''reaso...") |
m (→Example) |
||
(One intermediate revision by the same user not shown) | |||
Line 2: | Line 2: | ||
{{Server event}} | {{Server event}} | ||
{{New feature/item|3.161|1.6.0|22837|This event is triggered when the server is about to be stopped using the server console or the [[shutdown]] function.}} | {{New feature/item|3.161|1.6.0|22837|This event is triggered when the server is about to be stopped using the server console or the [[shutdown]] function.}} | ||
{{Note|There is no 100% guarantee that all the code and operations executed in this event will finish before the server is stopped. Therefore, avoid complex actions like triggers or exports, as there may not be enough time to complete the operations and execute the full code}} | |||
==Parameters== | ==Parameters== | ||
Line 18: | Line 20: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | |||
addEventHandler('onShutdown', root, function(resource, reason) | |||
outputServerLog("Server shutdown by resource: "..(resource and getResourceName(resource) or "Unknown").." Reason: "..reason) | |||
end) | |||
</syntaxhighlight> | |||
{{See also/Server event|Server events}} | {{See also/Server event|Server events}} |
Latest revision as of 02:08, 22 December 2024
Parameters
resource theResource, string reason
- theResource: The resource that stops the server using the shutdown function. If the server is being stopped from the console, the resource is set to nil.
- reason: The reason for stopping the server (if provided).
Source
The source of this event is root.
Cancel effect
This event cannot be canceled.
Example
addEventHandler('onShutdown', root, function(resource, reason) outputServerLog("Server shutdown by resource: "..(resource and getResourceName(resource) or "Unknown").." Reason: "..reason) end)
See Also
Server events
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled