winstxnhdw / lc-hax

A powerful, feature-rich and highly performant internal cheat for the co-op indie horror video game, Lethal Company.
77 stars 25 forks source link

[BUG]: Clear Chat #336

Closed D1GQ closed 4 months ago

D1GQ commented 5 months ago

For some reason the clear chat is only client-sided, that's why it's not working for example the mute command.

Problematic Code

    public static void Announce(string announcement, bool keepHistory = false) {
        if (Helper.LocalPlayer is not PlayerControllerB player) return;
        if (Helper.HUDManager is not HUDManager hudManager) return;

        string actualHistory = string.Join('\n', hudManager.ChatMessageHistory.Where(message =>
            !message.StartsWith("<color=#FF0000>USER</color>: <color=#FFFF00>'") &&
            !message.StartsWith("<color=#FF0000>SYSTEM</color>: <color=#FFFF00>'")
        ));

        string chatText = keepHistory ? $"{actualHistory}\n<color=#7069ff>{announcement}</color>" : announcement;

        hudManager.AddTextToChatOnServer(
            $"</color>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n{chatText}<color=#FFFFFF00>",
            (int)player.playerClientId
        );
    }

    public static void Clear() {
        Chat.Announce("");
    }
winstxnhdw commented 5 months ago

Strange. I'll look into it. It's weird because AddTextToChatOnServer works properly in the say command.

winstxnhdw commented 4 months ago

Fixed in latest.