Functions are defined in your script as shown in this example:
<codedoc> Function IsItemASword( $itemNum ) {
if ( $itemNum = 112 ) // Sword { return( 1 ) } else if ( $itemNum = 113 ) // Sword 2 { return( 1 ) } return( 0 )
} </codedoc>
This example function would be called from another part of your script like this: <codedoc>
$isSword = IsItemASword( $gTaskItem1 )
</codedoc>
Functions can have any number of parameters, and always return a value.
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>
</codedoc>
would display My Custom Event has been triggered for Bob
.
*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..)