stopResource | Multi Theft Auto: Wiki Skip to content

stopResource

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function stops a running resource.

Note

This function does not stop the resource immediately, so don't expect that it starts stopping until the onResourceStop event for that resource is triggered. This happens after the scripts are done executing for this server frame.

Syntax

stopResource ( )

Code Examples

server

This function stops all running resources except the current one.

function stopAllResources()
-- we store a table of resources
local allResources = getResources()
-- for each one of them,
for i, resource in ipairs(allResources) do
-- if it's running, and it is not the current resource
if ( getResourceState(resource) == "running" ) and ( resource ~= getThisResource() ) then
-- then stop it
stopResource(resource)
end
end
end