RestartResource: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 20: Line 20:
local allResources = getResources()
local allResources = getResources()
--for each one of them,
--for each one of them,
for index, resource in allResources do
for index, resource in ipairs(allResources) do
--if it's running,
--if it's running,
if getResourceState(resource) == "running" then
if getResourceState(resource) == "running" then

Revision as of 22:19, 6 May 2007

This function restarts a running resource.

Syntax

bool restartResource ( resource theResource )

Required Arguments

  • theResource: the resource we 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, resource in ipairs(allResources) do
		--if it's running,
		if getResourceState(resource) == "running" then
			--then restart it
			restartResource(resource)
		end
	end
end

See Also