fix better rpc

This commit is contained in:
D1GQ committed 2024-08-17 09:19:08 -05:00
1 parent 27ea4abb7f
commit 904c4239ab
5 files changed
+16 -16

No files matched your search

+5
View File
@@ -53,6 +53,11 @@ public class DebugMenu : MonoBehaviour
BetterDataManager.ClearCheatData();
});
AddButtonToTab(Main, "Send Better RPC", () =>
{
RPC.SendBetterCheck();
}, true);
AddButtonToTab(HostOnly, "Sync All Names", () =>
{
RPC.SyncAllNames();
+6 -6
View File
@@ -81,8 +81,8 @@ internal static class RPC
public static void SendBetterCheck()
{
var flag = GameStates.IsHost && Main.BetterHost.Value;
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, unchecked((byte)CustomRPC.BetterCheck), SendOption.None, -1);
messageWriter.Write((byte)PlayerControl.LocalPlayer.NetId);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.BetterCheck, SendOption.None, -1);
messageWriter.Write(true);
messageWriter.Write(flag);
messageWriter.Write(Main.GetVersionText().Replace(" ", ""));
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
@@ -91,7 +91,7 @@ internal static class RPC
public static void SetNamePrivate(PlayerControl player, string name, PlayerControl target)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetName, SendOption.Reliable, target.GetClientId());
writer.Write(player.NetId);
writer.Write(player.Data.NetId);
writer.Write(name);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
@@ -167,17 +167,17 @@ internal static class RPC
switch (callId)
{
case (byte)CustomRPC.BetterCheck:
if (reader.ReadByte() == player.Data.NetId)
{
var SetBetterUser = reader.ReadBoolean();
var IsBetterHost = reader.ReadBoolean();
if (!player.IsHost() && IsBetterHost)
{
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)} called as BetterHost");
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((CustomRPC)callId)} called as BetterHost");
break;
}
player.BetterData().IsBetterUser = true;
player.BetterData().IsBetterUser = SetBetterUser;
player.BetterData().IsBetterHost = IsBetterHost;
}
break;
+1
View File
@@ -46,6 +46,7 @@ class GamePlayManager
if (GameStates.IsInGame)
{
RPC.SyncAllNames(force: true);
RPC.SendBetterCheck();
}
}, 1.5f, "LobbyBehaviourPatch SyncAllNames");
}
+2 -1
View File
@@ -160,7 +160,8 @@ 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.BetterData().IsBetterHost) && !GameStates.IsInGamePlay)
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>+++");
+2 -9
View File
@@ -11,6 +11,8 @@ class OnGameJoinedPatch
{
try
{
PlayerControlExtensions.playerInfo.Clear();
PlayerControlPatch.infotime = 0f;
AntiCheat.PauseAntiCheat();
@@ -23,15 +25,6 @@ class OnGameJoinedPatch
host.SetColor(host.CurrentOutfit.ColorId);
}
_ = new LateTask(() =>
{
// Send Better Among Us Check RPC
if (GameStates.IsInGame)
{
RPC.SendBetterCheck();
}
}, 1.5f, "OnGameJoinedPatch");
Logger.Log($"Successfully joined {GameCode.IntToGameName(AmongUsClient.Instance.GameId)}", "OnGameJoinedPatch");
}
catch { };