AdmWarn for ox_inventory giveitem
Go to ox_inventory > server.lua. Find the giveitem command.
lib.addCommand({'additem', 'giveitem'}, {
help = 'Gives an item to a player with the given id',
params = {
{ name = 'target', type = 'playerId', help = 'The player to receive the item' },
{ name = 'item', type = 'string', help = 'The name of the item' },
{ name = 'count', type = 'number', help = 'The amount of the item to give', optional = true },
{ name = 'type', help = 'Sets the "type" metadata to the value', optional = true },
},
restricted = 'group.admin',
}, function(source, args)
local item = Items(args.item)
if item then
local inventory = Inventory(args.target)
local count = args.count or 1
local success, response = Inventory.AddItem(inventory, item.name, count, args.type and { type = tonumber(args.type) or args.type })
if not success then
return Citizen.Trace(('Failed to give %sx %s to player %s (%s)'):format(count, item.name, args.target, response))
end
local sourceServerId = source
local targetServerId = args.target
if server.loglevel > 0 then
lib.logger(sourceServerId, 'admin', ('"Admin %s" (Server ID: %d) gave %sx %s to "Player %s" (Server ID: %d)'):format(
Inventory(source).label, sourceServerId, count, item.name, Inventory(args.target).label, targetServerId
))
end
TriggerEvent('shawn_rpchat:admwarn:giveitem', sourceServerId, targetServerId, count, item.name)
end
end)
Last updated