BAU User Verification Mark and use IsLocalPlayer

This commit is contained in:
D1GQ committed 2024-09-08 13:23:33 -05:00
1 parent 2b91761eb7
commit deaf46b512
10 files changed
+38 -39

No files matched your search

+5 -5
View File
@@ -100,7 +100,7 @@ class AntiCheat
{
MessageReader reader = MessageReader.Get(Oldreader);
if (player == PlayerControl.LocalPlayer || PlayerControl.LocalPlayer == null || player == null || !IsEnabled) return;
if (player.IsLocalPlayer() || player == null || !IsEnabled) return;
if (callId is unchecked((byte)CustomRPC.Sicko) && Main.AntiCheat.Value && BetterGameSettings.DetectCheatClients.GetBool())
{
@@ -182,7 +182,7 @@ class AntiCheat
{
MessageReader reader = MessageReader.Get(Oldreader);
if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.BetterData().IsBetterHost || reader == null || !IsEnabled || !Main.AntiCheat.Value
if (player == null || player.IsLocalPlayer() || player.BetterData().IsBetterHost || reader == null || !IsEnabled || !Main.AntiCheat.Value
|| (GameStates.IsBetterHostLobby && !GameStates.IsHost) || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return;
RoleTypes? Role = player?.Data?.RoleType;
@@ -352,7 +352,7 @@ class AntiCheat
}
}
if (!GameStates.IsHost || PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.BetterData().IsBetterHost || !IsEnabled || !Main.AntiCheat.Value
if (!GameStates.IsHost || PlayerControl.LocalPlayer == null || player == null || player.IsLocalPlayer() || player.BetterData().IsBetterHost || !IsEnabled || !Main.AntiCheat.Value
|| (GameStates.IsBetterHostLobby && !GameStates.IsHost) || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return true;
if (!BetterGameSettings.CancelInvalidSabotage.GetBool())
@@ -478,7 +478,7 @@ class AntiCheat
{
MessageReader reader = MessageReader.Get(Oldreader);
if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.BetterData().IsBetterHost || reader == null) return true;
if (PlayerControl.LocalPlayer == null || player == null || player.IsLocalPlayer() || player.BetterData().IsBetterHost || reader == null) return true;
// Prevent ban exploit
if (callId is (byte)RpcCalls.MurderPlayer)
@@ -489,7 +489,7 @@ class AntiCheat
if (target != null)
{
if (target == PlayerControl.LocalPlayer)
if (target.IsLocalPlayer())
{
target.BetterData().AntiCheatInfo.TimesAttemptedKilled++;
+2 -2
View File
@@ -206,7 +206,7 @@ class BetterHostManager
foreach (PlayerControl target in Main.AllPlayerControls)
{
if (target == null || target == PlayerControl.LocalPlayer) continue;
if (target == null || target.IsLocalPlayer()) continue;
string NewName = player.CurrentOutfit.PlayerName;
@@ -224,7 +224,7 @@ class BetterHostManager
if (player.IsDev())
sbTopTag.Append("<color=#6e6e6e>(<color=#0088ff>Dev</color>)</color>+++");
if (player == PlayerControl.LocalPlayer)
if (player.IsLocalPlayer())
sbTopTag.Append($"<color=#0dff00>Better Host</color>+++");
else if (player.BetterData().IsBetterUser)
sbTopTag.Append("<color=#0dff00>Better User</color>+++");
+9 -10
View File
@@ -68,7 +68,6 @@ static class ExtendedPlayerControl
textObj.text = text;
}
}
// Reset players over head text
public static void ResetAllPlayerTextInfo(this PlayerControl player)
{
@@ -99,7 +98,6 @@ static class ExtendedPlayerControl
}
return true;
}
// Kick player
public static void Kick(this PlayerControl player, bool ban = false, string setReasonInfo = "", bool AntiCheatBan = false)
{
@@ -127,7 +125,7 @@ static class ExtendedPlayerControl
player.BetterData().AntiCheatInfo.BannedByAntiCheat = AntiCheatBan;
}
// Set color outline on player
public static void SetOutline(this PlayerControl player, bool active, Color? color = null)
{
player.cosmetics.currentBodySprite.BodySprite.material.SetFloat("_Outline", (float)(active ? 1 : 0));
@@ -146,6 +144,7 @@ static class ExtendedPlayerControl
}
}
}
// Set color outline on player
public static void SetOutlineByHex(this PlayerControl player, bool active, string hexColor = "")
{
Color color = Utils.HexToColor32(hexColor);
@@ -165,26 +164,27 @@ static class ExtendedPlayerControl
}
}
}
// RPCs
// Set name for Target
public static void RpcSetNamePrivate(this PlayerControl player, string name, PlayerControl target)
{
if (player == null || target == null) return;
RPC.SetNamePrivate(player, name, target);
}
// Exile player
public static void RpcExile(this PlayerControl player)
{
if (player == null) return;
RPC.ExileAsync(player);
}
// Check if player is selecting room to spawn in, for Airship
public static bool IsInRoomSelect(this PlayerControl player)
{
if (player == null) return false;
return GameStates.AirshipIsActive && Vector2.Distance(player.GetTruePosition(), new(-25, 40)) < 5f;
}
// Check if player controller is self client
public static bool IsLocalPlayer(this PlayerControl player) => player != null && PlayerControl.LocalPlayer != null && player == PlayerControl.LocalPlayer;
// Get vent Id that the player is in.
public static int GetPlayerVentId(this PlayerControl player)
{
@@ -196,9 +196,8 @@ static class ExtendedPlayerControl
return ventilationSystem.PlayersInsideVents.TryGetValue(player.PlayerId, out var playerIdVentId) ? playerIdVentId : -1;
}
// Get true position
public static Vector2 GetCustomPosition(this PlayerControl player) => new(player.transform.position.x, player.transform.position.y);
// Check if player is a dev
public static bool IsDev(this PlayerControl player) => player != null && Main.DevUser.Contains($"{Utils.GetHashPuid(player)}+{player.Data.FriendCode}");
// Check if player is alive
@@ -254,7 +253,7 @@ static class ExtendedPlayerControl
// Check if player is a imposter teammate
public static bool IsImpostorTeammate(this PlayerControl player) =>
player != null && PlayerControl.LocalPlayer != null &&
((player == PlayerControl.LocalPlayer && PlayerControl.LocalPlayer.IsImpostorTeam()) ||
((player.IsLocalPlayer() && PlayerControl.LocalPlayer.IsImpostorTeam()) ||
(PlayerControl.LocalPlayer.IsImpostorTeam() && player.IsImpostorTeam()));
// Check if player is in the Anti-Cheat list
public static bool IsCheater(this PlayerControl player) =>
+4 -4
View File
@@ -98,7 +98,7 @@ internal static class RPC
return;
}
foreach (var player in Main.AllPlayerControls.Where(pc => pc != PlayerControl.LocalPlayer))
foreach (var player in Main.AllPlayerControls.Where(pc => !pc.IsLocalPlayer()))
{
var optionsByteArray = GameOptionsManager.Instance.gameOptionsFactory.ToBytes(GameOptionsManager.Instance.CurrentGameOptions, false);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SyncSettings, SendOption.None, player.GetClientId());
@@ -151,7 +151,7 @@ internal static class RPC
public static void HandleCustomRPC(PlayerControl player, byte callId, MessageReader oldReader)
{
if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.Data == null) return;
if (player == null || player.IsLocalPlayer() || player.Data == null) return;
if (!Enum.IsDefined(typeof(CustomRPC), (int)unchecked(callId))) return;
@@ -209,7 +209,7 @@ internal static class RPC
public static void HandleRPC(PlayerControl player, byte callId, MessageReader oldReader)
{
if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.Data == null) return;
if (player == null || player.IsLocalPlayer() || player.Data == null) return;
MessageReader reader = MessageReader.Get(oldReader);
@@ -223,7 +223,7 @@ internal static class RPC
case (byte)RpcCalls.SendChat:
var text = reader.ReadString();
if (player.IsHost() && player != PlayerControl.LocalPlayer)
if (player.IsHost() && !player.IsLocalPlayer())
{
if (text.ToLower() == "/allow")
{
+5 -5
View File
@@ -131,7 +131,7 @@ class ChatPatch
pooledBubble.transform.SetParent(__instance.scroller.Inner);
pooledBubble.transform.localScale = Vector3.one;
bool flag = sourcePlayer == PlayerControl.LocalPlayer;
bool flag = sourcePlayer.IsLocalPlayer();
if (flag)
{
pooledBubble.SetRight();
@@ -176,10 +176,10 @@ class ChatPatch
if (sourcePlayer.IsDev())
sbTag.Append("<color=#0088ff>Dev</color>+++");
if (((sourcePlayer == PlayerControl.LocalPlayer && GameStates.IsHost && Main.BetterHost.Value)
|| (sourcePlayer != PlayerControl.LocalPlayer && sourcePlayer.BetterData().IsBetterHost && sourcePlayer.IsHost())))
if (((sourcePlayer.IsLocalPlayer() && GameStates.IsHost && Main.BetterHost.Value)
|| (!sourcePlayer.IsLocalPlayer() && sourcePlayer.BetterData().IsBetterHost && sourcePlayer.IsHost())))
sbTag.Append("<color=#0dff00>Better Host</color>+++");
else if ((sourcePlayer == PlayerControl.LocalPlayer || sourcePlayer.BetterData().IsBetterUser))
else if ((sourcePlayer.IsLocalPlayer() || sourcePlayer.BetterData().IsBetterUser))
sbTag.Append("<color=#0dff00>Better User</color>+++");
if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.SickoData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.SickoData.ContainsValue(friendCode))
@@ -192,7 +192,7 @@ class ChatPatch
if (!sourcePlayer.IsImpostorTeammate())
{
if (PlayerControl.LocalPlayer.IsAlive() && sourcePlayer != PlayerControl.LocalPlayer)
if (PlayerControl.LocalPlayer.IsAlive() && !sourcePlayer.IsLocalPlayer())
{
Role = "";
}
+1 -1
View File
@@ -347,7 +347,7 @@ class CommandsPatch
else if (HandlePlayerArgument(command, subArgs) == true)
{
var player = cmdTarget;
if (player == PlayerControl.LocalPlayer)
if (player.IsLocalPlayer())
{
Utils.AddChatPrivate($"<color=#730000>{error}\nUnable to use /SetRole for self, use /Role!");
return;
+1 -1
View File
@@ -153,7 +153,7 @@ class MeetingHudUpdatePatch
}
if (!target.IsImpostorTeammate())
{
if (PlayerControl.LocalPlayer.IsAlive() && target != PlayerControl.LocalPlayer)
if (PlayerControl.LocalPlayer.IsAlive() && !target.IsLocalPlayer())
{
if (!DebugMenu.RevealRoles)
{
+1 -1
View File
@@ -32,7 +32,7 @@ public class PingTrackerPatch
sb.Append($"<color=#00dbdb><size=75%>BetterAmongUs {Main.GetVersionText(true)}</size></color>\n");
// sb.Append("<size=68%><color=#8040bf>By</color> <color=#bc4345>The Enhanced Network</color></size>\n");
sb.Append($"<size=50%><color=#6a6a6a>{Main.Github}</color></size>\n");
sb.Append($"<size=50%><color=#b5b5b5>{Main.Github}</color></size>\n");
if (Main.BetterHost.Value && GameStates.IsHost)
{
+8 -8
View File
@@ -172,11 +172,11 @@ class PlayerControlPatch
if (player.IsDev() && !GameStates.IsInGamePlay)
sbTag.Append("<color=#6e6e6e>(<color=#0088ff>Dev</color>)</color>+++");
if (((player == PlayerControl.LocalPlayer && GameStates.IsHost && Main.BetterHost.Value)
|| (player != PlayerControl.LocalPlayer && player.BetterData().IsBetterHost && player.IsHost())) && !GameStates.IsInGamePlay)
sbTag.Append("<color=#0dff00>Better Host</color>+++");
else if ((player == PlayerControl.LocalPlayer || player.BetterData().IsBetterUser) && !GameStates.IsInGamePlay)
sbTag.Append("<color=#0dff00>Better User</color>+++");
if (((player.IsLocalPlayer() && GameStates.IsHost && Main.BetterHost.Value)
|| (!player.IsLocalPlayer() && player.BetterData().IsBetterHost && player.IsHost())) && !GameStates.IsInGamePlay)
sbTag.AppendFormat("<color=#0dff00>{0}Better Host</color>+++", player.BetterData().IsVerifiedBetterUser || player.IsLocalPlayer() ? "✓ " : "");
else if ((player.IsLocalPlayer() || player.BetterData().IsBetterUser) && !GameStates.IsInGamePlay)
sbTag.AppendFormat("<color=#0dff00>{0}Better User</color>+++", player.BetterData().IsVerifiedBetterUser || player.IsLocalPlayer() ? "✓ " : "");
sbTag.Append($"<color=#b554ff>ID: {player.PlayerId}</color>+++");
sbTagTop.Append($"<color=#9e9e9e>{platform}</color>+++");
@@ -187,7 +187,7 @@ class PlayerControlPatch
}
else if ((GameStates.IsInGame || GameStates.IsFreePlay) && !GameStates.IsHideNSeek)
{
if (player.IsImpostorTeammate() || player == PlayerControl.LocalPlayer || !PlayerControl.LocalPlayer.IsAlive() || DebugMenu.RevealRoles)
if (player.IsImpostorTeammate() || player.IsLocalPlayer() || !PlayerControl.LocalPlayer.IsAlive() || DebugMenu.RevealRoles)
{
string Role = $"<color={player.GetTeamHexColor()}>{player.GetRoleName()}</color>";
if (!player.IsImpostorTeam() && player.myTasks.Count > 0)
@@ -203,7 +203,7 @@ class PlayerControlPatch
}
else if (GameStates.IsInGame || GameStates.IsFreePlay)
{
if (player == PlayerControl.LocalPlayer)
if (player.IsLocalPlayer())
{
if (player.IsImpostorTeam())
{
@@ -216,7 +216,7 @@ class PlayerControlPatch
}
}
if (player.IsImpostorTeammate() && player != PlayerControl.LocalPlayer)
if (player.IsImpostorTeammate() && !player.IsLocalPlayer())
{
NewName = $"<color=#ff1919>{player.Data.PlayerName}</color>";
}
+2 -2
View File
@@ -92,7 +92,7 @@ public class RoleManagerPatch
// Override player role assignment
if (SetPlayerRole.Keys.Any())
{
foreach (var kvp in SetPlayerRole.Where(kvp => kvp.Key != null).OrderBy(kvp => kvp.Key == PlayerControl.LocalPlayer ? 0 : 1))
foreach (var kvp in SetPlayerRole.Where(kvp => kvp.Key != null).OrderBy(kvp => kvp.Key.IsLocalPlayer() ? 0 : 1))
{
var player = kvp.Key;
var role = kvp.Value;
@@ -311,7 +311,7 @@ public class RoleManagerPatch
// Override player role assignment
if (SetPlayerRole.Keys.Any())
{
foreach (var kvp in SetPlayerRole.Where(kvp => kvp.Key != null).OrderBy(kvp => kvp.Key == PlayerControl.LocalPlayer ? 0 : 1))
foreach (var kvp in SetPlayerRole.Where(kvp => kvp.Key != null).OrderBy(kvp => kvp.Key.IsLocalPlayer() ? 0 : 1))
{
var player = kvp.Key;
var role = kvp.Value;