Does anyone know why I return a value in GetVehInventoryItemCount but in the function IsItemMaxedToVehicle it prints it as nil. I use a variable “vInvItemCount” to call the function. All help is appreciated I’ve been working on this one problem for a few hours.
function IsItemMaxedToVehicle(player, item, count, plate)
local xPlayer = ESX.GetPlayerFromId(player)
local itemMax = xPlayer.getInventoryItem(item).limit
local amountToAdd = count
local vInvItemCount = GetVehInventoryItemCount(plate, item)
print(vInvItemCount)
if vInvItemCount ~= nil then
if count + vInvItemCount <= itemMax then
return false
elseif count + vInvItemCount > itemMax then
return true
end
else
if count + 0 <= itemMax then
return false
elseif count + 0 > itemMax then
return true
end
end
end
function GetVehInventoryItemCount(plate, name)
MySQL.Async.fetchAll(
'SELECT count FROM `truck_inventory` WHERE `plate` = @plate and `item` = @item',
{
['@plate'] = plate,
['@item'] = name
},
function(result)
print(result[1].count)
return(result[1].count)
end)
end