From Multi Theft Auto: Wiki
Revision as of 04:47, 11 August 2019 by Danilo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function stops a running resource.

[[{{{image}}}|link=|]] 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.


bool stopResource ( resource theResource )

OOP Syntax Help! I don't understand this!

Method: resource:stop(...)

Required Arguments

  • theResource: the resource that should be stopped.


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


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

See Also