Merge pull request #759 from tony-stark-17/tony-stark-17-patch-1

feat: add canClose to context menu
This commit is contained in:
P Gergő
2022-12-20 21:49:02 +01:00
committed by GitHub
3 changed files with 15 additions and 11 deletions
+6 -3
View File
@@ -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 @@
</script>
</body>
</html>
</html>
+7 -6
View File
@@ -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
end
+2 -2
View File
@@ -163,7 +163,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)
@@ -211,7 +211,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)