summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-04-10 08:43:25 -0300
committerJesusaves <cpntb1@ymail.com>2019-04-10 08:43:25 -0300
commitee7ad93a1ebd36af21568cae37934d5edd3e4a12 (patch)
tree3043a9f8a26b14cb3e0315c8faadc4a5722774ce
parent08b14b5ef166a9ad2e81f65554030af26b912b2b (diff)
downloadserverdata-ee7ad93a1ebd36af21568cae37934d5edd3e4a12.tar.gz
serverdata-ee7ad93a1ebd36af21568cae37934d5edd3e4a12.tar.bz2
serverdata-ee7ad93a1ebd36af21568cae37934d5edd3e4a12.tar.xz
serverdata-ee7ad93a1ebd36af21568cae37934d5edd3e4a12.zip
gettimeparam(n) → Returns number of seconds/minutes/hours/days/months/years
since 01/01/1970. Note that months and years are estimatives. For seconds, please use gettimetick(2) instead.
-rw-r--r--npc/functions/util.txt35
1 files changed, 34 insertions, 1 deletions
diff --git a/npc/functions/util.txt b/npc/functions/util.txt
index 6b01dd7fa..4dea46bfc 100644
--- a/npc/functions/util.txt
+++ b/npc/functions/util.txt
@@ -615,5 +615,38 @@ function script mercrank {
}
}
-
+// gettimeparam(GETTIME_X)
+// Returns the number of seconds/minutes/hours/days/months/years since 01/01/1970
+function script gettimeparam {
+ .@p=getarg(0, GETTIME_MINUTE);
+
+ // Seconds
+ .@t=gettimetick(2);
+ if (.@p == GETTIME_SECOND)
+ return .@t;
+
+ // Minutes (default)
+ .@t=.@t/60;
+ if (.@p == GETTIME_MINUTE)
+ return .@t;
+
+ // Hours
+ .@t=.@t/60;
+ if (.@p == GETTIME_HOUR)
+ return .@t;
+
+ // Days
+ .@t=.@t/24;
+ if (.@p == GETTIME_DAYOFMONTH)
+ return .@t;
+
+ // Months (estimative)
+ .@t=.@t/30;
+ if (.@p == GETTIME_MONTH)
+ return .@t;
+
+ // Years (estimative, unused, fallback)
+ .@t=.@t/12;
+ return .@t;
+}