Blockland Files > Add-Ons

Administrative action log writer V3

Pages: << < (3/7) > >>

Ephialtes:


--- Code: --- writeToFileLine(%location, %crap);
writeToFileLine(%location);
writeToFileLine(%location, "Ban logs");
writeToFileLine(%location, "Date, banner's name, banner's ID, banned's name, banned's ID, amount of time, reason");
writeToFileLine(%location);
writeToFileLine(%location, "Unban logs");
writeToFileLine(%location, "Date, unbanner's name, unbanner's ID, unbanner's position in list");
writeToFileLine(%location);
writeToFileLine(%location, "Chat logs");
writeToFileLine(%location, "Date, name, ID, message");
writeToFileLine(%location);
writeToFileLine(%location, "Status logs(demotion and promotion)");
writeToFileLine(%location, "Date, Person who did it, who did it's ID, action, opposing name, opposing ID");
writeToFileLine(%location, "Actions: N means normal, S means super admin, A means admin");
writeToFileLine(%location);
writeToFileLine(%location, "Whis logs(only if you have IGSO)");
writeToFileLine(%location, "Date, client's ID, target's name, target's ID, message");
--- End code ---

You're creating, opening, closing and deleting a file object and file 16 times in a row.


--- Code: ---    function servercmdRTB_AdminPlayer(%client,%victim)
    {

if(!%client.isSuperAdmin)
{
    parent::servercmdRTB_AdminPlayer(%client,%victim);
    return;
}

if(%victim.isAdmin)
    return;

if(!%victim.name) //don't log if person was not found
{
    parent::servercmdRTB_AdminPlayer(%client,%victim);
    return;
}
%string1 = "";
%string2 = "";

if(%victim.isSuperAdmin)
    %string1 = "S";

%string2 = "A";

%stringFINAL = %string1 @"-"@ %string2;

//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 %stringFINAL TAB %victim.name TAB %victim.bl_id);
parent::servercmdRTB_AdminPlayer(%client,%victim);
    }
--- End code ---

That is just a total mess, you're even randomly creating empty variables, And it can be totally replaced with this:


--- Code: ---function servercmdRTB_AdminPlayer(%client,%victim)
{
%oldMask = %victim.isAdmin @ %victim.isSuperAdmin;
Parent::serverCmdRTB_AdminPlayer(%client,%victim);
%newMask = %victim.isAdmin @ %victim.isSuperAdmin;

if(%newMask !$= %oldMask)
{
writeToFileLine($LOGWrite::statusPath, addTime() TAB %client.name TAB %client.bl_id TAB (%victim.isAdmin) ? "A" : "" @ "-" @ (%victim.isSuperAdmin) ? "S" : "" TAB %victim.name TAB %victim.bl_id);
}
}
--- End code ---

And that way it wont break RTB if i decide to change how RTB permissions work in the future. Overall its just a mess.

Kalphiter:

Yes, the shorthand if-else is in the back of my mind, I always forget it.

Ephialtes:

No its not just that, you're re-writing (and overwriting) a bunch of RTB logic when you don't even need to.

Kalphiter:

Will you also approve it if I fix what you said?

The random blank variable things is that I was worried about the scope.

Do I have to worry about the scope, or is the variable available to the whole function?

Ephialtes:

% is a local variable and only exists until the function has been run and then its destroyed and cannot be accessed.

And yeah, I'll approve it if you fix those.

Pages: << < (3/7) > >>

Go to full version