OnResourceStop: Difference between revisions
Jump to navigation
Jump to search
m (Right revision number) |
mNo edit summary |
||
Line 15: | Line 15: | ||
*'''stoppedResource''': the [[resource]] that is being stopped. | *'''stoppedResource''': the [[resource]] that is being stopped. | ||
{{New items|3. | {{New items|3.0156|1.5.5| | ||
*'''wasDeleted''': a [[boolean]] representing whether the resource folder was deleted, moved or renamed. | *'''wasDeleted''': a [[boolean]] representing whether the resource folder was deleted, moved or renamed. | ||
|11854}} | |11854}} | ||
Line 36: | Line 36: | ||
This example only outputs message if the stopped resource is the same resource where the eventHandler is. | This example only outputs message if the stopped resource is the same resource where the eventHandler is. | ||
<syntaxhighlight lang="lua" > | <syntaxhighlight lang="lua" > | ||
addEventHandler ( "onResourceStop", resourceRoot, | addEventHandler( "onResourceStop", resourceRoot, | ||
function ( resource ) | function( resource ) | ||
outputChatBox ( "This resource has | outputChatBox( "This resource has stopped", root ) | ||
end | end | ||
) | ) | ||
Line 44: | Line 44: | ||
</section> | </section> | ||
==Changelog== | |||
{{ChangelogHeader}} | |||
{{ChangelogItem|1.5.5-3.11854|Added wasDeleted parameter}} | |||
{{See also/Server event|Resource events}} | {{See also/Server event|Resource events}} |
Revision as of 22:14, 5 July 2018
This event is triggered when the resource is stopped. This can occur for a number of reasons:
- The stop console command was used
- The restart console command was used
- The resource was modified (the resource will automatically restart)
- Another resource stopped it using stopResource.
Note: If you wish to just detect a single resource being stopped, you should attach handlers for this event to the resource's root element. You can access this using getResourceRootElement.
Parameters
resource stoppedResource
- stoppedResource: the resource that is being stopped.
- wasDeleted: a boolean representing whether the resource folder was deleted, moved or renamed.
Source
The source of this event is the root element of the resource that is being stopped.
Example
This example displays a message in the chatbox when a resource is stopped.
Click to collapse [-]
Example 1: ServeraddEventHandler ( "onResourceStop", root, function ( resource ) outputChatBox ( "The Resource " .. getResourceName(resource) .. " was stopped!", root, 255, 255, 255 ) end )
Click to collapse [-]
Example 2: ServerThis example only outputs message if the stopped resource is the same resource where the eventHandler is.
addEventHandler( "onResourceStop", resourceRoot, function( resource ) outputChatBox( "This resource has stopped", root ) end )
Changelog
Version | Description |
---|
1.5.5-3.11854 | Added wasDeleted parameter |
See Also
Resource events
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled