User Tools

Site Tools


scripting:functions_custom_events_overview

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
scripting:functions_custom_events_overview [2012/03/25 18:36] mitscripting:functions_custom_events_overview [2025/05/28 16:34] (current) – external edit 127.0.0.1
Line 27: Line 27:
 The 'Sleep' command cannot be used from within a function. The 'Sleep' command cannot be used from within a function.
 </note> </note>
 +
 +===== Custom Events =====
 +You can add your own custom events, and then trigger them from a command. (And hence, you can trigger custom events from within other events). When you trigger a custom event in your script, the new event is executed immediately and the main event waits until it completes or when the new event sleeps.
 +
 +A custom event is defined as shown:
 +
 +<codedoc>
 +   Event( "Custom", "YourCustomEventName" )
 +   {
 +      *say My Custom Event has been triggered for %PLAYER%
 +   }
 +</codedoc>
 +
 +This custom event can be triggered using the command ''*event'' or ''*eventallonline'' (''*eao'' for short). e.g.
 +<codedoc>
 +   *event Bob YourCustomEventName
 +</codedoc>
 +would display ''My Custom Event has been triggered for Bob''.
 +
 +<note important>
 +Be very careful with events calling other events, particularly when using ''*eventallonline'' or ''Sleep''s. Many commands (''*addbackgroundmodel'' for instance) replicate to everyone present, so mistakenly having an event triggered for all players can produce confusing and nasty side-effects. (e.g. For ''*addbackgroundmodel'', duplicate models would be added to the map multiple times and the server could waste an awful lot of your bandwidth telling everyone about again and again..)
 +</note>
 +
 +
 +
 +
 +
 +
 +
scripting/functions_custom_events_overview.1332700600.txt.gz · Last modified: (external edit)