Shutdown: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 9: Line 9:
bool shutdown ( [ string reason = "No reason specified" ] )         
bool shutdown ( [ string reason = "No reason specified" ] )         
</syntaxhighlight>  
</syntaxhighlight>  
{{New items|3.0159|1.5.8|
{{Added feature/item|1.5.9|1.5.8|20915|
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool shutdown ( [ string reason = "No reason specified", number exitCode = 0 ] )         
bool shutdown ( [ string reason = "No reason specified", number exitCode = 0 ] )         
Line 17: Line 17:
===Optional Arguments===
===Optional Arguments===
*'''reason:''' the reason why the server has been shutdown.
*'''reason:''' the reason why the server has been shutdown.
{{New items|3.0159|1.5.8|
{{Added feature/item|1.5.9|1.5.8|20915|
*'''exitCode:''' the server application exit code to be returned on shutdown.
*'''exitCode:''' the server application exit code to be returned on shutdown.
|20915}}
|20915}}

Revision as of 21:26, 23 September 2021

This function shuts down the server.

Make sure your server ACL setup has function.shutdown object protected.

Syntax

bool shutdown ( [ string reason = "No reason specified" ] )         
bool shutdown ( [ string reason = "No reason specified", number exitCode = 0 ] )         

Optional Arguments

  • reason: the reason why the server has been shutdown.
  • exitCode: the server application exit code to be returned on shutdown.

Returns

Returns false if it was not possible to shut down the server.

Example

This command shuts down the server on request

addCommandHandler ( "shutdown", function ( player, command, reason )
  if ( hasObjectPermissionTo ( player, "function.shutdown" ) ) then
    shutdown ( reason or "" )
  end
end )

See Also