Esx_menu_default and inventory error on houses

Hello,
I’ve been trying out a housing system for my rp server and came up with an error on the esx_menu_default. The error is: error during NUI callback menu_submit: @esx_menu_default/client/main.lua attempt to index a nil value (local ‘menu’). I think this could be on the client side of the housing script but not shure. This the part of the script

if near.v ~= nil and near.ds < 1.5 then
help3d("~r~E~w~ - Abrir",near.pos)
if IsControlJustPressed(0, 38) then
local inv = thishouse…"_"…near.k
ESX.TriggerServerCallback(‘p_houses:getInventory’, function(inventory)
ESX.UI.Menu.Open(‘default’, GetCurrentResourceName(), ‘p_housimg’, {
title = 'Casa ',
align = ‘bottom-right’,
elements = {
{label = ‘Armario’, value = ‘bailar1’},
{label = ‘Ropero’, value = ‘baile2’}
}}, function(data, menu)
if data.current.value == ‘bailar1’ then
if UseCustomInv then
invHouse(inv, wbymod[near.v.data.m])
–exports[‘linden_inventory’]:OpenStash({owner = false, id = inv, label = "Casa - "…inv, slots = wbymod[near.v.data.m]})
menu.close()
else
inventory = json.decode(inventory)
ESX.UI.Menu.Open(‘default’, GetCurrentResourceName(), ‘Casa’, {
title = ‘Tus muertos’,
align = ‘right’,
elements = {
{label = ‘Coger items’, value = ‘getI’},
{label = ‘Dejar items’, value = ‘putI’},
{label = ‘Coger armas’, value = ‘getW’},
{label = ‘Dejar armas’, value = ‘putW’},
{label = ‘Coger dinero’, value = ‘getM’},
{label = ‘Dejar dinero’, value = ‘putM’}
}
}, function(data2, menu2)
if data2.current.value == ‘getI’ then
local items = {}
local data = inventory.items
if #data > 0 then
for i=1, #data do
table.insert(items, {label = ‘x’ … data[i].count … ’ - ’ … data[i].name})
end
else
table.insert(items, {label = ‘No hay items’, value = ‘’})
end
ESX.UI.Menu.Open(‘default’, GetCurrentResourceName(), ‘CasaI’, {
title = ‘Coger items’,
align = ‘right’,
elements = items
}, function(data3, menu3)
if data3.current.value ~= nil and data3.current.value ~= ‘’ then
end
end, function(data3, menu3)
menu3.close()
end)
elseif data2.current.value == ‘putI’ then
ESX.TriggerServerCallback(‘p_houses:getInvPlayer’, function(inventario)
local elements = {}
local count = 0
local items = inventory.items
for i=1, #inventario do
if inventario[i].count > 0 then
count = count + 1
end
end
if count > 0 then
for i=1, #inventario do
if inventario[i].count > 0 then
table.insert(elements, {label = ‘x’ … inventario[i].count … ’ - ’ … inventario[i].label, value = inventario[i].name, id = i, label = inventario[i].label, count = inventario[i].count})
end
end
else
table.insert(elements, {label = ‘No tienes items’, value = ‘’})
end
ESX.UI.Menu.Open(‘default’, GetCurrentResourceName(), (‘CasaIPSSSS’), {
title = ‘Dejar items’,
align = ‘right’,
elements = elements
}, function(data3, menu3)
if data3.current.value ~= nil and data3.current.value ~= ‘’ then
ESX.UI.Menu.Open(‘dialog’, GetCurrentResourceName(), ‘Mnd_dialogHouse’, {
title = ‘Cantidad a dejar’
}, function(data4, menu4)
local num = data4.value
if tonumber(num) then
print(num)
if data3.current.count >= tonumber(num) then
ESX.ShowNotification(‘Has dejado x’ … num … ’ - ’ … data3.current.label)
TriggerServerEvent(‘p_houses:deleteItems’, data3.current.value, num)
local hay = true
if #inventory.items > 0 then
for i=1, #inventory.items do
if inventory.items[i].name == data3.current.value then
hay = true
break
end
end
else
hay = false
end
if hay then
for i=1, #inventory.items do
if inventory.items[i].name == data3.current.value then
inventory.items[i].count = (inventory.items[i].count + num)
break
end
end
else
table.insert(inventory, {name = data3.current.value, count = num, label = data3.current.label})
end
Citizen.Wait(50)
TriggerServerEvent(‘p_houses:setInventory’, ‘items’, thishouse, inventory)
else
ESX.ShowNotification('No tienes tantos ’ … data3.current.label)
end
else
ESX.ShowNotification(‘Debes poner un número’)
end
end)
end
end, function(data3, menu3)
menu3.close()
end)
end, GetPlayerServerId(PlayerId()))
end
end, function(data2, menu2)
menu2.close()
end)
end
menu.close()
elseif data.current.value == ‘baile2’ then
TriggerEvent(‘p_housing:clothes’)
end
end, function(data, menu)
menu.close()
end)
end, thishouse)
end
end

And when it does work cause sometimes it has worked fine, when I’m going to place an item on the house inventory it gives error on the server script

RegisterServerEvent(‘p_houses:deleteItems’)
AddEventHandler(‘p_houses:deleteItems’, function(name, count)
local xPlayer = ESX.GetPlayerFromId()
xPlayer.removeInventoryItem(name, count)
end)

Any help would be of much help. Thank you!!!

Hey :slight_smile:
You have more chances to get help if your post is easier to read (well structured).
For the code : Use the Preformatted text or directly link your script file.
For the error and the context send screenshots (of the console in your case).

If i’m not wrong this is p_housing maybe you can recive support from @Pa1nlessz

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.