Difference between revisions of "Setnpctimer"
From Hercules Wiki
(Created page with "== Syntax == *'''setnpctimer''' <tick>{,"NPC Name"}; == Description == The 'setnpctimer' is a command that will explicitly set a NPC timer to a given tick. == Example =...") |
Dastgirpojee (Talk | contribs) |
||
Line 4: | Line 4: | ||
== Description == | == Description == | ||
The '[[setnpctimer]]' is a command that will explicitly set a NPC timer to a given tick. | The '[[setnpctimer]]' is a command that will explicitly set a NPC timer to a given tick. | ||
+ | '[[getnpctimer]]' provides timer information. Its parameter defines what type: | ||
+ | |||
+ | 0 - Will return the current tick count of the timer. | ||
+ | 1 - Will return 1 if there are remaining [[OnTimer]]<ticks>:" labels in the | ||
+ | specified NPC waiting for execution. | ||
+ | 2 - Will return the number of times the timer has triggered and will | ||
+ | trigger an "OnTimer<tick>:" label in the specified NPC. | ||
== Example == | == Example == | ||
− | |||
Here is an example which will help you to understand how the '''setnpctimer''' command works. | Here is an example which will help you to understand how the '''setnpctimer''' command works. | ||
Line 36: | Line 42: | ||
'''setnpctimer''' 0; | '''setnpctimer''' 0; | ||
end; | end; | ||
+ | |||
+ | |||
+ | Example 2: | ||
+ | <pre> | ||
+ | mes "[Man]"; | ||
+ | mes "Ok, I will let you have 30 more seconds..."; | ||
+ | close2; | ||
+ | initnpctimer; | ||
+ | // Notice the 'close2'. If there were a 'next' there the timer would | ||
+ | // be changed only after the player pressed the 'next' button. | ||
+ | end; | ||
+ | |||
+ | OnTimer30000: | ||
+ | setnpctimer getnpctimer(0)+30000; //Will directly Call OnTimer60000. | ||
+ | end; | ||
+ | |||
+ | OnTimer60000: | ||
+ | announce "Only 30 seconds passed, but OnTimer60000 Called.",bc_all; | ||
+ | end; | ||
+ | </pre> |
Revision as of 17:00, 3 October 2013
Syntax
- setnpctimer <tick>{,"NPC Name"};
Description
The 'setnpctimer' is a command that will explicitly set a NPC timer to a given tick. 'getnpctimer' provides timer information. Its parameter defines what type:
0 - Will return the current tick count of the timer. 1 - Will return 1 if there are remaining OnTimer<ticks>:" labels in the
specified NPC waiting for execution.
2 - Will return the number of times the timer has triggered and will
trigger an "OnTimer<tick>:" label in the specified NPC.
Example
Here is an example which will help you to understand how the setnpctimer command works.
OnTimer15000: set $quote,rand(5); if($quote == 0) goto Lquote0; if($quote == 1) goto Lquote1; if($quote == 2) goto Lquote2; if($quote == 3) goto Lquote3; if($quote == 4) goto Lquote4; Lquote0: npctalk "If 0 is randomly picked you will see this"; setnpctimer 0; end; Lquote1: npctalk "If 1 is randomly picked you will see this"; setnpctimer 0; end; Lquote2: npctalk "If 2 is randomly picked you will see this"; setnpctimer 0; end; Lquote3: npctalk "If 3 is randomly picked you will see this"; setnpctimer 0; end; Lquote4: npctalk "If 4 is randomly picked you will see this"; setnpctimer 0; end;
Example 2:
mes "[Man]"; mes "Ok, I will let you have 30 more seconds..."; close2; initnpctimer; // Notice the 'close2'. If there were a 'next' there the timer would // be changed only after the player pressed the 'next' button. end; OnTimer30000: setnpctimer getnpctimer(0)+30000; //Will directly Call OnTimer60000. end; OnTimer60000: announce "Only 30 seconds passed, but OnTimer60000 Called.",bc_all; end;