15
15
Here's an example of it in proccess.
16
16
We'll take this apart after we look at it.
17
17
18
- ``` C
18
+ ``` HercScript
19
19
prontera,23,20,2 script Non-spamming-NPC-Talker 1_M_JOBGUIDER,{
20
20
end;
21
21
@@ -49,7 +49,7 @@ We'll start with "OnInit:".
49
49
Q: What is "OnInit:"?
50
50
A: "OnInit:" is the commands you wish the NPC to execute right after the NPC is loaded.
51
51
52
- ``` C
52
+ ``` HercScript
53
53
OnInit:
54
54
$GlobalVariable = 10;
55
55
end;
@@ -67,7 +67,7 @@ has ended.
67
67
68
68
** If you do not end the "On" label with "end;", horrible things will happen, such as running through other labels.**
69
69
70
- ``` C
70
+ ``` HercScript
71
71
OnInit:
72
72
$GlobalVariable = 10;
73
73
@@ -84,7 +84,7 @@ Note: Sometimes this is usefull too...
84
84
85
85
Example:
86
86
87
- ``` C
87
+ ``` HercScript
88
88
// ...
89
89
90
90
OnClock2100:
@@ -104,7 +104,7 @@ This Script will run at 21:00 AND at 23:00 (c&p from the woe-starting-script)
104
104
Delayed warping is a feature you can put in your script to add more drama, or to automatically warp someone from a room
105
105
when the player has exceeded the allotted time for being there. Here is an example of a delayed warp:
106
106
107
- ``` C
107
+ ``` HercScript
108
108
prontera,23,20,2 script Bomb Squad 1_M_JOBGUIDER,{
109
109
mes("[Dismantler]");
110
110
mes("Where is the bomb? WHERE IS IT??");
@@ -144,7 +144,7 @@ However, the script will keep on running in the background, after the close butt
144
144
presses the close button, it continues with the next line. For you lazy bums, here is an outtake of the script to
145
145
prevent your scrolling finger from getting tired.
146
146
147
- ``` C
147
+ ``` HercScript
148
148
addtimer(15000, "Bomb Squad::OnWarn");
149
149
addtimer(30000, "Bomb Squad::OnBoom");
150
150
dispbottom("Dismantler : The bomb will detonate in 30 seconds!");
@@ -167,7 +167,7 @@ need to manipulate the player later on, we need the script to remember the RID.
167
167
168
168
Anyway, after 15 seconds, if the player hasn't logged out, the script will restart at the following point:
169
169
170
- ```C
170
+ ``` HercScript
171
171
OnWarn:
172
172
dispbottom("Dismantler : OH MY GOD! ONLY 15 SECONDS LEFT - HURRY!!!!");
173
173
end;
@@ -176,7 +176,7 @@ OnWarn:
176
176
What it does here, is another text display in the chat of the player, and then end the script again. So, we wait, and we
177
177
wait, and then, after another 15 seconds, the second timer triggers the label OnBoom:, and starts this piece of code:
178
178
179
- ``` C
179
+ ``` HercScript
180
180
OnBoom:
181
181
dispbottom("*time slows down as suddenly the ticking stops*");
182
182
dispbottom("....");
@@ -203,7 +203,7 @@ addtimer command, as they both behave the same.
203
203
204
204
so the Bomb Squad npc script now look like this
205
205
206
- ```C
206
+ ``` HercScript
207
207
prontera,155,188,2 script Bomb Squad 1_M_JOBGUIDER,{
208
208
mes("[Dismantler]");
209
209
mes("Where is the bomb? WHERE IS IT??");
@@ -241,7 +241,7 @@ see the player variable boom set back to 0 with "[set](./commands/set.md) @boom,
241
241
242
242
Now, on to the bomb npc.
243
243
244
- ``` C
244
+ ``` HercScript
245
245
prontera,50,50,2 script Bomb HIDDEN_NPC,{
246
246
if (@boom == 0)
247
247
end;
@@ -272,7 +272,7 @@ and recompile your server.
272
272
273
273
Let's start with another example:
274
274
275
- ``` C
275
+ ``` HercScript
276
276
prontera,23,20,2 script Daily Healer 1_M_JOBGUIDER,{
277
277
mes("[Healer]");
278
278
mes("Hello there.");
@@ -311,7 +311,7 @@ A: That is correct. This NPC uses what I would like to call a Static Timer. We w
311
311
Ok, at a first glance, this is a normal healer NPC that fully heals your HP and SP. The interesting part though is at
312
312
the bottom. Let's start with the bottom most part:
313
313
314
- ``` C
314
+ ``` HercScript
315
315
close2();
316
316
percentheal(100, 100);
317
317
TimeHealed = gettimetick(GETTIMETICK_UNIXTIME);
@@ -322,7 +322,7 @@ the bottom. Let's start with the bottom most part:
322
322
The NPC does the healing here, but after the healing, it sets a weird value to TimeHealed. First, it gets a value from
323
323
` gettimetick(GETTIMETICK_UNIXTIME) ` . This command returns the amount of seconds elapsed since 1/1/1970, based on your server current time.
324
324
325
- ```C
325
+ ``` HercScript
326
326
if (TimeHealed + 86400 > gettimetick (GETTIMETICK_UNIXTIME)) {
327
327
```
328
328
@@ -340,7 +340,7 @@ making it dynamic means.
340
340
341
341
By turning that numbers into a Global variable,
342
342
343
- ``` c
343
+ ``` HercScript
344
344
if ((TimeHealed + $HealInterval) > Gettimetick(GETTIMETICK_UNIXTIME)) {
345
345
```
346
346
@@ -397,7 +397,7 @@ How they work? Relatively easy. OnClock is already explained in the first part o
397
397
case you forgot. To make it work, you replace XXXX by an actual time in the 24 hour format. The time you put there, is
398
398
when the label is triggered. So, for example:
399
399
400
- ```C
400
+ ``` HercScript
401
401
OnClock0700: // This label is triggered at 7 AM servertime.
402
402
OnClock1414: // This label is triggered at 2:14 PM servertime.
403
403
```
@@ -409,7 +409,7 @@ month, the second XX is the day of that month. When it is that day, it will be t
409
409
only once at the start of that day, or the first time that your server is up during that day. Here are a couple of
410
410
examples:
411
411
412
- ``` C
412
+ ``` HercScript
413
413
OnDay0101: // This label is triggered on the first day of January.
414
414
OnDay0515: // This one is triggered on the fifteenth day of May.
415
415
OnDay1231: // This one is triggered on the last day of December.
@@ -420,7 +420,7 @@ OnDay0229: // This label is only triggered when it is February 29th,
420
420
OnHourXX and OnMinuteXX are similar in use. With OnHour, the XX stands for a specific hour during the day when it is
421
421
triggered. The XX within OnMinute stands for a specific minute per hour. Some examples to make it clear:
422
422
423
- ``` C
423
+ ``` HercScript
424
424
OnHour01: // Triggers at 1 AM every day.
425
425
OnHour20: // Triggers at 8 PM every day.
426
426
OnMinute00: // Triggers at each new hour, so 1:00, 2:00, 3:00, 4:00 etc.
@@ -433,7 +433,7 @@ replaced by a number in the same way as the XXXX in OnClockXXXX. It notes a spec
433
433
triggered on the specified day of the week (SSS) at the specified time in 24 hour format (XXXX). At least, that is the
434
434
theory. Here are some examples you can work with:
435
435
436
- ``` C
436
+ ``` HercScript
437
437
OnSat1200: // Triggers at noon on each Saturday.
438
438
OnTue0707: // Triggers at 7 past 7 AM on Tuesday.
439
439
```
@@ -443,7 +443,7 @@ Note: Although there is no OnSecondXX or OnMillisecondXXXX label, you can simula
443
443
heavy load on your server. To do this, you will have to use a NPC. Here is a short example simulating OnSecond30 using a
444
444
NPC timer:
445
445
446
- ``` C
446
+ ``` HercScript
447
447
- script Annoying Announcer FAKE_NPC,{
448
448
OnInit:
449
449
initnpctimer();
@@ -460,7 +460,7 @@ OnTimer1000:
460
460
461
461
And one that triggers every 40 milliseconds:
462
462
463
- ``` C
463
+ ``` HercScript
464
464
- script Flooder FAKE_NPC,{
465
465
OnInit:
466
466
initnpctimer();
@@ -492,7 +492,7 @@ There are many more of these kinds of special event triggered labels, like the l
492
492
exception of OnTimerX, are all triggered without the need of a player. With OnTimerX, the X should be replaced by a time
493
493
in milliseconds, for example:
494
494
495
- ``` C
495
+ ``` HercScript
496
496
OnTimer100: // Triggers 100ms after a player timer or NPC timer is started in the same NPC.
497
497
OnTimer3600000: // Triggers 1 hour after a player timer or NPC timer is started in the same NPC.
498
498
```
@@ -553,7 +553,7 @@ online, the player's RID will be set equal to his account ID (`getcharid(CHAR_ID
553
553
554
554
Some examples:
555
555
556
- ``` C
556
+ ``` HercScript
557
557
initnpctimer(); // Start a new NPC timer and make it count from 0.
558
558
initnpctimer("My Other NPC"); // Start a new NPC timer in the NPC named "My Other NPC" and make it count from 0.
559
559
@@ -571,7 +571,7 @@ this command. If you like you can read `continuenpctimer` instead of `startnpcti
571
571
Again, for the various options, you might want to look at ` InitNPCTimer ` . We will just show
572
572
some examples here:
573
573
574
- ```C
574
+ ``` HercScript
575
575
startnpctimer(); // Continues the NPC timer where it left off, or start a new one if there isn't a timer already.
576
576
577
577
startnpctimer("My Other NPC"); // Same as above, but starts it in the NPC named "My Other NPC".
@@ -588,7 +588,7 @@ ignored), then **stopnpctimer** will also detach the player, if any was attached
588
588
589
589
Some examples again:
590
590
591
- ``` C
591
+ ``` HercScript
592
592
stopnpctimer(); // Pauses the NPC timer in the current NPC.
593
593
stopnpctimer("My Other NPC"); // Pauses the NPC timer in the NPC named "My Other NPC"
594
594
stopnpctimer(1); // Pauses the NPC timer in the current NPC and detaches any attached player.
@@ -622,7 +622,7 @@ attached, or it will give you back an error and return 0.
622
622
623
623
Some examples:
624
624
625
- ```C
625
+ ``` HercScript
626
626
getnpctimer(0); // Returns the current amount of ticks.
627
627
getnpctimer(0,"My Other NPC"); // Does the same, only for the NPC named "My Other NPC".
628
628
getnpctimer(1); // Returns the amount of OnTimer labels that are still untriggered.
@@ -646,7 +646,7 @@ there is to this command. It works, no matter if there is a player attached to i
646
646
647
647
Some examples again:
648
648
649
- ``` C
649
+ ``` HercScript
650
650
setnpctimer(10000); // Sets the NPC Timer of the current NPC to 10 seconds.
651
651
setnpctimer(2345, "My Other NPC"); // Sets the NPC Timer in the NPC named "My Other NPC" to 2345 ticks or ms.
652
652
setnpctimer(0); // Sets the current NPC Timer to 0.
@@ -667,7 +667,7 @@ his account id or RID (or UID/GID in some devs words) as a parameter.
667
667
668
668
Examples:
669
669
670
- ```C
670
+ ``` HercScript
671
671
attachnpctimer(getcharid(3)); // Attaches current player to the NPC Timer.`
672
672
attachnpctimer(2000000); // Attaches the player with account id 2000000 to the NPC Timer, if he is online.`
673
673
```
@@ -680,7 +680,7 @@ parameter. This is optional of course.
680
680
681
681
Examples:
682
682
683
- ``` C
683
+ ``` HercScript
684
684
detachnpctimer(); // Detaches the attached player from the NPC Timer, if anyone was attached.`
685
685
detachnpctimer("My Other NPC"); // Does the same, only for the NPC named "My Other NPC".`
686
686
```
@@ -737,7 +737,7 @@ timer runs down to 0, it will jump to that label in that NPC. For easiness sake,
737
737
the command, and the upcoming commands, also the name of the player timer.
738
738
Well, that is all there is to the addtimer command, so some last examples:
739
739
740
- ```C
740
+ ``` HercScript
741
741
addtimer(1000, "My NPC::OnMyLabel"); // Starts a timer that runs out after 1000 ms (1 second), and then jumps to OnMyLabel in My NPC.
742
742
addtimer(60000, "NPC1::OnLoser"); // After 60 seconds, this timer runs out, and jumps to OnLoser in the NPC named NPC1.
743
743
```
@@ -750,7 +750,7 @@ which timer it does this, is up to you and the player who is currently attached
750
750
alter, is what you specify with the second parameter, "NPC::OnEvent" (or as said earlier, the name of the timer).
751
751
Some examples:
752
752
753
- ``` C
753
+ ``` HercScript
754
754
addtimercount(5000, "My NPC::OnMyLabel"); // Adds 5 seconds to the timer with the name "My NPC::OnMyLabel".
755
755
addtimercount(-10000, "NPC1::OnLoser"); // Removes 10 seconds from the timer with the name "NPC1::OnLoser".
756
756
```
@@ -762,7 +762,7 @@ the same event label/name as specified in the parameter. Of course, it only does
762
762
is currently attached to the script, but well, that is all it does.
763
763
Some examples:
764
764
765
- ```C
765
+ ``` HercScript
766
766
deltimer("My NPC::OnMyLabel"); // Erases the timer that was supposed to jump to OnMyLabel in the NPC named My NPC.
767
767
deltimer("NPC1::OnLoser"); // Erases the timer named NPC1::OnLoser. (Name == Event label)
768
768
```
0 commit comments