Difference between revisions of "Engine.RestartResource"

From Tomb Raider Mod Launcher Wiki
Jump to navigation Jump to search
(Created page with "== Function == <syntaxhighlight lang="javascript"> function bool Engine.RestartResource(resourceName); </syntaxhighlight> === Arguments === * resourceName ** The name of th...")
 
 
Line 19: Line 19:
  
 
Then the function returns if the server was able to start the resource, possible reasons could include scripts containing errors.
 
Then the function returns if the server was able to start the resource, possible reasons could include scripts containing errors.
 +
 +
=== Example ===
 +
 +
<syntaxhighlight lang="javascript">
 +
 +
// Add a handler for "restart" to that we can restart a resource using the chatbox.
 +
// It would be a good idea to check if the user is allowed to do so when possible.
 +
// It would also be a good idea to check the number of arguments in the array to prevent errors.
 +
//
 +
Engine.AddCommandHandler("restart",function(player, commandLine, command, arguments){
 +
Engine.RestartResource(arguments[0]);
 +
});
 +
 +
</syntaxhighlight>
  
 
== Notes ==
 
== Notes ==
  
 
If the resource doesn't exist then an error is thrown.
 
If the resource doesn't exist then an error is thrown.

Latest revision as of 06:59, 12 August 2014

Function

function bool Engine.RestartResource(resourceName);

Arguments

  • resourceName
    • The name of the resource to restart.

Description

This function will attempt to restart the resource.

Returns

If the resource is currently stopped the function will return false.

Then the function returns if the server was able to start the resource, possible reasons could include scripts containing errors.

Example

// Add a handler for "restart" to that we can restart a resource using the chatbox.
// It would be a good idea to check if the user is allowed to do so when possible.
// It would also be a good idea to check the number of arguments in the array to prevent errors.
//
Engine.AddCommandHandler("restart",function(player, commandLine, command, arguments){
	Engine.RestartResource(arguments[0]);
});

Notes

If the resource doesn't exist then an error is thrown.