Skip to main content

AddItemToInventory

note

ONLY serverside

Parameters

ParameterDescription
xPlayerESX Player (ESX.GetPlayerFromId)
itemitem as a table
countitem count or ammo count
invinventory
exports.inventory:AddItemToInventory(xPlayer, item, count, inv)

Example

RegisterCommand('add', function(source, args, raw)
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
local itemName = 'bread'
local count = 1 -- This is also the weaponammo count

local inv = {
type = 'storage', -- type from database
id = 'pd1', -- identifier from database
save = true
}

local item = {
type = 'item_standard', -- 'item_standard' or 'item_weapon'
name = itemName
}

exports.inventory:AddItemToInventory(xPlayer, item, count, inv)
end)