Beispiel #1
0
        public async Task Update()
        {
            try
            {
                // Currently it seems this assembly loads way earlier than the Lua ever did
                // So SetTextChatEnabled has to be called at a later point than before
                // Not sure what would be a suitable solution, so temporarily
                // it's done on each tick... Overkill.
                NativeWrappers.SetTextChatEnabled(false);

                if (isChatScrollEnabled)
                {
                    if (Game.IsControlJustPressed(0, Control.ReplayCameraUp)) // PgUp
                    {
                        TriggerChatAction("scrollUp");
                    }
                    else if (Game.IsControlJustPressed(0, Control.ReplayCameraDown)) // PgDn
                    {
                        TriggerChatAction("scrollDown");
                    }
                }

                if (isChatInputActive && Game.IsDisabledControlPressed(0, Control.CursorScrollUp)) // Scrollwheel Up
                {
                    TriggerChatAction("scrollUp");
                }
                else if (isChatInputActive && Game.IsDisabledControlPressed(0, Control.CursorScrollDown)) // Scrollwheel Down
                {
                    TriggerChatAction("scrollDown");
                }

                if (Game.IsControlJustPressed(0, Control.FrontendCancel)) // Escape
                {
                    isChatInputActive     = false;
                    isChatInputActivating = false;
                    NativeWrappers.EnableControlAction(0, Control.CursorScrollUp, true);   // Scrollwheel Up
                    NativeWrappers.EnableControlAction(0, Control.CursorScrollDown, true); // Scrollwheel Down
                    NativeWrappers.SetPedCanSwitchWeapon(Game.PlayerPed, true);            // Disable weapon select
                    NativeWrappers.SetNuiFocus(false);

                    TriggerChatAction("forceCloseChatBox");
                }

                if (!isChatInputActive && Game.IsControlPressed(0, Control.MpTextChatAll))
                {
                    isChatInputActive     = true;
                    isChatInputActivating = true;
                    TriggerChatAction("openChatBox");
                }

                if (isChatInputActivating && !Game.IsControlPressed(0, Control.MpTextChatAll))
                {
                    NativeWrappers.SetNuiFocus(true);
                    isChatInputActivating = false;
                }

                if (isChatInputActive)
                {
                    TriggerChatAction("focusChatBox");
                    NativeWrappers.DisableControlAction(0, Control.CursorScrollUp, true);
                    NativeWrappers.DisableControlAction(0, Control.CursorScrollDown, true);
                    NativeWrappers.SetPedCanSwitchWeapon(Game.PlayerPed, false);
                }
            }
            catch (Exception ex)
            {
                Log.Error($"Chat Update ERROR: ${ex.Message}");
            }

            await Task.FromResult(0);
        }