From 5642dea82f99181dce45b83b9e9bcfd6a903175b Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Mon, 12 Apr 2021 10:57:46 -0300 Subject: Enable some logging and keep it around for a short period because whinners. Chat log retention: 24~48 hours item log retention: 2 months (same for money) --- npc/functions/global_event_handler.txt | 9 +++++++++ npc/functions/main.txt | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'npc/functions') diff --git a/npc/functions/global_event_handler.txt b/npc/functions/global_event_handler.txt index 33723786..aa06a38b 100644 --- a/npc/functions/global_event_handler.txt +++ b/npc/functions/global_event_handler.txt @@ -26,6 +26,15 @@ OnPCDieEvent: set @killerrid, 0; // reset killer rid end; +// Cleanup: Retain chat logs for 24~48 hours +// Cleanup: Retain item logs for 2 months +OnClock0500: + if (gettime(GETTIME_DAYOFMONTH) > 1) + query_sql("DELETE FROM `chatlog` WHERE `time` < '"+sqldate(-1)+"'"); + query_sql("DELETE FROM `picklog` WHERE `time` < '"+sqldate(0, -2)+"'"); + query_sql("DELETE FROM `zenylog` WHERE `time` < '"+sqldate(0, -2)+"'"); + end; + OnInit: MOTD(); // set the MOTD array end; diff --git a/npc/functions/main.txt b/npc/functions/main.txt index ead3a99d..25d20edc 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -633,3 +633,24 @@ function script learnskill { return; } +// sqldate({day variation, month variation}) +function script sqldate { + .@d=gettime(GETTIME_DAYOFMONTH)+getarg(0, 0); + .@m=gettime(GETTIME_MONTH)+getarg(1, 0); + .@y=gettime(GETTIME_YEAR); + // Overflow prevention + if (.@d <= 0) { + .@d=1; + } + while (.@m > 12) { + .@y+=1; + .@m-=12; + } + while (.@m < 1) { + .@y-=1; + .@m+=12; + } + .@strdate$=sprintf("%04d-%02d-%02d %02d:%02d:%02d", .@y, .@m, .@d, gettime(GETTIME_HOUR), gettime(GETTIME_MINUTE), gettime(GETTIME_SECOND)); + return .@strdate$; +} + -- cgit v1.2.3-70-g09d2