StopResource: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__
{{Server function}}
This function stops a running resource.
This function stops a running resource.


Line 17: Line 18:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function stopAllResources()
function stopAllResources()
--we store a table of resources
-- we store a table of resources
local allResources = getResources()
local allResources = getResources()
--for each one of them,
-- for each one of them,
for index, resource in ipairs(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
--then stop it
-- then stop it
stopResource(resource)
stopResource(resource)
end
end

Revision as of 18:41, 15 August 2007

This function stops a running resource.

Syntax

bool stopResource ( resource theResource )

Required Arguments

  • theResource: the resource we want to stop.

Returns

Returns true if the resource was stopped, false if the stopping failed, or an invalid resource was passed.

Example

This function stops all running resources.

function stopAllResources()
	-- 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 stop it
			stopResource(resource)
		end
	end
end

See Also