Talow
Sorceror
This is a tutorial for Timer.DelayCall. The reason most will find useful to use this is when you want something to happen but you need to wait a moment because some other scripts will be doing things that would interfere with what you are doing.
An example of this, you want a gump to display when a player dies. Well when a player dies there are many things happening but you can use the player death event to hook into it and send the gump. The gump will be sent but it will also most likely be closed too as the gumps are closed on player's death. Because of this waiting a moment or two for the server to be done closing your gumps is a wonderful way for you to be able to send it and keep it. There are plenty of other reasons to use this.
The delaycall is a way to call a method in your script once the timer has clicked without having to set up the timer class or the ontick ext. From my point of view it's a timer that easy to set up.
Lets look this over. The timer tutorial that's already done, is well done and so I will not be going over the TimeSpan argument as he already spells it out well so reference that argument there. I will however tell you the argument is the length of time before your method is called. In this example we are waiting 2 seconds.
TimerStateCallback is where we define which method we want to call back to. I used "method" as the method I want to call back to for this tutorial.
In this form the DelayCall will call the method without any arguments and will wait 2 seconds before it makes this call.
An example of this, you want a gump to display when a player dies. Well when a player dies there are many things happening but you can use the player death event to hook into it and send the gump. The gump will be sent but it will also most likely be closed too as the gumps are closed on player's death. Because of this waiting a moment or two for the server to be done closing your gumps is a wonderful way for you to be able to send it and keep it. There are plenty of other reasons to use this.
The delaycall is a way to call a method in your script once the timer has clicked without having to set up the timer class or the ontick ext. From my point of view it's a timer that easy to set up.
Code:
Timer.DelayCall( TimeSpan.FromSeconds( 2.0 ), new TimerStateCallback( method ));
Lets look this over. The timer tutorial that's already done, is well done and so I will not be going over the TimeSpan argument as he already spells it out well so reference that argument there. I will however tell you the argument is the length of time before your method is called. In this example we are waiting 2 seconds.
TimerStateCallback is where we define which method we want to call back to. I used "method" as the method I want to call back to for this tutorial.
In this form the DelayCall will call the method without any arguments and will wait 2 seconds before it makes this call.