From 5b6d5abb7c25fce31cc818a5aa9dbb66aeec5f26 Mon Sep 17 00:00:00 2001 From: Reid Date: Tue, 19 Apr 2016 08:25:38 +0200 Subject: Add a new function called npctalkonce. --- npc/functions/main.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'npc') diff --git a/npc/functions/main.txt b/npc/functions/main.txt index cd71b8ea..12484f11 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -188,3 +188,35 @@ function script compareandsetq { } return false; } + +// Use a delay to prevent spams from NPC that display text without the +// use of (a) close/next function(s). +// Argument: +// 0 Text to display +// 1 Lock delay (default = 1) +// 2 Message function: (default = 0) +// 0 = npctalk3 +// 1 = npctalk +// 2 = message +function script npctalkonce { + if ((.@current_time = gettimetick(2)) < Repeat_NPC_lock) + { + return false; + } + Repeat_NPC_lock = .@current_time + getarg(1,1); + + if (getarg(2,0) == 0) + { + npctalk3 getarg(0); + } + else if (getarg(2,0) == 1) + { + npctalk getarg(0); + } + else if (getarg(2,0) == 2) + { + message strcharinfo(0), getarg(0); + } + + return true; +} -- cgit v1.2.3-70-g09d2