Shutdown: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Server client function}}
{{Server function}}
__NOTOC__
__NOTOC__
This function shuts down the server.  
This function shuts down the server.  
Line 7: Line 7:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool shutdown ( string reason )         
bool shutdown ( [ string reason = "No reason specified" ] )         
</syntaxhighlight>  
</syntaxhighlight>  
{{Added feature/item|1.5.9|1.5.8|20915|
<syntaxhighlight lang="lua">
bool shutdown ( [ string reason = "No reason specified", number exitCode = 0 ] )       
</syntaxhighlight>
|20915}}


===Required Arguments===  
===Optional Arguments===
*'''reason:''' the reason why the server has been shut down.
*'''reason:''' the reason why the server has been shutdown.
{{Added feature/item|1.5.9|1.5.8|20915|
*'''exitCode:''' the server application exit code to be returned on shutdown.
|20915}}


===Returns===
===Returns===
Line 19: Line 27:
This command shuts down the server on request
This command shuts down the server on request
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler ( "shutdown", function ( player, command, reason ) )
addCommandHandler ( "shutdown", function ( player, command, reason )
   if ( hasObjectPermissionTo ( player, "function.shutdown" ) ) then
   if ( hasObjectPermissionTo ( player, "function.shutdown" ) ) then
     shutdown ( reason or "" )
     shutdown ( reason or "" )

Latest 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