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() { function Close() {
$.post(`https://${GetParentResourceName()}/closed`) $.post(`https://${GetParentResourceName()}/closed`,(retVal)=>{
Closed() if(retVal){
Closed()
}
})
} }
window.addEventListener("message", (e) => { window.addEventListener("message", (e) => {
@@ -437,4 +440,4 @@
</script> </script>
</body> </body>
</html> </html>
+7 -6
View File
@@ -12,10 +12,11 @@ function Post(fn,...)
}) })
end end
function Open(position,eles,onSelect,onClose) function Open(position,eles,onSelect,onClose,canClose)
activeMenu = { activeMenu = {
position = position, position = position,
eles = eles, eles = eles,
canClose = canClose,
onSelect = onSelect, onSelect = onSelect,
onClose = onClose onClose = onClose
} }
@@ -74,11 +75,11 @@ end)
-- NUI Callbacks -- NUI Callbacks
-- [ closed | selected | changed ] -- [ closed | selected | changed ]
RegisterNUICallback("closed",function() RegisterNUICallback("closed",function(data,cb)
if not activeMenu then if not activeMenu or (activeMenu and not activeMenu.canClose) then
return return cb(false)
end end
cb(true)
Closed() Closed()
end) end)
@@ -266,4 +267,4 @@ if Debug then
exports["esx_context"]:Open(position,eles,onSelect,onClose) exports["esx_context"]:Open(position,eles,onSelect,onClose)
end) end)
end end
+2 -2
View File
@@ -163,7 +163,7 @@ if ESX.GetConfig().Multichar then
elseif Action.action == "return" then elseif Action.action == "return" then
SelectCharacterMenu(Characters, slots) SelectCharacterMenu(Characters, slots)
end end
end, nil, true) end, nil, false)
end end
function SelectCharacterMenu(Characters, slots) function SelectCharacterMenu(Characters, slots)
@@ -211,7 +211,7 @@ if ESX.GetConfig().Multichar then
SetPedAoBlobRendering(playerPed, true) SetPedAoBlobRendering(playerPed, true)
ResetEntityAlpha(playerPed) ResetEntityAlpha(playerPed)
end end
end, nil, true) end, nil, false)
end end
RegisterNetEvent('esx_multicharacter:SetupUI') RegisterNetEvent('esx_multicharacter:SetupUI')
AddEventHandler('esx_multicharacter:SetupUI', function(data, slots) AddEventHandler('esx_multicharacter:SetupUI', function(data, slots)