OnResourceLoadStateChange: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
{{Server event}}
{{Server event}}
{{New feature/item|3.0159|1.5.8|20809|This event is triggered when a [[resource]] load state is changed.}}
{{Added feature/item|3.0159|1.5.9|1.5.8|20809|This event is triggered when a [[resource]] load state is changed.}}
__NOTOC__
__NOTOC__
==Parameters==
==Parameters==
Line 7: Line 7:
</syntaxhighlight>  
</syntaxhighlight>  


*'''changedResource''': the [[resource]] that was either loaded, reloaded or is unloading.
*'''changedResource''': The [[resource]] that was either loaded, reloaded or is unloading.
*'''oldState''': the state the [[resource]] was in before it changed.
*'''oldState''': The state the [[resource]] was in before it changed.
*'''newState''': the state the [[resource]] has changed to.
*'''newState''': The state the [[resource]] has changed to.


==Source==
==Source==
Line 15: Line 15:


==Example==
==Example==
<section name="Example 1" class="server" show="true">
This code will output the state of resource when it's state will be changed:
This code will output the state of resource when it's state will be changed.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function onResourceLoadStateChange(resource, oldState, newState)
function onResourceLoadStateChange (resource, oldState, newState)
print("Resource "..getResourceName(resource).." has changed it's state from "..tostring(oldState).." to "..tostring(newState))
    print ("Resource "..getResourceName (resource).." has changed it's state from "..tostring (oldState).." to "..tostring (newState))
end
end
addEventHandler("onResourceLoadStateChange", root, onResourceLoadStateChange)
 
addEventHandler ("onResourceLoadStateChange", root, onResourceLoadStateChange)
</syntaxhighlight>
</syntaxhighlight>
</section>
 
==Requirements==
{{Requirements|1.5.8-9.20809|n/a|}}


{{See also/Server event|Resource events}}
{{See also/Server event|Resource events}}

Revision as of 11:38, 20 September 2021

20809

Parameters

resource changedResource, string oldState, string newState
  • changedResource: The resource that was either loaded, reloaded or is unloading.
  • oldState: The state the resource was in before it changed.
  • newState: The state the resource has changed to.

Source

The source of this event is the root element.

Example

This code will output the state of resource when it's state will be changed:

function onResourceLoadStateChange (resource, oldState, newState)
    print ("Resource "..getResourceName (resource).." has changed it's state from "..tostring (oldState).." to "..tostring (newState))
end

addEventHandler ("onResourceLoadStateChange", root, onResourceLoadStateChange)

Requirements

Minimum server version 1.5.8-9.20809
Minimum client version n/a

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.5.8-9.20809" />

See Also

Resource events


Event functions