From d0d2c841867e77afe91d9b19fce1920c9a9d1402 Mon Sep 17 00:00:00 2001 From: Tony Stark <76168122+tony-stark-17@users.noreply.github.com> Date: Tue, 20 Dec 2022 23:07:36 +0530 Subject: [PATCH 1/3] Update UI for canClose function --- [esx]/esx_context/index.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/[esx]/esx_context/index.html b/[esx]/esx_context/index.html index fa50034e..5d15770d 100644 --- a/[esx]/esx_context/index.html +++ b/[esx]/esx_context/index.html @@ -352,8 +352,11 @@ } function Close() { - $.post(`https://${GetParentResourceName()}/closed`) - Closed() + $.post(`https://${GetParentResourceName()}/closed`,(retVal)=>{ + if(retVal){ + Closed() + } + }) } window.addEventListener("message", (e) => { @@ -437,4 +440,4 @@ - \ No newline at end of file + From 54088abcb6bebf368c344680d7ffa689f4c8abbb Mon Sep 17 00:00:00 2001 From: Tony Stark <76168122+tony-stark-17@users.noreply.github.com> Date: Tue, 20 Dec 2022 23:10:06 +0530 Subject: [PATCH 2/3] Add canClose function to context menu Added a canClose parameter so that the user cannot close the menu by pressing ESC instead has to be force closed via code. --- [esx]/esx_context/main.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/[esx]/esx_context/main.lua b/[esx]/esx_context/main.lua index 5a879643..8a2769c9 100644 --- a/[esx]/esx_context/main.lua +++ b/[esx]/esx_context/main.lua @@ -12,10 +12,11 @@ function Post(fn,...) }) end -function Open(position,eles,onSelect,onClose) +function Open(position,eles,onSelect,onClose,canClose) activeMenu = { position = position, eles = eles, + canClose = canClose, onSelect = onSelect, onClose = onClose } @@ -74,11 +75,11 @@ end) -- NUI Callbacks -- [ closed | selected | changed ] -RegisterNUICallback("closed",function() - if not activeMenu then - return +RegisterNUICallback("closed",function(data,cb) + if not activeMenu or (activeMenu and not activeMenu.canClose) then + return cb(false) end - + cb(true) Closed() end) @@ -266,4 +267,4 @@ if Debug then exports["esx_context"]:Open(position,eles,onSelect,onClose) end) -end \ No newline at end of file +end From cf24e7212dab838d9e7ed3ab0ad92f36e41bc2c3 Mon Sep 17 00:00:00 2001 From: Tony Stark <76168122+tony-stark-17@users.noreply.github.com> Date: Tue, 20 Dec 2022 23:13:09 +0530 Subject: [PATCH 3/3] Update Multicharacter to fix issue of closing context menu --- [esx]/esx_multicharacter/client/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/[esx]/esx_multicharacter/client/main.lua b/[esx]/esx_multicharacter/client/main.lua index 69365dee..67def6fa 100644 --- a/[esx]/esx_multicharacter/client/main.lua +++ b/[esx]/esx_multicharacter/client/main.lua @@ -164,7 +164,7 @@ if ESX.GetConfig().Multichar then elseif Action.action == "return" then SelectCharacterMenu(Characters, slots) end - end, nil, true) + end, nil, false) end function SelectCharacterMenu(Characters, slots) @@ -212,7 +212,7 @@ if ESX.GetConfig().Multichar then SetPedAoBlobRendering(playerPed, true) ResetEntityAlpha(playerPed) end - end, nil, true) + end, nil, false) end RegisterNetEvent('esx_multicharacter:SetupUI') AddEventHandler('esx_multicharacter:SetupUI', function(data, slots)