From 99e9b9ad62bb38ed559c62bc3847841ffc8475f6 Mon Sep 17 00:00:00 2001 From: "Adam Volkman (maku)" <68100107+itIsMaku@users.noreply.github.com> Date: Sat, 8 Jun 2024 00:46:39 +0200 Subject: [PATCH 1/2] feat(client/main): hud toggle fun expose --- client/main.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/main.lua b/client/main.lua index 451fbf3..9854eab 100644 --- a/client/main.lua +++ b/client/main.lua @@ -2,6 +2,9 @@ function HUD:Toggle(state) SendNUIMessage({ type = "SHOW", value = state }) end +RegisterNetEvent('esx_hud:HudToggle', HUD:Toggle) +exports('HudToggle', HUD:Toggle) + function HUD:SetHudColor() SendNUIMessage({ type = "SET_CONFIG_DATA", value = Config }) end From 8ac3928969bb918aa03df95aec9cd9f5a03f7354 Mon Sep 17 00:00:00 2001 From: "Adam Volkman (maku)" Date: Sat, 8 Jun 2024 13:16:38 +0200 Subject: [PATCH 2/2] fix(client/main): wrapper for state update --- client/main.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/main.lua b/client/main.lua index 9854eab..ac294e4 100644 --- a/client/main.lua +++ b/client/main.lua @@ -2,9 +2,6 @@ function HUD:Toggle(state) SendNUIMessage({ type = "SHOW", value = state }) end -RegisterNetEvent('esx_hud:HudToggle', HUD:Toggle) -exports('HudToggle', HUD:Toggle) - function HUD:SetHudColor() SendNUIMessage({ type = "SET_CONFIG_DATA", value = Config }) end @@ -32,6 +29,14 @@ function HUD:Start(xPlayer) self:Toggle(true) end +local function ToggleHud(state) + HUD:Toggle(state) + HUD.Data.hudHidden = not state +end + +RegisterNetEvent('esx_hud:HudToggle', ToggleHud) +exports('HudToggle', ToggleHud) + -- Handlers -- On script start AddEventHandler("onResourceStart", function(resource)