Esx_property/client/main.lua: 580 attempt to concatenate a nil value (field 'label')

		for i=1, #inventory.items, 1 do
			local item = inventory.items[i]

			if item.count > 0 then
				table.insert(elements, {
					label = item.label .. ' x' .. item.count,    --- Line 580
					type = 'item_standard',
					value = item.name
				})
			end
		end

This is what i have on my esx_property, i cant withdraw items.

Maybe that’s error is server side

ESX.RegisterServerCallback('esx_property:getPropertyInventory', function(source, cb, owner)
	local xPlayer    = ESX.GetPlayerFromIdentifier(owner)
	local blackMoney = 0
	local items      = {}
	local weapons    = {}

	TriggerEvent('esx_addonaccount:getAccount', 'property_black_money', xPlayer.identifier, function(account)
		blackMoney = account.money
	end)

	TriggerEvent('esx_addoninventory:getInventory', 'property', xPlayer.identifier, function(inventory)
		items = inventory.items
	end)

	TriggerEvent('esx_datastore:getDataStore', 'property', xPlayer.identifier, function(store)
		weapons = store.get('weapons') or {}
	end)

	cb({
		blackMoney = blackMoney,
		items      = items,
		weapons    = weapons
	})
end)

ESX.RegisterServerCallback('esx_property:getPlayerInventory', function(source, cb)
	local xPlayer    = ESX.GetPlayerFromId(source)
	local blackMoney = xPlayer.getAccount('black_money').money
	local items      = xPlayer.inventory

	cb({
		blackMoney = blackMoney,
		items      = items,
		weapons    = xPlayer.getLoadout()
	})
end)

This is my server side code.

Do u have install esx_addonaccount, esx_accountdata and more?

sure, i have them installed, in add like and i have tryed reinstalling them, but it still no works. ( i have all esx_property dependencies)

mmm, try with my esx_property: link: https://drive.google.com/file/d/1yNIbLA9V18YCjj4hNSTKgo0frkGFS6dg/view?usp=sharing

1 Like

okay i´ll try and tonight i tell u <3

1 Like

I have tryed ur esx_property and still the same error, but now on diferent lane

mmm, where it’s located in server.cfg?

ensure es_extended
ensure es_carwash
ensure skinchanger
ensure esx_accessories
ensure esx_addonaccount
ensure esx_addoninventory
ensure esx_society
ensure esx_drugs
ensure esx_addons_gcphone
ensure esx_ambulancejob
ensure esx_animations
ensure LegacyFuel
ensure esx_barbershop
ensure esx_basicneeds
ensure esx_bike-rental
ensure esx_billing
ensure esx_boilerplate
ensure esx_datastore
ensure esx_doorlock
ensure esx_dmvschool
ensure esx_duty
ensure esx_eden_clotheshop
ensure esx_garbagecrew
ensure trewhud
ensure esx_holdup
ensure esx_holdupfleeca
ensure esx_holdupbank
ensure esx_identity
ensure esx_jb_eden_garage2
ensure esx_jb_realtimejailer
ensure esx_joblisting
ensure esx_jobs
ensure OnlineJobs
ensure esx_license
ensure esx_mechanicjob
ensure esx_menu_default
ensure esx_menu_dialog
ensure esx_menu_list
ensure esx_moneywash
ensure esx_optionalneeds
ensure esx_policejob
ensure esx_policedog
ensure policealert
ensure esx_property
ensure esx_gunani
ensure id-card
ensure esx_vemenu
ensure esx_outclothes
ensure vehiclelock
ensure pbeds
ensure wheelchair
ensure esx_carthief

mmmm, thats cfg is a little bit messy, try use this for essentials ESX’S scripts

ensure mysql-async
ensure async
ensure cron
ensure es_extended
ensure essentialmode
ensure instance
ensure skinchanger
ensure esx_skin
ensure esx_menu_default
ensure esx_menu_dialog
ensure esx_menu_list
ensure esx_addonaccount
ensure esx_addoninventory
ensure esx_datastore
ensure esx_society
ensure esx_service
ensure esx_billing
ensure esx_license
ensure esx_advancedgarage
ensure esx_voice
## ESX JOBS ##

ensure esx_ambulancejob
ensure esx_policejob
ensure esx_taxijob
ensure esx_mechanicjob
ensure esx_lscustom
ensure esx_joblisting

## SUB-ESENCIALES PARA ESX ##

ensure esx_gasolina
ensure esx_status
ensure esx_basicneeds
ensure esx_optionalneeds
ensure esx_secondhandcars
ensure esx_vehicleshop
ensure esx_shops
ensure esx_clotheshop
ensure esx_barbershop
ensure esx_weaponshop
ensure esx_tattooshop
ensure esx_identity
ensure esx_accessories
ensure esx_boatshop
ensure esx_dmvschool
ensure esx_property
ensure esx_rpchat
ensure esx_vehiclelock
ensure esx_vehicle_inventory
ensure esx_doorlock
ensure esx_moneywash

I have tryed it, but im still having the issue.

I addition i would like to say that if i store meth on property for first time i cant withdraw it until a new server restart, is like i cant withdraw items unless i have stored them atleast 1 time.

Mmmm, what es_extended version do u have?

last time i updated it was last summer

1 Like

I believe this might be a issue with “item.label” as removing that will resolve it for all cases where you have to use “esx_addoninventory” to withdraw items (eg. police armory, other jobs with specific stashes etc.) so that is your best bet. I have been looking for a fix but can’t find one other than just replacing “items.label” with “items.name” which will mean that you can at least open the menu, but it will not be shown with the label but instead the name will be shown. So if you have an item called “waterbottle” and the label is “Water Bottle” then it will show up in the menu as “waterbottle” which can be confusing but it’s just temporary till we can find out how to fix this.

the error is very simple, check your database in the addon_inventory_items table, there must be the label column, if not, you must create it and put their respective names.

Your code assumes, that your item object variable contains count, label and name.

for i=1, #inventory.items, 1 do
	local item = inventory.items[i]

	if item.count > 0 then -- we assume count prop exists
		table.insert(elements, {
			label = item.label .. ' x' .. item.count, -- we assume label prop exists
			type = 'item_standard',
			value = item.name -- we assume name prop exists
		})
	end
end

@scode correctly mentioned that there is a possibility, that your database lacks label column. The only problem is that this should be checked by the code anyways. We cannot rely on the data source (database in this scenario).

Also, I think it’s not a problem with the lack of the whole column, because it was probably created during the installation process of the script. I believe the problem lies with the item itself - when you added it, you forgot to add label to the database.

Solution

This solution is absolutely bulletproof, some may say an overkill. But when you are not aware of the importance of the database and the fields you have to fill out, this should work just fine for you.

Also it’s a bit optimized now, since the initialization of the variable item was put outside of the loop.

local item -- variable outside of the loop, so it's initialized only once
for i=1, #inventory.items, 1 do
	if inventory.items[i] then -- checking if the item exists
		item = inventory.items[i]
		
		if item.count and item.label and item.name then
			if item.count > 0 then
				table.insert(elements, {
					label = item.label .. ' x' .. item.count,
					type = 'item_standard',
					value = item.name
				})
			end
		else
			-- this else statement is optional
			-- do something when the item lacks any of the properties
			print('[esx_property] An item is missing some properties. Check the database!')
		end
	end
end
1 Like

This really is confusing as I have item names and labels in the db for every item. This is happening for every menu based inventory script that i use. Changing item.label to item.name fixes the issue but no reason that label shouldnt work.

2 Likes

Well Done I was searching this issue and youre totally right with it ! "Just Replace item.label with item.name