mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 10:18:54 +00:00
Eliminate the need for matching namespace & resource name
When the Menu.Open function is called, a new key-value pair labeled "resourceName" is now added to the menu object. This addition serves the purpose of capturing and storing the invoking resource's name that triggers the function by calling the GetInvokingResource() native. By implementing this change, we establish a more direct and reliable method for checking the "resourceName" key within the menu object. This approach eliminates the need to solely rely on matching the namespace and resource name. As a result, the code becomes more robust and less prone to errors.
This commit is contained in:
@@ -196,6 +196,7 @@ function ESX.UI.Menu.Open(type, namespace, name, data, submit, cancel, change, c
|
||||
|
||||
menu.type = type
|
||||
menu.namespace = namespace
|
||||
menu.resourceName = (GetInvokingResource() or "Unknown")
|
||||
menu.name = name
|
||||
menu.data = data
|
||||
menu.submit = submit
|
||||
@@ -1346,7 +1347,7 @@ end)
|
||||
AddEventHandler('onResourceStop', function(resourceName)
|
||||
for i = 1, #ESX.UI.Menu.Opened, 1 do
|
||||
if ESX.UI.Menu.Opened[i] then
|
||||
if ESX.UI.Menu.Opened[i].namespace == resourceName then
|
||||
if ESX.UI.Menu.Opened[i].resourceName == resourceName or ESX.UI.Menu.Opened[i].namespace == resourceName then
|
||||
ESX.UI.Menu.Opened[i].close()
|
||||
ESX.UI.Menu.Opened[i] = nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user