Server Functions

You will need to customize this file according to the content of the client file. This allows you to include any necessary additions to ensure the proper processing of client requests.

Matching example to the client examples

ESX.Shared.RegisterServerCallback('Trusted:Nitro:HaveItem', function(source, haveItem, item, count)
    local xPlayer = ESX.Shared.GetPlayerFromId(source)
    
    if not xPlayer then 
        haveItem(false)
        return
    end 
 
    local xItem = xPlayer.getInventoryItem(item)
 
    haveItem(xItem.count >= count)
end)
 
RegisterNetEvent('Trusted:Nitro:ESX:UseItem', function(item, count)
    local xPlayer = ESX.Shared.GetPlayerFromId(source)
    xPlayer.removeInventoryItem(item, count)
end)