Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //LogWriter by Kalphiter
- //Modified slightly by TBP.
- //Function to output an updated date.
- function loggerloop(){
- cancel($loggersched);
- $upddate = getDate();
- $loggersched = schedule(60000,0,'loggerloop');
- }
- loggerloop();
- $LOGWrite::CommonPath = "Add-Ons/Server_TBP/Logs/" @ strreplace($upddate,"/",".") @ "/";
- $LOGWrite::UnbanPath = $LOGWrite::CommonPath @ "unbans.txt";
- $LOGWrite::BanPath = $LOGWrite::CommonPath @ "bans.txt";
- $LOGWrite::ChatPath = $LOGWrite::CommonPath @ "chat.txt";
- $LOGWrite::helpPath = $LOGWrite::CommonPath @ "help.txt";
- $LOGWrite::ConnectionPath = $LOGWrite::CommonPath @"connections.txt";
- $LOGWrite::statusPath = $LOGWrite::CommonPath @"status.txt";
- //For /whis logging(IGSO only)
- $LOGWrite::whisPath = "config/server/Adminlogs/whis.txt";
- if(isFile("Add-Ons/Script_IGSO.zip"))
- $LOGWrite::HasIgso = true;
- else
- $LOGWrite::HasIgso = false;
- if(!isFile($LOGWrite::helpPath))
- createHelpFile($LOGWrite::helpPath);
- package LogWriter
- {
- function addTime()
- {
- %getTime = firstWord(getDateTime()) TAB restWords(getDateTime());
- return %getTime;
- }
- function writeToFileLine(%filepath, %crap)
- {
- %file = new FileObject();
- %file.openForAppend(%filepath);
- %file.writeLine(%crap);
- %file.close();
- %file.delete();
- }
- function createHelpFile(%location)
- {
- %crap1 = "How to read the logs\r\n\r\n";
- %crap2 = "";
- %crap3 = "Ban logs\r\nDate, banner's name, banner's ID, banned's name, banned's ID, amount of time, reason\r\n\r\n";
- %crap4 = "Unban logs\r\nDate, unbanner, unbanner's ID, unbanned's name(if applicable), unbanned's ID\r\n\r\n";
- %crap5 = "Chat logs\r\nDate, name, ID, message\r\n\r\n";
- %crap6 = "Status logs(demotion and promotion)\r\nDate, Person who did it, who did it's ID, action, opposing name, opposing ID\r\n";
- %crap7 = "Actions: N means normal, S means super admin, A means admin\r\n\r\n";
- %crap8 = "Whis logs(only if you have IGSO)\r\nDate, client's ID, target's name, target's ID, message\r\n\r\n";
- %crap9 = "Connection logs\r\nDate, connect/disconnect, name, BL ID, IP Address\r\n\r\n";
- %allCrap = %crap1 @ %crap2 @ %crap3 @ %crap4 @ %crap5 @ %crap6 @ %crap7 @ %crap8 @ %crap9;
- writeToFileLine(%location, %allCrap);
- }
- function GameConnection::onClientLeaveGame(%this)
- {
- %type = "D";
- //Date, connect/disconnect, name, BL ID, IP address
- writeToFileLine($LOGWrite::ConnectionPath, addTime() TAB %type TAB %this.name TAB %this.bl_id TAB %this.getRawIP());
- parent::onClientLeaveGame(%this,%name,%a,%b,%c,%d,%e);
- }
- function GameConnection::autoAdminCheck(%this)
- {
- %type = "C";
- //Date, connect/disconnect, name, BL ID, IP address
- writeToFileLine($LOGWrite::ConnectionPath, addTime() TAB %type TAB %this.name TAB %this.bl_id TAB %this.getRawIP());
- parent::autoAdminCheck(%this);
- }
- function serverCmdmessageSent(%client, %text)
- {
- parent::serverCmdmessageSent(%client, %text);
- writeToFileLine($LOGWrite::ChatPath, addTime() TAB %client.name TAB %client.bl_id TAB %text);
- }
- function servercmdRTB_DeAdminPlayer(%client,%victim)
- {
- %oldMask = %victim.isAdmin @ %victim.isSuperAdmin;
- parent::servercmdRTB_DeAdminPlayer(%client,%victim);
- %newMask = %victim.isAdmin @ %victim.isSuperAdmin;
- if(%newMask $= %oldMask) //if there is no rank change, let's just exit
- return;
- if(%victim.isSuperAdmin)
- %origRank = "S";
- if(%victim.isAdmin)
- %origRank = "A";
- //Admin or super admin to normal player
- %rankChange = %origRank @"-N";
- //Date, Person who did it, who did it's ID, action, opposing name, opposing ID
- writeToFileLine($LOGWrite::statusPath, addTime() TAB %client.name TAB %client.bl_id TAB %rankChange TAB %victim.name TAB %victim.bl_id);
- }
- function servercmdRTB_AdminPlayer(%client,%victim)
- {
- %oldMask = %victim.isAdmin @ %victim.isSuperAdmin;
- Parent::serverCmdRTB_AdminPlayer(%client,%victim);
- %newMask = %victim.isAdmin @ %victim.isSuperAdmin;
- if(%newMask !$= %oldMask)
- {
- if(%victim.isSuperAdmin)
- {
- %adminLevel = 2;
- %status = "S";
- }
- else
- {
- %adminLevel = 0;
- %status = "A";
- }
- writeToFileLine($LOGWrite::statusPath, addTime() TAB %client.name TAB %client.bl_id TAB %status @"-A" TAB %victim.name TAB %victim.bl_id);
- }
- }
- function servercmdRTB_SuperAdminPlayer(%client, %victim)
- {
- %oldMask = %victim.isAdmin @ %victim.isSuperAdmin;
- Parent::serverCmdRTB_AdminPlayer(%client,%victim);
- %newMask = %victim.isAdmin @ %victim.isSuperAdmin;
- if(%newMask !$= %oldMask)
- {
- if(%victim.isAdmin)
- {
- %adminLevel = 1;
- %status = "A";
- }
- else
- {
- %adminLevel = 0;
- %status = "N";
- }
- writeToFileLine($LOGWrite::statusPath, addTime() TAB %client.name TAB %client.bl_id TAB %status @"-S" TAB %victim.name TAB %victim.bl_id);
- }
- }
- function serverCmdWhis(%client,%victim,%a1,%a2,%a3,%a4,%a5,%a6,%a7,%a8,%a9,%a10,%a11,%a12,%a13,%a14,%a15,%a16,%a17,%a18,%a19,%a20)
- {
- if(!$LOGWrite::HasIgso)
- {
- return;
- }
- if(!%victim.name) //don't log if person was not found
- {
- parent::serverCmdWhis(%client,%victim,%a1,%a2,%a3,%a4,%a5,%a6,%a7,%a8,%a9,%a10,%a11,%a12,%a13,%a14,%a15,%a16,%a17,%a18,%a19,%a20);
- return;
- }
- %msg = %a1 SPC %a2 SPC %a3 SPC %a4 SPC %a5 SPC %a6 SPC %a7 SPC %a8 SPC %a9 SPC %a10 SPC %a11 SPC %a12 SPC %a13 SPC %a14 SPC %a15 SPC %a16 SPC %a17 SPC %a18 SPC %a19 SPC %a20;
- //Date, client's name, client's ID, target's name, target's ID, message
- writeToFileLine($LOGWrite::whisPath, addTime() TAB %client.name TAB %client.bl_id TAB %victim.name TAB %victim.bl_id TAB %msg);
- parent::serverCmdWhis(%client,%Victim,%a1,%a2,%a3,%a4,%a5,%a6,%a7,%a8,%a9,%a10,%a11,%a12,%a13,%a14,%a15,%a16,%a17,%a18,%a19,%a20);
- }
- function servercmdUnban(%unbanner, %positionInList)
- {
- %banCount = BanManagerSO.numBans;
- parent::servercmdunban(%unbanner, %positionInList);
- if(%banCount == BanManagerSO.numBans)
- return;
- //%unbanner person who is unbanning this person
- //%positionInList position of the person being unbanned in the unban list
- //Also another benefit, you can see expired bans, in case of abuse
- //Date, unbanner, unbanner's ID, unbanned's name(if applicable), unbanned's ID
- if(!banManagerSO.victimName[%positionInList])
- %nameIfApplicable = "?";
- writeToFileLine($LOGWrite::UnbanPath, addTime() TAB %unbanner.name TAB %unbanner.bl_id TAB %nameIfApplicable TAB banManagerSO.victimBL_ID[%positionInList]);
- }
- function servercmdBan(%banner, %bannedClient, %bannedID, %banTime, %banReason)
- {
- %banCount = BanManagerSO.numBans;
- %reason = BanManagerSO.Reason[getField(1, BanManagerSO.isBanned(%bannedID))];
- parent::servercmdban(%banner, %bannedClient, %bannedID, %banTime, %banReason);
- //if the ban count didn't change, it probably means they're not allowed to ban
- //But, an admin may revise a previous ban in which the ban count will not change, so we check to see if the reason changed
- if(%banCount == BanManagerSO.numBans && %banReason $= BanManagerSO.Reason[getField(1, BanManagerSO.isBanned(%bannedID))])
- return;
- if(!%banner.isAdmin)
- return;
- //And newly discovered,
- //%banner person who is issuing ban
- //%bannedClient person being banned(If person has never visited server, will return BL_ID
- //%bannedID ID of person being banned
- //%banTime Time in minutes(-1 is forever, you've heard that before)
- //%banReason Reason, obviously
- //What's being written to the file:
- //Date, banner's name, banner's ID, banned's name, banned's ID, time, reason
- //It is possible to ban people with the /ban command, but they might not have their name in the server "history"
- //The server history logs all IDs and names in the clear bricks list, and once the server is shut it dissapears
- %nameIfApplicable = %bannedClient.name;
- if(!%bannedClient.name)
- %nameIfApplicable = "?";
- writeToFileLine($LOGWrite::BanPath, addTime() TAB %banner.name TAB %banner.bl_id TAB %nameIfApplicable TAB %bannedID TAB %banTime TAB %banReason);
- }
- };
- activatePackage(LogWriter);
Advertisement
Add Comment
Please, Sign In to add comment