script:chicken] SCRIPT ERROR: @chicken/servers/server.lua:57: attempt to index a nil value (local 'xItem')
[ script:chicken] > TriggerServerCallback (@es_extended/server/functions.lua:160)
[ script:chicken] > handler (@es_extended/server/common.lua:71)
[ script:es_extended] SCRIPT ERROR: citizen:/scripting/lua/scheduler.lua:765: bad argument #1 to 'table_unpack' (table expected, got nil)
Replace this
ESX.RegisterServerCallback('crossbite_chicken:haveItem', function(source, cb, item)
local xPlayer = ESX.GetPlayerFromId(source)
local xItem = xPlayer.getInventoryItem(item)
if xItem.count >= 1 then
cb(true)
else
cb(false)
end
end)
With
ESX.RegisterServerCallback('crossbite_chicken:haveItem', function(source, cb, item)
local xPlayer = ESX.GetPlayerFromId(source)
local xItem = xPlayer.getInventoryItem(packaged_chicken)
if xItem.count >= 1 then
cb(true)
else
cb(false)
end
end)
It is because
local xItem = xPlayer.getInventoryItem(item) is not in the sql
item is the itemname
and that item name should be in the items table
so you should also add that item in the sql aslo
If you are using esx 1.1 use
INSERT INTO `items`(`name`, `label`, `limit`) VALUES(`packaged_chicken`, `PACKAGED CHICKEN`, 1); if you are using esx 1.1
If you are using esx 1.2 or esx legacy use
INSERT INTO `items`(`name`, `label`, weight) VALUES(`packaged_chicken`, `PACKAGED CHICKEN`, 1);