ox_inventory
Add Items:
Although weedbaggie can still stack, but when you sell you must seperate them. Because our script also supports qb-inventory, and that inventory sux...
Copy the image files from the
img
folder to yourinventory
folder.Add the following codes to your
ox-inventory > data >items.lua
file under the Items section:
['femaleseed'] = {
label = 'Female Marijuana Seed',
weight = 500,
consume = 0,
client = {
image = "weed-seed.png",
},
server = {
export = 'rep-weed.femaleseed',
},
close = true,
description = 'Surely I can just plant this, right?'
},
['maleseed'] = {
label = 'Male Marijuana Seed',
weight = 500,
client = {
image = "weed-seed.png",
},
description = 'Add this to a planted female seed to make it pregnant? You are pretty sure this seed has a penis.'
},
['wateringcan'] = {
label = 'Watering Can',
weight = 2500,
consume = 0,
server = {
export = 'rep-weed.wateringcan',
},
close = true,
description = 'Fill this at a river or lake.'
},
['fertilizer'] = {
label = 'Fertilizer',
weight = 500,
description = 'Cool'
},
['wetbud'] = {
label = 'Wet Bud (100 grams)',
weight = 7500,
client = {
image = "wet.png",
},
description = 'THIS CANT BE DRIED WITHOUT STRAIN... Needs to be stored somewhere dry.'
},
['driedbud'] = {
label = 'Dried Bud (100 Grams)',
weight = 2500,
consume = 0,
server = {
export = 'rep-weed.driedbud',
},
close = true,
description = 'Pack It?'
},
['weedpackage'] = {
label = 'Suspicious Package',
weight = 5000,
consume = 0,
server = {
export = 'rep-weed.weedpackage',
},
close = true,
description = 'Marked for Police Seizure'
},
['qualityscales'] = {
label = 'Quality Scales',
weight = 500,
consume = 0,
description = 'Weighs Baggies with no loss'
},
['smallscales'] = {
label = 'Small Scales',
weight = 250,
description = 'Weighs Baggies with minimal loss'
},
['joint'] = {
label = '2g Joint',
weight = 200,
consume = 0,
server = {
export = 'rep-weed.joint',
},
close = true,
description = 'Its a Joint, man.'
},
['emptybaggies'] = {
label = 'Empty Baggies',
weight = 100,
description = 'Empty Baggies'
},
['weedbaggie'] = {
label = 'Baggie (7g)',
weight = 300,
consume = 0,
server = {
export = 'rep-weed.weedbaggie',
},
close = true,
description = 'Sold on the streets'
},
['rollingpaper'] = {
label = 'Rolling Paper',
weight = 100,
description = 'Required to roll joints!'
},
Dry:
Step 1:
Go to ox_inventory/client.lua
Look for the following code block:
action = 'setupInventory',
Add the following code directly above that SendNuiMessage function
TriggerServerEvent('rep-weed:server:checkDry', left, currentInventory)
Step 2:
Go to \modules\inventory\server.lua
Look for the following code:
function Inventory.Save(inv)
Add the following code directly 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)
Step 3:
Go to \modules\inventory\server.lua
Look for the following code:
fromInventory.items[data.fromSlot] = fromData
toInventory.items[data.toSlot] = toData
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.
Give Item with metadata:
Step 1:
Go to /server.lua
Look for the following 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 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
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)
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.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)
Last updated