[HELP] qtarget

hey how can I make this function on qb-core

local ItemCount = function(item)
	if Config.LindenInventory then return exports['linden_inventory']:CountItems(item)[item]
	else
		for k, v in pairs(ESX.GetPlayerData().inventory) do
			if v.name == item then
				return v.count
			end
		end
	end
	return 0
end
local ItemCount = function(item)
    local PlayerInventoryData = QBCore.Functions.GetPlayerData()["items"]
    local count = 0
    for k,v in pairs(PlayerInventoryData) do
        if v.name == item then
            count = count + v.amount
        end
    end
    return count
end

This should work

i will check it now tell you if it works

** Edit **
ty man works perfect can yoy help me also with grade fix maybe iwant to get the
rigth grade level

can you make me this
if you can only

local DataJob = QBCore.Functions.GetPlayerData()
and (not data.job or data.job == DataJob.job.name or (data.job[DataJob.job.name] and data.job[DataJob.job.name] <= DataJob.job.grade))
option 1:
job = "ambulance",

option 2:

job = {

    ["police"] = 5, -- minimum grade required to see this option

    ["ambulance"] = 0,

}

how do i make it like the grade level = level you place

if you can help me with this part also it will be amazing ty