I use this ambulance job that is made in Lua. Unfortunately, being an old script, it's not updated, so it was still set to use "limit" which I changed to "weight" since my gamemode is based on weight as well as the database. But sadly it doesn't work, I get this error.
RegisterServerEvent('esx_ambulancejob:giveItem')
AddEventHandler('esx_ambulancejob:giveItem', function(itemName)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.job.name ~= 'ambulance' then
print(('esx_ambulancejob: %s attempted to spawn in an item!'):format(xPlayer.identifier))
return
elseif (itemName ~= 'medikit' and itemName ~= 'bandage') then
print(('esx_ambulancejob: %s attempted to spawn in an item!'):format(xPlayer.identifier))
return
end
local xItem = xPlayer.getInventoryItem(itemName)
local count = 1
if xItem.weight ~= -1 then (it was xItem.limit before)
count = xItem.weight - xItem.count
end
if xItem.count < xItem.weight then
xPlayer.addInventoryItem(itemName, count)
else
TriggerClientEvent('esx:showNotification', source, _U('max_item'))
end
end)
The error screen when I try to take the item from the pharmacy:
I'd suggest to check if your ESX framework is updated. It could possibly be outdated hence returning a non-existent field metadata. Check your database "items" table data. You should have a weight column there.