mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-19 15:51:52 +00:00
fixed
This commit is contained in:
1 parent
596ce9e892
commit
5af7667c82
4 files changed
+64
-44
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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 = $"<color=#ffea00>{saveName}</color> {setReasonInfo}<size=0%>";
|
||||
player.SetName($"<color=#ffea00>{saveName}</color> {setReasonInfo}<size=0%>");
|
||||
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
|
||||
|
||||
@@ -36,6 +36,8 @@ public static class PlayerControlDataExtension
|
||||
|
||||
public static readonly Dictionary<string, ExtendedPlayerInfo> playerInfo = [];
|
||||
|
||||
public static void ClearData(this ExtendedPlayerInfo BetterData) => playerInfo[BetterData._Data.Puid] = new ExtendedPlayerInfo();
|
||||
|
||||
// Reset info when needed
|
||||
public static void ResetPlayerData(PlayerControl player)
|
||||
{
|
||||
|
||||
@@ -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<HudManager>.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<HudManager>.Instance.Notifier.AddDisconnectMessage(ReasonText);
|
||||
Logger.Log(ReasonText);
|
||||
|
||||
DestroyableSingleton<HudManager>.Instance.Notifier.AddDisconnectMessage(ReasonText);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Prefix()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user