toggle command + more weapons + leaving SCP log
This commit is contained in:
parent
cceb3473be
commit
0ff218530b
@ -46,6 +46,9 @@
|
|||||||
<Reference Include="Axwabo.Helpers.NWAPI">
|
<Reference Include="Axwabo.Helpers.NWAPI">
|
||||||
<HintPath>..\..\assemblies\Axwabo.Helpers.dll</HintPath>
|
<HintPath>..\..\assemblies\Axwabo.Helpers.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="CommandSystem.Core">
|
||||||
|
<HintPath>..\..\..\pluginz\assemblies\CommandSystem.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Microsoft.CodeAnalysis, Version=3.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.CodeAnalysis, Version=3.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.3.3.1\lib\netstandard2.0\Microsoft.CodeAnalysis.dll</HintPath>
|
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.3.3.1\lib\netstandard2.0\Microsoft.CodeAnalysis.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -109,6 +112,7 @@
|
|||||||
<Compile Include="DeathLogPlugin.cs"/>
|
<Compile Include="DeathLogPlugin.cs"/>
|
||||||
<Compile Include="LogHandler.cs"/>
|
<Compile Include="LogHandler.cs"/>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs"/>
|
<Compile Include="Properties\AssemblyInfo.cs"/>
|
||||||
|
<Compile Include="ToggleLogsCommand.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config"/>
|
<None Include="packages.config"/>
|
||||||
|
@ -6,4 +6,6 @@ public sealed class DeathLogConfig {
|
|||||||
|
|
||||||
public PlayerPermissions VisibilityRequirement { get; set; } = PlayerPermissions.Overwatch;
|
public PlayerPermissions VisibilityRequirement { get; set; } = PlayerPermissions.Overwatch;
|
||||||
|
|
||||||
|
public bool LogLeavingScpPlayers { get; set; } = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
using PlayerStatsSystem;
|
using Axwabo.Helpers;
|
||||||
|
using PlayerRoles.PlayableScps;
|
||||||
|
using PlayerStatsSystem;
|
||||||
using PluginAPI.Core;
|
using PluginAPI.Core;
|
||||||
using PluginAPI.Core.Attributes;
|
using PluginAPI.Core.Attributes;
|
||||||
using PluginAPI.Enums;
|
using PluginAPI.Enums;
|
||||||
|
using Respawning;
|
||||||
|
|
||||||
namespace DeathLog;
|
namespace DeathLog;
|
||||||
|
|
||||||
@ -22,12 +25,50 @@ public sealed class DeathLogPlugin {
|
|||||||
[PluginConfig]
|
[PluginConfig]
|
||||||
public DeathLogConfig Config = new();
|
public DeathLogConfig Config = new();
|
||||||
|
|
||||||
|
private bool _spawnWaveOccurred;
|
||||||
|
|
||||||
|
[PluginEvent(ServerEventType.RoundStart)]
|
||||||
|
private void OnRoundStarted() {
|
||||||
|
_spawnWaveOccurred = false;
|
||||||
|
_lastId = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
[PluginEvent(ServerEventType.TeamRespawn)]
|
||||||
|
private void OnTeamRespawn(SpawnableTeamType team) => _spawnWaveOccurred = true;
|
||||||
|
|
||||||
|
private static bool IsUnknownCause(DamageHandlerBase handler) =>
|
||||||
|
handler is UniversalDamageHandler udh && udh.TranslationId == DeathTranslations.Unknown.Id;
|
||||||
|
|
||||||
[PluginEvent(ServerEventType.PlayerDying)]
|
[PluginEvent(ServerEventType.PlayerDying)]
|
||||||
public void OnPlayerDeath(Player player, Player attacker, DamageHandlerBase handler) {
|
private void OnPlayerDeath(Player player, Player attacker, DamageHandlerBase handler) {
|
||||||
if (attacker != null && handler is AttackerDamageHandler adh)
|
if (attacker != null && handler is AttackerDamageHandler adh)
|
||||||
LogHandler.LogAttackerDeathMessage(player, attacker, adh, Config.VisibilityRequirement);
|
LogHandler.LogAttackerDeathMessage(player, attacker, adh, Config.VisibilityRequirement);
|
||||||
else if (Config.LogSimpleDeaths)
|
else if (Config.LogSimpleDeaths)
|
||||||
LogHandler.LogSimpleDeathMessage(player, handler, Config.VisibilityRequirement);
|
LogHandler.LogSimpleDeathMessage(player, handler, Config.VisibilityRequirement);
|
||||||
|
if (!IsUnknownCause(handler) || player.ReferenceHub.roleManager.CurrentRole is not FpcStandardScp scp)
|
||||||
|
return;
|
||||||
|
_lastRole = scp.RoleName.Color(scp.RoleColor.ToHex());
|
||||||
|
_lastId = player.UserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
[PluginEvent(ServerEventType.PlayerDamage)]
|
||||||
|
private void OnDamage(Player player, Player attacker, DamageHandlerBase handler) {
|
||||||
|
if (!IsUnknownCause(handler) || player.ReferenceHub.roleManager.CurrentRole is not FpcStandardScp)
|
||||||
|
return;
|
||||||
|
var stats = player.ReferenceHub.playerStats;
|
||||||
|
_lastHealth = stats.GetModule<HealthStat>().CurValue;
|
||||||
|
_lastHumeShield = stats.GetModule<HumeShieldStat>().CurValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _lastRole = "";
|
||||||
|
private float _lastHealth;
|
||||||
|
private float _lastHumeShield;
|
||||||
|
private string _lastId;
|
||||||
|
|
||||||
|
[PluginEvent(ServerEventType.PlayerLeft)]
|
||||||
|
private void OnPlayerLeave(Player player) {
|
||||||
|
if (!_spawnWaveOccurred && Config.LogLeavingScpPlayers && player.UserId == _lastId)
|
||||||
|
LogHandler.LogLeavingScp(_lastRole, _lastHealth, _lastHumeShield, Config.VisibilityRequirement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,10 @@ public static class LogHandler {
|
|||||||
or ItemType.GunShotgun
|
or ItemType.GunShotgun
|
||||||
or ItemType.GunLogicer
|
or ItemType.GunLogicer
|
||||||
or ItemType.ParticleDisruptor
|
or ItemType.ParticleDisruptor
|
||||||
or ItemType.Jailbird;
|
or ItemType.Jailbird
|
||||||
|
or ItemType.GrenadeHE
|
||||||
|
or ItemType.SCP018
|
||||||
|
or ItemType.MicroHID;
|
||||||
|
|
||||||
public static void LogSimpleDeathMessage(Player player, DamageHandlerBase handler, PlayerPermissions permissions) => Log("DEATH LOG" + "#" + string.Format(
|
public static void LogSimpleDeathMessage(Player player, DamageHandlerBase handler, PlayerPermissions permissions) => Log("DEATH LOG" + "#" + string.Format(
|
||||||
GetDeathMessage(handler),
|
GetDeathMessage(handler),
|
||||||
@ -32,10 +35,10 @@ public static class LogHandler {
|
|||||||
), true, permissions);
|
), true, permissions);
|
||||||
|
|
||||||
private static string GetDeathMessage(DamageHandlerBase handler) => handler switch {
|
private static string GetDeathMessage(DamageHandlerBase handler) => handler switch {
|
||||||
CustomReasonDamageHandler custom => $"{{0}} has died: {custom._deathReason.Bold().Color("orange").Size(30)}",
|
CustomReasonDamageHandler custom => $"{{0}} has died: {custom._deathReason.Bold().Color("#00FF00").Size(30)}",
|
||||||
UniversalDamageHandler universal => $"{{0}} has died. Reason: {universal._logsText.TrimEnd('.').Bold().Color("orange").Size(30)}",
|
UniversalDamageHandler universal => $"{{0}} has died. Reason: {universal._logsText.TrimEnd('.').Bold().Color("#00FF00").Size(30)}",
|
||||||
WarheadDamageHandler => $"{{0}} died to {"the Alpha Warhead".Bold().Color("orange").Size(30)}",
|
WarheadDamageHandler => $"{{0}} died to {"the Alpha Warhead".Bold().Color("#00FF00").Size(30)}",
|
||||||
_ => $"{{0}} has died. {"Reason is unknown".Italic()}"
|
_ => $"{{0}} has died. {"Reason is unknown".Italic().Color("#00FF00")}"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void LogAttackerDeathMessage(Player victim, Player attacker, AttackerDamageHandler handler, PlayerPermissions permissions) {
|
public static void LogAttackerDeathMessage(Player victim, Player attacker, AttackerDamageHandler handler, PlayerPermissions permissions) {
|
||||||
@ -59,7 +62,7 @@ public static class LogHandler {
|
|||||||
private static void Log(string msg, bool success, PlayerPermissions playerPermissions) {
|
private static void Log(string msg, bool success, PlayerPermissions playerPermissions) {
|
||||||
foreach (var p in Player.GetPlayers()) {
|
foreach (var p in Player.GetPlayers()) {
|
||||||
var sender = p.ReferenceHub.queryProcessor._sender;
|
var sender = p.ReferenceHub.queryProcessor._sender;
|
||||||
if (p.RemoteAdminAccess && PermissionsHandler.IsPermitted(sender.Permissions, playerPermissions))
|
if (p.RemoteAdminAccess && PermissionsHandler.IsPermitted(sender.Permissions, playerPermissions) && !ToggleLogsCommand.HiddenIdList.Contains(sender.SenderId))
|
||||||
sender.RaReply(msg, success, true, "");
|
sender.RaReply(msg, success, true, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +120,7 @@ public static class LogHandler {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static string GetScp049AttackType(Scp049DamageHandler scp049) => scp049.DamageSubType switch {
|
private static string GetScp049AttackType(Scp049DamageHandler scp049) => scp049.DamageSubType switch {
|
||||||
Scp049DamageHandler.AttackType.Instakill => "SCP-049 Instakill",
|
Scp049DamageHandler.AttackType.Instakill => "Instakill",
|
||||||
Scp049DamageHandler.AttackType.Scp0492 => "SCP-049-2",
|
Scp049DamageHandler.AttackType.Scp0492 => "SCP-049-2",
|
||||||
Scp049DamageHandler.AttackType.CardiacArrest => "Cardiac Arrest",
|
Scp049DamageHandler.AttackType.CardiacArrest => "Cardiac Arrest",
|
||||||
_ => "[an unknown attack type]"
|
_ => "[an unknown attack type]"
|
||||||
@ -130,4 +133,9 @@ public static class LogHandler {
|
|||||||
_ => "[an unknown attack type]"
|
_ => "[an unknown attack type]"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static void LogLeavingScp(string role, float health, float hs, PlayerPermissions permissions) =>
|
||||||
|
Log($"{"SCP Left".Color("red").Bold()}#Please replace {role.Size(40)} as the player has left the game.\n" +
|
||||||
|
($"HP: {((int) health).ToString().Color("red")} " +
|
||||||
|
$"HS: {((int) hs).ToString().Color("purple")}").Size(35), false, permissions);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
49
DeathLog/ToggleLogsCommand.cs
Normal file
49
DeathLog/ToggleLogsCommand.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using CommandSystem;
|
||||||
|
using RemoteAdmin;
|
||||||
|
|
||||||
|
namespace DeathLog;
|
||||||
|
|
||||||
|
[CommandHandler(typeof(RemoteAdminCommandHandler))]
|
||||||
|
public sealed class ToggleLogsCommand : ICommand {
|
||||||
|
|
||||||
|
public static readonly HashSet<string> HiddenIdList = new();
|
||||||
|
|
||||||
|
public string Command => "toggleKillLogs";
|
||||||
|
public string[] Aliases { get; } = {"tkl"};
|
||||||
|
public string Description => "Toggles the visibility of kill logs for the caller.";
|
||||||
|
|
||||||
|
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response) {
|
||||||
|
if (sender is not PlayerCommandSender {ReferenceHub.characterClassManager.UserId: var id}) {
|
||||||
|
response = "You must be a player to use this command.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments.Count < 1) {
|
||||||
|
if (HiddenIdList.Add(id))
|
||||||
|
response = "You will no longer see kill logs.";
|
||||||
|
else {
|
||||||
|
HiddenIdList.Remove(id);
|
||||||
|
response = "You will now see kill logs.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (arguments.At(0).ToLower()) {
|
||||||
|
case "on" or "enable" or "true" or "1":
|
||||||
|
HiddenIdList.Remove(id);
|
||||||
|
response = "You will now see kill logs.";
|
||||||
|
return true;
|
||||||
|
case "off" or "disable" or "false" or "0":
|
||||||
|
HiddenIdList.Add(id);
|
||||||
|
response = "You will no longer see kill logs.";
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
response = "Invalid argument.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user