internal void HandleChatResult(System.Dynamic.ExpandoObject data) { try { // The below might be handled by the Controls class when implemented TriggerChatAction("scrollBottom"); NativeWrappers.EnableControlAction(0, Control.CursorScrollUp, true); NativeWrappers.EnableControlAction(0, Control.CursorScrollDown, true); NativeWrappers.SetPedCanSwitchWeapon(Game.PlayerPed, true); NativeWrappers.SetNuiFocus(false); isChatInputActive = false; IDictionary <string, object> chatResult = data; if (!chatResult.ContainsKey("message") || string.IsNullOrWhiteSpace((string)chatResult["message"])) { return; } string Message = (String)chatResult["message"]; var spaceSplit = Message.Split(' '); if (Message.Substring(0, 1) == "/" && Message.Length >= 2) { TriggerEvent("Chat.CommandEntered", Message); // If we want the user to see the command they just entered //TriggerEvent("Chat.Message", "COMMAND", "#888888", Message); } else { // Commented as we want local chat by default //TriggerServerEvent("Chat.MessageEntered", Game.Player.Name, chatMessageColor, Message); //Debug.WriteLine("Sending local chat"); PointEvent pointEvent = new PointEvent("Communication.LocalChat", CitizenFX.Core.Game.PlayerPed.Position.ToArray(), localChatAoe, Message, Game.Player.ServerId, false); BaseScript.TriggerServerEvent("TriggerEventNearPoint", FamilyRP.Roleplay.Client.Helpers.MsgPack.Serialize(pointEvent)); } } catch (Exception ex) { Log.Error($"HandleChatResult ERROR: ${ex.Message}"); } }
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); }