RestartResource: Difference between revisions
(add oop syntax) |
(Added missing parameters) |
||
Line 7: | Line 7: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool restartResource ( resource theResource ) | bool restartResource ( resource theResource [, bool persistent = false, bool configs = true, bool maps = true, bool scripts = true, bool html = true, bool clientConfigs = true, bool clientScripts = true, bool clientFiles = true ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[resource]]:restart}} | {{OOP||[[resource]]:restart}} | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theResource:''' the [[resource]] you want to restart. | *'''theResource:''' the [[resource]] you want to restart. | ||
===Optional Arguments=== | |||
*'''persistent:''' Unused | |||
*'''configs:''' Reload configs? | |||
*'''maps:''' Reload maps? | |||
*'''scripts:''' Reload (server) scripts? | |||
*'''html:''' Reload html files (for resource web access)? | |||
*'''clientConfigs:''' Reload client configs? | |||
*'''clientScripts:''' Reload client scripts? | |||
*'''clientFiles:''' Reload files? | |||
===Returns=== | ===Returns=== |
Revision as of 22:04, 4 January 2016
This function restarts a running resource. Restarting will destroy all the elements that the resource has created (as stopping the resource does).
Note: This function does not restart the resource immediately. Restarts are queued up until the end of the server's frame to ensure that they occur in the correct order (and that dependent resources can start and stop correctly). The resource being restarted will have an onResourceStop event triggered and the restarted instance will receive an onResourceStart event. Remember that the element and resource variables will be invalidated during the restart, though of course, the resource's name will not.
Syntax
bool restartResource ( resource theResource [, bool persistent = false, bool configs = true, bool maps = true, bool scripts = true, bool html = true, bool clientConfigs = true, bool clientScripts = true, bool clientFiles = true ] )
OOP Syntax Help! I don't understand this!
- Method: resource:restart(...)
Required Arguments
- theResource: the resource you want to restart.
Optional Arguments
- persistent: Unused
- configs: Reload configs?
- maps: Reload maps?
- scripts: Reload (server) scripts?
- html: Reload html files (for resource web access)?
- clientConfigs: Reload client configs?
- clientScripts: Reload client scripts?
- clientFiles: Reload files?
Returns
Returns true if the resource was restarted, false if the restart failed, or an invalid resource was passed.
Example
This function restarts all running resources.
function restartAllResources() -- we store a table of resources local allResources = getResources() -- for each one of them, for index, res in ipairs(allResources) do -- if it's running, if getResourceState(res) == "running" then -- then restart it restartResource(res) end end end
See Also
- abortRemoteRequest
- call
- fetchRemote
- getResourceConfig
- getResourceDynamicElementRoot
- getResourceExportedFunctions
- getResourceFromName
- getResourceName
- getResourceRootElement
- getResourceState
- getThisResource
- getRemoteRequests
- getRemoteRequestInfo