RestartResource: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{Server function}}
{{Server function}}
__NOTOC__
__NOTOC__
This function restarts a running resource.
This function restarts a running resource.<br>
'''Note:''' This function does not restart the resource immediately, so don't expect that stops or starts until [[onResourceStop]] and [[onResourceStart]] events for that resource is called. This happens after the scripts are done executing for this server frame.


==Syntax==  
==Syntax==  

Revision as of 03:29, 5 January 2008

This function restarts a running resource.
Note: This function does not restart the resource immediately, so don't expect that stops or starts until onResourceStop and onResourceStart events for that resource is called. This happens after the scripts are done executing for this server frame.

Syntax

bool restartResource ( resource theResource )

Required Arguments

  • theResource: the resource you want to restart.

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