Rep Scripts
  • Rep Scripts
  • Free Scripts
    • 💬rep-talkNPC
  • Paid Scripts
    • 🌱rep-weed
      • 📌READ ME
      • 📃Installation
        • 🔴QB
          • SQL installation
          • Add items
            • qb-inventory
            • ox_inventory
          • Joints, carry, player metadata
          • Inventory Installation
            • qb-inventory
            • ox_inventory
        • 🟨ESX
          • SQL installation
          • Ox_inventory Installation
    • 🛡️Anti Trigger
      • 💻Installation
Powered by GitBook
On this page
  • Go to ox_inventory/client.lua
  • For /giveitem commands

Was this helpful?

  1. Paid Scripts
  2. rep-weed
  3. Installation
  4. QB
  5. Inventory Installation

ox_inventory

Inventory Installation

Previousqb-inventoryNextESX

Last updated 1 year ago

Was this helpful?

Go to ox_inventory/client.lua

  1. Look for the following code block:

SendNUIMessage({
				action = 'setupInventory',
  1. Add the following code directly above that SendNuiMessage function

TriggerServerEvent('rep-weed:server:checkDry', left, currentInventory)

Go to \modules\inventory\server.lua

  1. Look for the following code:

function Inventory.Save(inv)
  1. 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)
  1. Look for the following code:

 fromInventory.items[data.fromSlot] = fromData
  1. 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
  1. If you want weed to also dry in trunk, player or glove trunk, repeat the same process


For /giveitem commands

Go to /server.lua

  1. Look for the following code:

lib.addCommand({'additem', 'giveitem'}, {
  1. 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)
🌱
📃
🔴
aox_inventory/client.lua
ox_inventory\modules\inventory\server.lua
ox_inventory\server.lua