diff --git a/Modules/AntiCheat.cs b/Modules/AntiCheat.cs
index e1fd693..b05d097 100644
--- a/Modules/AntiCheat.cs
+++ b/Modules/AntiCheat.cs
@@ -493,11 +493,11 @@ class AntiCheat
if (target.BetterData().TimesAttemptedKilled >= 5 && !target.IsAlive())
{
BetterNotificationManager.NotifyCheat(player, $"Invalid Action: Attempted To Ban Exploit");
- Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)} 2: {target.BetterData().CheckBanExploit} && {!target.IsAlive()}");
+ Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)} 2: {target.BetterData().TimesAttemptedKilled >= 5} && {!target.IsAlive()}");
return false;
}
- // Cancel murder on client
+ // Cancel murder on client if not alive
if (!target.IsAlive())
{
return false;
diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs
index 4871018..7ed2ece 100644
--- a/Modules/ExtendedPlayerControl.cs
+++ b/Modules/ExtendedPlayerControl.cs
@@ -108,23 +108,14 @@ static class ExtendedPlayerControl
return;
}
- player.BetterData().BannedByAntiCheat = AntiCheatBan && ban;
-
- NetworkedPlayerInfo playerInfo = player.Data;
- string saveName = player.BetterData().RealName;
-
if (setReasonInfo != "")
{
- playerInfo.PlayerName = $"{saveName} {setReasonInfo}";
- player.SetName($"{saveName} {setReasonInfo}");
+ GameDataShowNotificationPatch.BetterShowNotification(player.Data, forceReasonText: setReasonInfo);
}
AmongUsClient.Instance.KickPlayer(player.GetClientId(), ban);
- _ = new LateTask(() =>
- {
- playerInfo.PlayerName = saveName;
- }, 0.15f, shoudLog: false);
+ player.BetterData().BannedByAntiCheat = AntiCheatBan && ban;
}
// RPCs
diff --git a/Modules/ExtendedPlayerInfo.cs b/Modules/ExtendedPlayerInfo.cs
index d191192..de66476 100644
--- a/Modules/ExtendedPlayerInfo.cs
+++ b/Modules/ExtendedPlayerInfo.cs
@@ -36,6 +36,8 @@ public static class PlayerControlDataExtension
public static readonly Dictionary playerInfo = [];
+ public static void ClearData(this ExtendedPlayerInfo BetterData) => playerInfo[BetterData._Data.Puid] = new ExtendedPlayerInfo();
+
// Reset info when needed
public static void ResetPlayerData(PlayerControl player)
{
diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs
index 7e2463a..8784f25 100644
--- a/Patches/PlayerJoinAndLeftPatch.cs
+++ b/Patches/PlayerJoinAndLeftPatch.cs
@@ -35,8 +35,14 @@ public static class OnPlayerJoinedPatch
{
public static void Postfix(/*AmongUsClient __instance,*/ [HarmonyArgument(0)] ClientData client)
{
+ var player = Utils.PlayerFromClientId(client.Id);
PlayerControlPatch.infotime = 0f;
+ if (player != null)
+ {
+ player.BetterData().ClearData();
+ }
+
_ = new LateTask(() =>
{
if (GameStates.IsInGame)
@@ -52,7 +58,6 @@ public static class OnPlayerJoinedPatch
// Auto ban player on ban list
if (Main.UseBannedList.Value)
{
- var player = Utils.PlayerFromClientId(client.Id);
if (player != null)
{
try
@@ -121,46 +126,68 @@ class GameDataHandleDisconnectPatch
public static void Prefix(/*GameData __instance,*/ [HarmonyArgument(0)] PlayerControl player, [HarmonyArgument(1)] DisconnectReasons reason)
{
player.BetterData().DisconnectReason = reason;
+
+ GameDataShowNotificationPatch.BetterShowNotification(player.Data, reason);
}
}
[HarmonyPatch(typeof(GameData), nameof(GameData.ShowNotification))]
class GameDataShowNotificationPatch
-{
- public static bool Prefix(/*GameData __instance,*/ ref string playerName, ref DisconnectReasons reason)
+{
+ public static void BetterShowNotification(NetworkedPlayerInfo playerData, DisconnectReasons reason = DisconnectReasons.Unknown, string forceReasonText = "")
{
- string ReasonText;
- switch (reason)
+ if (playerData.BetterData().BannedByAntiCheat) return;
+
+ string playerName = playerData.BetterData().RealName;
+
+ if (forceReasonText != "")
{
- case DisconnectReasons.ExitGame:
- ReasonText = $"{playerName} Left the game!";
- break;
- case DisconnectReasons.ClientTimeout:
- ReasonText = $"{playerName} Disconnected!";
- break;
- case DisconnectReasons.Kicked:
- ReasonText = $"{playerName} Was kicked by {AmongUsClient.Instance.GetHost().Character.Data.PlayerName}!";
- break;
- case DisconnectReasons.Banned:
- ReasonText = $"{playerName} Was banned by {AmongUsClient.Instance.GetHost().Character.Data.PlayerName}!";
- break;
- case DisconnectReasons.Hacking:
- ReasonText = $"{playerName} Was banned by Innersloth Anti-Cheat!";
- break;
- case DisconnectReasons.Error:
- ReasonText = $"{playerName} Was kicked due to an error!";
- break;
- case DisconnectReasons.Unknown:
- ReasonText = $"{playerName} Left the game due to unknown reason?";
- break;
- default:
- ReasonText = $"{playerName} Left the game!";
- break;
+ var ReasonText = $"{playerData.BetterData().RealName} {forceReasonText}";
+
+ Logger.Log(ReasonText);
+
+ DestroyableSingleton.Instance.Notifier.AddDisconnectMessage(ReasonText);
}
+ else
+ {
+ string ReasonText;
- Logger.Log(ReasonText);
+ switch (reason)
+ {
+ case DisconnectReasons.ExitGame:
+ ReasonText = $"{playerName} Left the game!";
+ break;
+ case DisconnectReasons.ClientTimeout:
+ ReasonText = $"{playerName} Disconnected!";
+ break;
+ case DisconnectReasons.Kicked:
+ ReasonText = $"{playerName} Was kicked by {AmongUsClient.Instance.GetHost().Character.Data.PlayerName}!";
+ break;
+ case DisconnectReasons.Banned:
+ ReasonText = $"{playerName} Was banned by {AmongUsClient.Instance.GetHost().Character.Data.PlayerName}!";
+ break;
+ case DisconnectReasons.Hacking:
+ ReasonText = $"{playerName} Was banned by Innersloth Anti-Cheat!";
+ break;
+ case DisconnectReasons.Error:
+ ReasonText = $"{playerName} Was kicked due to an error!";
+ break;
+ case DisconnectReasons.Unknown:
+ ReasonText = $"{playerName} Left the game due to unknown reason?";
+ break;
+ default:
+ ReasonText = $"{playerName} Left the game!";
+ break;
+ }
- DestroyableSingleton.Instance.Notifier.AddDisconnectMessage(ReasonText);
+ Logger.Log(ReasonText);
+
+ DestroyableSingleton.Instance.Notifier.AddDisconnectMessage(ReasonText);
+ }
+ }
+
+ public static bool Prefix()
+ {
return false;
}
}