From 2f60556bc30b6e56c678fe4d2f07a136e83167a2 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Thu, 14 Dec 2023 19:51:25 -0300 Subject: legendaryTimeCheck -> Change scope from local to global function. It might be useful later. --- npc/commands/grantpower.txt | 18 ------------------ npc/functions/time.txt | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/npc/commands/grantpower.txt b/npc/commands/grantpower.txt index 1762bdd5d..88541d21f 100644 --- a/npc/commands/grantpower.txt +++ b/npc/commands/grantpower.txt @@ -97,24 +97,6 @@ function legendaryRodexWarning { return; } -function legendaryTimeCheck { - .@min = getarg(1)-86400; - .@max = getarg(1)+86400; - // getarg(0) is last_login, and getarg(1) the tolerance - // if last_login < tolerance (older), then ban - // But we don't want this to repeat. - // Tolerance: day 10 -> min = 10-1=9; max=10+1=11 - // Day 8: (8 < 11? yes; 8 > 9? no) - // Day 9: (9 < 11? yes; 9 > 9? no) - // Day 10: (10 < 11? yes; 10 > 9? yes) -> Message sent - // Day 11: (11 < 11? no; 11 > 9? yes) - // Day 12: (12 < 11? no; 12 > 9? yes) - if (getarg(0) < .@max && getarg(0) > .@min) - return true; - else - return false; -} - OnClock0238: .@date=gettimetick(2); .@warn=.@date-(86400*2); diff --git a/npc/functions/time.txt b/npc/functions/time.txt index e6e4c70a7..192c6c9ab 100644 --- a/npc/functions/time.txt +++ b/npc/functions/time.txt @@ -31,6 +31,24 @@ function script time_from_days { return now() + (getarg(0) * 86400); } +// legendaryTimeCheck(current_date, target_date) +function script legendaryTimeCheck { + .@min = getarg(1)-86400; + .@max = getarg(1)+86400; + // getarg(0) is last_login, and getarg(1) the tolerance + // if last_login < tolerance (older), then ban + // But we don't want this to repeat. + // Tolerance: day 10 -> min = 10-1=9; max=10+1=11 + // Day 8: (8 < 11? yes; 8 > 9? no) + // Day 9: (9 < 11? yes; 9 > 9? no) + // Day 10: (10 < 11? yes; 10 > 9? yes) -> Message sent + // Day 11: (11 < 11? no; 11 > 9? yes) + // Day 12: (12 < 11? no; 12 > 9? yes) + if (getarg(0) < .@max && getarg(0) > .@min) + return true; + else + return false; +} // FuzzyTime({, {, }}) // gives time in a human-readable format -- cgit v1.2.3-60-g2f50