Deltarix Scripts
TebexDiscord
  • Information
    • About Me - Deltarix
  • Keymaster
    • FiveM Asset Escrow
    • Authentication
    • Transfers
  • Paid Assets
    • MDT V2
      • Setup
      • Locales
      • Configurations
        • Server
        • Client
        • Settings
        • 10 Codes
        • Commands
      • Exports
        • Server
          • OpenMDT
          • OpenVehicleDetailsInMDT
          • GetStateId
          • GetOfficer
          • GetPlayerWanted
          • GetPlateFlagged
          • GetOfficerSuspended
          • GetWeaponRegistered
          • GetOfficerClockedIn
          • GetClosestCamera
          • CreateWeapon
          • CreateOfficer
          • DeleteOfficer
          • UpdateCitizenData
          • UpdateCitizenPoints
          • ToggleCamera
          • ToggleCameraTimeout
          • ToggleClock
        • Client
          • OpenMDT
          • InsertPhotoToGallery
      • Bridges
        • Server
          • Framework
            • es_extended
            • qb-core
            • qbx_core
          • Garage
            • esx_garage
            • qb-garages
            • qbx_garages
          • Inventory
            • ox_inventory
            • qb-inventory
          • Licence
            • es_extended
            • qb-core
            • qbx_core
          • Property
            • esx_property
            • qb-apartments
            • qbx_apartments
          • Utilities
            • Logger
        • Client
          • Garage
            • esx_garage
            • qb-garages
            • qbx_garages
          • Utilities
            • Camera
      • Dependencies
      • Known Bugs
      • Common Issues and Troubleshooting
    • Dispatch
      • Exports
        • Server
          • Notifications
          • IsDispatcher
          • GetDispatchersByGroup
          • GetGroups
          • GetStateId
        • Client
          • defaultNotification
          • officerNotification
          • dispatchNotification
          • Copy of dispatchNotification
      • Dependencies
Powered by GitBook
On this page

Was this helpful?

  1. Paid Assets
  2. MDT V2
  3. Bridges
  4. Server
  5. Inventory

qb-inventory

if GetResourceState('qb-inventory') ~= 'started' then return end

Inventory = {
  name = 'drx_evidence_',

  ---@param id number The inventory identifier
  GetStashItems = function(id)
    local items = {}
    local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { id })
    if not result then return items end

    local stashItems = json.decode(result)
    if not stashItems then return items end

    for _, item in pairs(stashItems) do
      local itemInfo = QBCore.Shared.Items[item.name:lower()]
      if itemInfo then
        items[item.slot] = {
          name = itemInfo["name"],
          amount = tonumber(item.amount),
          info = item.info or "",
          label = itemInfo["label"],
          description = itemInfo["description"] or "",
          weight = itemInfo["weight"],
          type = itemInfo["type"],
          unique = itemInfo["unique"],
          useable = itemInfo["useable"],
          image = itemInfo["image"],
          slot = item.slot,
        }
      end
    end

    return items
  end,

  ---@param id number The inventory identifier
  ---@param label string The inventory label
  RegisterStash = function(id, label)
    MySQL.insert.await('INSERT IGNORE INTO stashitems (`stash`, items) VALUES (?, ?)', {
      id, json.encode({})
    })
  end,

  ---@param src number The player server id
  ---@param id number The inventory identifier
  OpenInventory = function(src, id)
    exports['qb-inventory']:OpenInventory('stash', Inventory.name .. id, nil, src)
    TriggerClientEvent("inventory:client:SetCurrentStash", src, Inventory.name .. id)
  end,
}

Last updated 1 year ago

Was this helpful?