onShutdown | Multi Theft Auto: Wiki Skip to content

onShutdown

Client-side
Server-side
Shared

This event is triggered when the server is about to be stopped using the server console or the shutdown function.

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

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

element: The source of this event is root.

Canceling

This event cannot be canceled.

Code Examples

server
addEventHandler('onShutdown', root, function(resource, reason)
outputServerLog("Server shutdown by resource: "..(resource and getResourceName(resource) or "Unknown").." Reason: "..reason)
end)