IsResourceRunning: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Shared function}} ==Syntax== You can insert this code example in your resources. ===Required Arguments=== *'''isResourceRunning:''' The value to check resources ==Example== <section name="Example1" class="shared" show="true"> You can insert this code example in your resources. <syntaxhighlight lang="lua"> function isResourceRunning(resName) local res = getResourceFromName(resName) return (res) and (getResourceState(res) == "running") end -- Example o...")
 
Line 39: Line 39:


==See Also==
==See Also==
{{Resource}}
{{Resource_functions}}
[[ru:isBan]]
[[ru:isBan]]

Revision as of 02:03, 2 April 2026

Syntax

You can insert this code example in your resources.

Required Arguments

  • isResourceRunning: The value to check resources

Example

Click to collapse [-]
Example1

You can insert this code example in your resources.

function isResourceRunning(resName)
	local res = getResourceFromName(resName)
	return (res) and (getResourceState(res) == "running")
end

-- Example of inserting into system code:
--[[
if isResourceRunning("admin") then
   --code
else
   --alert
end
]]

addCommandHandler('pos', function (commandName)
    if isResourceRunning("admin") then
       local x,y,z = getElementPosition(localPlayer)
       outputChatBox( x ..', '.. y ..', '.. z, 255, 255, 255 )
    else
       outputChatBox("The resource is not running 'admin'.", 255, 0, 0)
    end
end )

See Also