IsResourceRunning: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:


==Syntax==  
==Syntax==  
*''isResourceRunning''' You can insert this code example in your resources.
*'''isResourceRunning''' You can insert this code example in your resources.


===Required Arguments===  
===Required Arguments===  

Revision as of 02:04, 2 April 2026

Syntax

  • isResourceRunning 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