Notify / Endon / Waittill

From COD Modding & Mapping Wiki
Share/Save/Bookmark
Jump to: navigation, search
Nutshell.png
These 3 functions allow you to make a script wait for specific events and then trigger those events in different parts of the scripts.

Notify / Endon / Waittill

This one ends the function it is inside when 'thread_restart' is triggered on 'level':

level endon ("thread_restart");

and this triggers the 'killed_player' notification on 'self' (which is a player in this case):

self notify("killed_player");

If you use 'player waittill("x")' or 'player endon("x")', then using a 'level notify("x")' will not trigger either of them - level is not the same entity as player, and all entities' triggers are independant.

Using the functions is easy. Firstly, decide which entity you want to wait for the trigger on. This is a player most of the time, but if you want a global trigger then use 'level'.

Then you must decide which trigger to use. You can choose either "endon" or "waittill" - they are both self explanatory, one will end the function it is running in when triggered, and the other will 'wait' until the specified trigger.


Next you decide on a unique name for the trigger. For example...

level endon("a_unique_call");

And to activate this trigger, you use notify on the same entity (level):

level notify("a_unique_call");

You can use as many waittill and endon functions as you want on an entity, in different functions. They will all be triggered by a notify.

Here is a quick example of it in use in multiple threads in the DM gametype...

 spawnPlayer()
 {
   self notify("spawned");
   
   /*... Code snipped ... this is another type of 
   comment that can span multiple lines. */
   
 }

 Callback_PlayerKilled(attacker, some other arguments)
 {
   self endon("spawned"); //this makes callback_playerkilled() terminate when "spawned" is triggered in spawnplayer().
 }