1+ -- log messages triggered by player
2+ function logViolation (uPlayer , strMessage )
3+ local strPlayerName , strPlayerIP , strPlayerSerial = getPlayerName (uPlayer ), getPlayerIP (uPlayer ), getPlayerSerial (uPlayer );
4+ local strLogFileName = " violations.txt" ;
5+ local uFileHandle = fileExists (strLogFileName ) and fileOpen (strLogFileName );
6+
7+ if (not uFileHandle ) then
8+ uFileHandle = fileCreate (strLogFileName );
9+ fileFlush (uFileHandle );
10+ else
11+ fileSetPos (uFileHandle , fileGetSize (uFileHandle ));
12+ end
13+
14+ local strViolationMessage = getDateTime ().. " CLIENT: " .. strPlayerName .. " | IP: " .. strPlayerIP .. " | SERIAL: " .. strPlayerSerial .. " | " .. strMessage ;
15+
16+ outputDebugString (strViolationMessage , 4 , 255 , 255 , 255 );
17+ outputServerLog (strViolationMessage );
18+ fileWrite (uFileHandle , strViolationMessage .. " \n " );
19+ fileClose (uFileHandle );
20+ end
21+
22+
23+
24+ -- log messages without player element
25+ function logAction (strMessage )
26+ local strLogFileName = " actions.txt" ;
27+ local uFileHandle = fileExists (strLogFileName ) and fileOpen (strLogFileName );
28+
29+ if (not uFileHandle ) then
30+ uFileHandle = fileCreate (strLogFileName );
31+ fileFlush (uFileHandle );
32+ else
33+ fileSetPos (uFileHandle , fileGetSize (uFileHandle ));
34+ end
35+
36+ local strActionMessage = getDateTime ().. " " .. strMessage ;
37+
38+ outputDebugString (strActionMessage , 4 , 255 , 255 , 255 );
39+ outputServerLog (strActionMessage );
40+ fileWrite (uFileHandle , strActionMessage .. " \n " );
41+ fileClose (uFileHandle );
42+ end
43+
44+
45+
46+ -- get the current date and time for logging
47+ function getDateTime ()
48+ local tblRealTime = getRealTime ();
49+ local iDay = tblRealTime .monthday ;
50+ local iMonth = tblRealTime .month + 1 ;
51+ local iYear = tblRealTime .year + 1900 ;
52+ local iHour = tblRealTime .hour ;
53+ local iMinute = tblRealTime .minute ;
54+ local iSecond = tblRealTime .second ;
55+
56+ if (iDay < 10 ) then iDay = " 0" .. iDay end ;
57+ if (iMonth < 10 ) then iMonth = " 0" .. iMonth end ;
58+ if (iHour < 10 ) then iHour = " 0" .. iHour end ;
59+ if (iMinute < 10 ) then iMinute = " 0" .. iMinute end ;
60+ if (iSecond < 10 ) then iSecond = " 0" .. iSecond end ;
61+
62+ return " [" .. tostring (iDay ).. " ." .. tostring (iMonth ).. " ." .. tostring (iYear ).. " - " .. tostring (iHour ).. " :" .. tostring (iMinute ).. " :" .. tostring (iSecond ).. " ]" ;
63+ end
0 commit comments