summaryrefslogtreecommitdiff
path: root/npc/config/duplicates.txt
blob: cdf24ed618cd229a9d5e3db0c65749333ecea3dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// TMW2 script
// Author: Jesusalva <admin@tmw2.org>
// Manages duplicates

-	script	#dupemaster	32767,{
    end;

OnInterIfInitOnce:
    // (dupe_name$, expire_tick)
    $@_DUPES = htnew();
    end;

OnInit:
    initnpctimer;
    end;

// Cleans every 15s
OnTimer15000:
    .@t = gettimetick(2);

    .@iter = htiterator($@_DUPES);
    for (.@key$ = htinextkey(.@iter); hticheck(.@iter); .@key$ = htinextkey(.@iter)) {
        // Check if the NPC expired, remove from hash table if so
        if (htget($@_DUPES, .@key$, INT_MAX) <= .@t) {
            npc_duplicate_remove(.@key$);
            htput($@_DUPES, .@key$, 0);
        }
    }
    htidelete(.@iter);

    initnpctimer;
    end;
}