IsResourceRunning

From Multi Theft Auto: Wiki
Revision as of 02:05, 2 April 2026 by Flox (talk | contribs) (→‎Example)
Jump to navigation Jump to search

Syntax

  • isResourceRunning You can insert this code example in your resources.

Required Arguments

  • isResourceRunning: The value to check resources

Example check isResourceRunning(resName)

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