Skip to content

getResourceState

Shared

Manual Review Required

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


This function returns the state of a given resource

OOP Syntax Help! I don't understand this!

  • Method:resource:getState(...)
  • Variable: .state

Syntax

string getResourceState ( ​resource theResource )
Required arguments
  • theResource: The resource you wish to get the state of.

Returns

If successful returns a string with the resource state in it, false otherwise. The state can be one of:

  • string: value

Code Examples

shared

This example returns the state of a given resource. Syntax:/state

function getState( player, command, resourceName )
if not resourceName then
outputChatBox( "Syntax: " .. command .. " [resource name]", player, 255, 0, 0 )
return
end
local resource = getResourceFromName( resourceName )
if not resource then
outputChatBox( "Error: No resource with name " .. resourceName .. " exists.", player, 255, 0, 0 )
return
end
local state = getResourceState( resource )
outputChatBox( "Resource " .. resourceName .. " is " .. state, player, 0, 0, 255 )
end
addCommandHandler( "state", getState )