detain events

This commit is contained in:
Axwabo 2024-07-14 16:53:38 +02:00
parent cf8e68f159
commit bce7d936b3
4 changed files with 29 additions and 4 deletions

View File

@ -15,4 +15,6 @@ public sealed class DeathLogConfig
public float DefaultFontSizeScalar { get; set; } = 1;
public bool LogDetainEvents { get; set; } = true;
}

View File

@ -90,4 +90,18 @@ public sealed class DeathLogPlugin
LogHandler.LogLeavingScp(_lastRole, _lastHealth, _lastHumeShield, Config.VisibilityRequirement, Config.DefaultFontSizeScalar);
}
[PluginEvent]
private void OnDetaining(PlayerHandcuffEvent e)
{
if (Config.LogDetainEvents)
LogHandler.LogDetain(e.Target, e.Player, Config.VisibilityRequirement, Config.DefaultFontSizeScalar);
}
[PluginEvent]
private void OnDetaining(PlayerRemoveHandcuffsEvent e)
{
if (Config.LogDetainEvents)
LogHandler.LogUnDetain(e.Target, e.Player, Config.VisibilityRequirement, Config.DefaultFontSizeScalar);
}
}

View File

@ -167,11 +167,19 @@ public static class LogHandler
_ => "[an unknown attack type]"
};
public static void LogLeavingScp(string role, float health, float hs, PlayerPermissions permissions, float defaultScalar) =>
Log(sizeScalar => $"{"SCP Left".Color("red").Bold()}#Please replace {role.Size(40.Scale(sizeScalar))} as the player has left the game.\n" +
public static void LogLeavingScp(string role, float health, float hs, PlayerPermissions permissions, float defaultScalar)
=> Log(sizeScalar => $"{"SCP Left".Color("red").Bold()}#Please replace {role.Size(40.Scale(sizeScalar))} as the player has left the game.\n" +
($"HP: {((int) health).ToString().Color("red")} " +
$"HS: {((int) hs).ToString().Color("purple")}").Size(35.Scale(sizeScalar)), false, permissions, defaultScalar);
public static void LogDetain(Player target, Player detainer, PlayerPermissions permissions, float defaultScalar)
=> Log(sizeScalar => $"{"CUFFING".Color("orange")}#{GetKillerStatus(detainer, sizeScalar)} {"detained".Color("orange").Size(30.Scale(sizeScalar))} {GetVictimStatus(target, sizeScalar)}",
true, permissions, defaultScalar);
public static void LogUnDetain(Player uncuffedPlayer, Player undetainer, PlayerPermissions permissions, float defaultScalar)
=> Log(sizeScalar => $"{"UNCUFFING".Color("red")}#{GetKillerStatus(undetainer, sizeScalar)} {"undetained".Color("red").Size(30.Scale(sizeScalar))} {GetVictimStatus(uncuffedPlayer, sizeScalar)}",
true, permissions, defaultScalar);
private static int Scale(this int number, float scalar) => (int) (number * scalar);
}

View File

@ -15,6 +15,7 @@ public sealed class ToggleLogsCommand : ICommand
public string Command => "toggleKillLogs";
public string[] Aliases { get; } = {"tkl"};
public string Description => "Toggles the visibility of kill logs or changes the font size scalar for the caller.";
public bool SanitizeResponse => false;
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{