diff options
Diffstat (limited to 'npc/functions')
-rw-r--r-- | npc/functions/global_event_handler.txt | 9 | ||||
-rw-r--r-- | npc/functions/main.txt | 21 |
2 files changed, 30 insertions, 0 deletions
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$; +} + |