[HELP] esx_invintoryhud not working with esx_property

hello!

i’ve ran into a problem, when i try to add support to esx_property for esx_invintoryhud
the esx_property resaurce stops wroking.

from what i understand from this wiki on how to add support for esx_invintoryhud to other resaurces
when it comes to esx_property i have to edit “OpenRoomMenu” function in “esx_property/client/main.lua” to make it look like this

function OpenRoomMenu(property, owner)
	local entering = nil
	local elements = {{label = _U('invite_player'),  value = 'invite_player'}}

	if property.isSingle then
		entering = property.entering
	else
		entering = GetGateway(property).entering
	end

	if CurrentPropertyOwner == owner then
		table.insert(elements, {label = _U('player_clothes'), value = 'player_dressing'})
		table.insert(elements, {label = _U('remove_cloth'), value = 'remove_cloth'})
	end

	table.insert(elements, {label = "Property inventory", value = "property_inventory"}

	ESX.UI.Menu.CloseAll()

	ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'room', {
		title    = property.label,
		align    = 'top-left',
		elements = elements
	}, function(data, menu)

		if data.current.value == 'invite_player' then

			local playersInArea = ESX.Game.GetPlayersInArea(entering, 10.0)
			local elements      = {}

			for i=1, #playersInArea, 1 do
				if playersInArea[i] ~= PlayerId() then
					table.insert(elements, {label = GetPlayerName(playersInArea[i]), value = playersInArea[i]})
				end
			end

			ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'room_invite', {
				title    = property.label .. ' - ' .. _U('invite'),
				align    = 'top-left',
				elements = elements,
			}, function(data2, menu2)
				TriggerEvent('instance:invite', 'property', GetPlayerServerId(data2.current.value), {property = property.name, owner = owner})
				ESX.ShowNotification(_U('you_invited', GetPlayerName(data2.current.value)))
			end, function(data2, menu2)
				menu2.close()
			end)

		elseif data.current.value == 'player_dressing' then

			ESX.TriggerServerCallback('esx_property:getPlayerDressing', function(dressing)
				local elements = {}

				for i=1, #dressing, 1 do
					table.insert(elements, {
						label = dressing[i],
						value = i
					})
				end

				ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'player_dressing', {
					title    = property.label .. ' - ' .. _U('player_clothes'),
					align    = 'top-left',
					elements = elements
				}, function(data2, menu2)
					TriggerEvent('skinchanger:getSkin', function(skin)
						ESX.TriggerServerCallback('esx_property:getPlayerOutfit', function(clothes)
							TriggerEvent('skinchanger:loadClothes', skin, clothes)
							TriggerEvent('esx_skin:setLastSkin', skin)

							TriggerEvent('skinchanger:getSkin', function(skin)
								TriggerServerEvent('esx_skin:save', skin)
							end)
						end, data2.current.value)
					end)
				end, function(data2, menu2)
					menu2.close()
				end)
			end)

		elseif data.current.value == 'remove_cloth' then

			ESX.TriggerServerCallback('esx_property:getPlayerDressing', function(dressing)
				local elements = {}

				for i=1, #dressing, 1 do
					table.insert(elements, {
						label = dressing[i],
						value = i
					})
				end

				ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'remove_cloth', {
					title    = property.label .. ' - ' .. _U('remove_cloth'),
					align    = 'top-left',
					elements = elements
				}, function(data2, menu2)
					menu2.close()
					TriggerServerEvent('esx_property:removeOutfit', data2.current.value)
					ESX.ShowNotification(_U('removed_cloth'))
				end, function(data2, menu2)
					menu2.close()
				end)
			end)

		elseif data.current.value == "property_inventory" then
			menu.close()
			OpenPropertyInventoryMenu(property, owner)
		end

	end, function(data, menu)
		menu.close()

		CurrentAction     = 'room_menu'
		CurrentActionMsg  = _U('press_to_menu')
		CurrentActionData = {property = property, owner = owner}
	end

	function OpenPropertyInventoryMenu(property, owner)
		ESX.TriggerServerCallback("esx_property:getPropertyInventory", function(inventory)
			TriggerEvent("esx_inventoryhud:openPropertyInventory", inventory)
		end, owner)
	end)
end

i don’t know why it stops working all together, any thoughts?

You’ve added a function within a function, not amazing with Lua but I’m pretty sure that won’t work.

Remove this part

function OpenPropertyInventoryMenu(property, owner)
	ESX.TriggerServerCallback("esx_property:getPropertyInventory", function(inventory)
		TriggerEvent("esx_inventoryhud:openPropertyInventory", inventory)
	end, owner)
end

Then re-add it somewhere else in the script that’s not already part of a function.

no luck, though… i found esx_property to be very buggy with me in general so i’ll try to update everything and try my luck again with this problem

1 Like

Any chance you got this working with inventoryhud?

I found an issue with mine, if I dont have a line in my addoninventory_items table with the name “property” and the players identifier, nothing works, but if i insert a line and basically put something in my inventory via phpmyadin even if i set its value to 0 (so it doesnt appear in the inventory ingame) then the inventory works fine. Not sure how to fix this for new players that wouldnt have any property inventory yet

I fixed my issue not sure if it will help anyone else but here is what I did.

I did what was mentioned here

then in esx_addoninventory/server/main.lua
-just after the result2 MySQL query (around line 127)
-code looks like this

local result2 = MySQL.Sync.fetchAll(‘SELECT * FROM addon_inventory_items WHERE inventory_name = @inventory_name AND owner = "’…owner…’"’ , {
[’@inventory_name’] = name
})

– I added this code right below that code

if #result2 == 0 then
result2 = MySQL.Sync.fetchAll(‘INSERT INTO addon_inventory_items (inventory_name, name, count, owner) VALUES (@inventory_name, “water”, 0, "’…owner…’");SELECT * FROM addon_inventory_items WHERE inventory_name = @inventory_name AND owner = “’…owner…’”;’ , {
[’@inventory_name’] = name
})
end

-This checks that result2 is not empty and if it is it inserts a water bottle into the inventory but sets its count to 0, this way the player appears to have an inventory in the database, but they dont get a random water bottle because its count is 0. it then sets result2 again.