WasEventCancelled: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
{{Deprecated}} | |||
This function checks whether or not ''the currently active event'' has been canceled. This is mainly useful for custom events created by scripts. | This function checks whether or not ''the currently active event'' has been canceled. This is mainly useful for custom events created by scripts. | ||
Revision as of 11:06, 17 January 2008
This function is deprecated. This means that its use is discouraged and that it might not exist in future versions, but there should be a more generic way to perform what it does. | |
This function checks whether or not the currently active event has been canceled. This is mainly useful for custom events created by scripts.
Events can be cancelled using cancelEvent, this indicates that the resource that triggered the event should do whatever it can to reverse any changes made by whatever caused the event. See triggerEvent for a more detailed explanation of this.
Syntax
bool wasEventCancelled ( )
Returns
Returns true if the event was canceled, false if it wasn't or doesn't exist.
Example
This example implements a custom event onFlagPickup that would be triggered if an onMarkerHit event was triggered on a marker whose parent was a flag element. If the event isn't canceled then an element data value is set on the player.
addEvent ( "onFlagPickup", "thePlayer" ) function flagHitcheck ( thePlayer ) parentElement = getElementParent ( source ) -- get the parent of the marker if ( getElementType ( parentElement ) == "flag" ) then -- if it was a flag element then triggerEvent ( "onFlagPickup", source, thePlayer ) -- trigger our onFlagPickup event if ( not wasEventCancelled() ) then -- if the handler for the event didn't cancel it then setElementData ( thePlayer, "hasFlag", true ) -- set that the player picked up the flag end end end addEventHandler ( "onMarkerHit", getRootElement(), flagHitCheck )
See Also
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled