Notify / Endon / Waittill: Difference between revisions

From COD Modding & Mapping Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
Line 1: Line 1:
== [[Notify / Endon / Waittill]] ==
{{Note|These 3 functions allow you to make a script wait for specific events and then trigger those events in different parts of the scripts.}}


[[Image: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':
This one ends the function it is inside when 'thread_restart' is triggered on 'level':
Line 45: Line 45:
  }
  }
</pre>
</pre>
[[Category:Call of Duty]]
[[Category:Scripting]]

Latest revision as of 21:36, 28 July 2009

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().
 }