ox_inventory
Inventory Installation
Last updated
Inventory Installation
Last updated
Look for the following code block:
SendNUIMessage({
action = 'setupInventory',
Add the following code directly above that SendNuiMessage function
TriggerServerEvent('rep-weed:server:checkDry', left, currentInventory)
Look for the following code:
function Inventory.Save(inv)
Paste the following code AFTER that whole function:
RegisterNetEvent('rep-weed:server:updateDry', function (id, slot, item)
inv = Inventory(id)
inv.weight -= Inventory(id).items[slot].weight
Inventory(id).items[slot] = item
inv.weight += Inventory(id).items[slot].weight
inv:syncSlotsWithClients({
{
item = item,
inventory = inv.id
}
}, true)
if inv.player and server.syncInventory then
server.syncInventory(inv)
end
end)
Look for the following code:
fromInventory.items[data.fromSlot] = fromData
Replace it with code:
if fromData then
if fromData.name == 'wetbud' then
if fromInventory.type == 'stash' then
if fromInventory.type == 'stash' then
if not fromData.metadata then
fromData.metadata = {}
fromData.metadata.time = os.time()
fromData.metadata.dry = 10
else
if not fromData.metadata.time then fromData.metadata.time = os.time() end
if not fromData.metadata.dry then fromData.metadata.dry = 10 end
end
end
end
end
end
fromInventory.items[data.fromSlot] = fromData
if toData then
if toData.name == 'wetbud' then
if toInventory.type == 'stash' then
print('stash')
if not toData.metadata then
toData.metadata = {}
toData.metadata.time = os.time()
toData.metadata.dry = 10
else
if not toData.metadata.time then toData.metadata.time = os.time() end
if not toData.metadata.dry then toData.metadata.dry = 10 end
end
end
end
end
toInventory.items[data.toSlot] = toData
If you want weed to also dry in trunk, player or glove trunk, repeat the same process
/giveitem
commandsLook for the following code:
lib.addCommand({'additem', 'giveitem'}, {
Replace the whole function with this code.
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) --[[@as OxInventory]]
local count = args.count or 1
local metadata = args.type and { type = tonumber(args.type) or args.type}
if args.item == "femaleseed" then
if not metadata then
metadata = {}
end
metadata.strain = "Unknown"
metadata.n = 0
metadata.p = 0
metadata.k = 0
elseif args.item == "driedbud" then
if not metadata then
metadata = {}
end
metadata.strain = "Unknown"
metadata.n = 0
metadata.p = 0
metadata.k = 0
metadata.remainweight = 100
elseif args.item == "weedpackage" then
if not metadata then
metadata = {}
end
metadata.strain = "Unknown"
metadata.n = 0
metadata.p = 0
metadata.k = 0
metadata.remainweight = 100
elseif args.item == "weedbaggie" then
if not metadata then
metadata = {}
end
metadata.strain = "Unknown"
metadata.n = 0
metadata.p = 0
metadata.k = 0
elseif args.item == "wetbud" then
if not metadata then
metadata = {}
end
metadata.strain = "Unknown"
metadata.n = 0
metadata.p = 0
metadata.k = 0
metadata.dry = 0
elseif args.item == "joint" then
if not metadata then
metadata = {}
end
metadata.strain = "Unknown"
metadata.dry = 0
metadata.n = 0
metadata.p = 0
metadata.k = 0
elseif args.item == "wateringcan" then
if not metadata then
metadata = {}
end
metadata.water = 0
end
local success, response = Inventory.AddItem(inventory, item.name, count, metadata)
if not success then
return Citizen.Trace(('Failed to give %sx %s to player %s (%s)'):format(count, item.name, args.target, response))
end
source = Inventory(source) or { label = 'console', owner = 'console' }
if server.loglevel > 0 then
lib.logger(source.owner, 'admin', ('"%s" gave %sx %s to "%s"'):format(source.label, count, item.name, inventory.label))
end
end
end)