How to add "Check items" function in job script

Hello anyone hv an idea to put function “check item” in this loop?
i mean check item if yes can cutting wood if not just show error “No Hatchet”

Citizen.CreateThread(function()
    while true do
        
        local sleep = 1000
        local playerPed = PlayerPedId()
        local playerCoords = GetEntityCoords(playerPed)
        
        for i = 1, #closestWood do
            local x = GetClosestObjectOfType(playerCoords, 2.0, GetHashKey(closestWood[i]), false, false, false)
            local entity = nil
            if DoesEntityExist(x) then
                entity = x
                Wood    = GetEntityCoords(entity)
                sleep  = 5
                DrawText3D(Wood.x, Wood.y, Wood.z + 1.5, 'Press [~g~E~s~] to harvest the ~b~wood~s~')  
                if IsControlJustReleased(0, 38) then
                    if not cachedWood[entity] then
                        OpenWood(entity)
                    else
                        ESX.ShowNotification('~r~This wood has already been cut.~s~')
                    end
                end
                break
            else
                sleep = 1000
            end
        end
        Citizen.Wait(sleep)
    end
end)

Thank you for any help in advance :smiley:

2 Likes

hi if you are completed the function please help me because i need the same thing

You could use something like this

 local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.getInventoryItem('wood').count >= 1 then
   print('WE GOT WOOD')
else
   print('WE AINT GOT WOOD')
end
5 Likes

I will try, thanks you for your suggestion :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.