Commands & Exports

This section lists all available commands, exports, and events included in the script. You’ll find client-side, server-side, and shared functions designed to help developers integrate, extend, or interact with the system easily within their own scripts or frameworks.


Commands

This section lists all available commands included in the script. Each command is designed to simplify administration, player interaction, or debugging tasks. You’ll find detailed descriptions, usage examples, and permission requirements to help you manage and customize your server efficiently.

Command
Description

/closeinv

Closes the player's inventory instantly.

/inventory

Opens the player's inventory instantly.

/hotbar

Opens the player's hotbar instantly.

/handsup

Raise your hands and enable the button to draw from said player if you open the inventory.

/searchplayer

Search the nearest player to steal or check their items.

/randomitems

Test command that will give you a random amount of items, used for general testing of the asset.

/resetinv [id]

Resets the selected player's inventory.

/clearinv [id]

Clears the selected player's inventory and leaves it completely empty.

/giveitem [id] [item] [count]

Deliver items to a specific player, selecting his id, item name and quantity.

/giveweapon [id] [weapon] [ammo]

Deliver only weapons, you must select the id, weapon and number of ammo.

/repairweapon [id]

Repairs the weapons of the selected player through his id, all weapons go to 100% durability.

/openinventorytarget [id]

Administrative command to check the inventory of a target player.

/admin_giveitem

The interactive menu opens to give items in a personalized way.


Client Exports

This section provides all available client exports for the script. These functions allow you to interact directly with the system from the client side, enabling custom features, UI interactions, and integrations with other resources. Each export includes a short description and usage example for easy implementation.

GetItemList

The GetItemList export allows you to retrieve the complete list of items defined in your shared/items.lua file. This is useful for accessing and managing your entire item database programmatically within your scripts.


How to Use

To get the full list of items, use the following code:

local itemList = exports['qs-inventory']:GetItemList()

for itemName, itemData in pairs(itemList) do
    print("Item Name: " .. itemName)
    print("Label: " .. itemData.label)
    print("Weight: " .. itemData.weight)
end

This will return a table containing all the items and their properties, such as name, label, weight, type, and more. You can use this data to interact with or display item details dynamically in your scripts.

GetWeaponList

The GetWeaponList export allows you to retrieve the complete list of weapons defined in your shared/weapons.lua file. This is useful for accessing and managing weapon data programmatically within your scripts.


How to Use

To get the full list of weapons, use the following code:

local weaponList = exports['qs-inventory']:GetWeaponList()

for weaponName, weaponData in pairs(weaponList) do
    print("Weapon Name: " .. weaponName)
    print("Label: " .. weaponData.label)
end

This will return a table containing all the weapons and their properties, such as name, label, damage, and more. You can use this data to interact with or display weapon details dynamically in your scripts.

inInventory

The inInventory export allows you to check whether the inventory is currently open or closed. It returns a boolean value, making it useful for managing interactions or preventing actions while the inventory is open.


How to Use

To check the inventory status, use the following code:

local isInventoryOpen = exports['qs-inventory']:inInventory()

if isInventoryOpen then
    print("The inventory is currently open.")
else
    print("The inventory is closed.")
end

This will return true if the inventory is open and false if it is closed. You can use this information to control other systems or restrict specific actions while the inventory is in use.

setInventoryDisabled

The setInventoryDisabled export allows you to enable or disable the use of the inventory. This is particularly useful for systems like handcuffs or third-party NUI menus where you want to prevent players from accessing their inventory temporarily.


How to Use

To control whether the inventory can be opened, use the following code:

-- Disable inventory
exports['qs-inventory']:setInventoryDisabled(true)

-- Enable inventory
exports['qs-inventory']:setInventoryDisabled(false)

This export accepts a boolean value:

  • true: Disables the inventory, preventing it from opening.

  • false: Enables the inventory, allowing it to open again.

This is ideal for scenarios where you need to restrict inventory access temporarily, ensuring smooth interaction with other systems or menus.

getUserInventory

The getUserInventory export allows you to retrieve the list of items currently in a player's inventory in .amount format. This can be useful for checking item quantities or implementing custom inventory logic directly from the client side.


How to Use

To get the player's inventory, use the following code:

local inventory = exports['qs-inventory']:getUserInventory()

for itemName, itemData in pairs(inventory) do
    print("Item Name: " .. itemName)
    print("Amount: " .. itemData.amount)
end

This will return a table of items with their quantities, making it easy to access and manipulate the player's inventory programmatically. Use this to search for specific items, display inventory details, or validate item counts.

RegisterStash

The RegisterStash export allows you to create stashes directly from the client side. This is useful for setting up custom stash locations or containers dynamically. You can configure the stash identifier, number of slots, and total weight capacity.


How to Use

To create a stash, use the following code:

-- Example stash configuration
local stashID = "example_stash" -- Unique identifier for the stash
local stashSlots = 50           -- Total number of slots
local stashWeight = 1000        -- Maximum weight capacity

exports['qs-inventory']:RegisterStash(stashID, stashSlots, stashWeight)
print("Stash registered: " .. stashID)

The export parameters are:

  • stash: A unique identifier for the stash (e.g., "police_armory").

  • slots: The total number of item slots available in the stash.

  • weight: The total weight capacity of the stash in your preferred unit.

This export allows for dynamic stash creation and is particularly useful for custom systems like private lockers, organization storage, or role-specific containers. For more advanced details, refer to the Feature Guides in this documentation.

setInClothing

The setInClothing export allows you to enable or disable the clothing registration loop. This loop continuously checks and updates clothing items in the inventory. It is particularly useful when interacting with clothing systems to ensure seamless functionality.


How to Use

To control the clothing loop, use the following code:

-- Enable the clothing loop
exports['qs-inventory']:setInClothing(true)

-- Disable the clothing loop
exports['qs-inventory']:setInClothing(false)

This ensures that clothing items are correctly tracked when the loop is enabled and prevents conflicts by pausing the loop when disabled, such as during the use of a clothing menu.

WeaponWheel

The WeaponWheel export allows you to enable or disable the Weapon Wheel temporarily. This is intended for specific use cases, such as mini-games like battle royale, and is not meant for permanent use. Quasar Inventory will not register weapons when this system is enabled, so it should only be used for short-term scenarios.


How to Use

To enable or disable the Weapon Wheel, use the following code:

-- Enable the Weapon Wheel
exports['qs-inventory']:WeaponWheel(true)

-- Disable the Weapon Wheel
exports['qs-inventory']:WeaponWheel(false)

This export is designed specifically for enabling the Weapon Wheel in controlled environments, such as mini-games, and should not be used as a replacement for the standard inventory weapon system.

GetCurrentWeapon

The GetCurrentWeapon export allows you to check the weapon currently in your hands. This export provides useful information about the weapon, such as its durability or other attributes, and can be integrated into custom scripts.


How to Use

To retrieve the current weapon, use the following code:

local weapon = exports['qs-inventory']:GetCurrentWeapon()
if weapon then
    print("Current Weapon: " .. json.encode(weapon))
else
    print("No weapon equipped.")
end

Here’s an example of using this export to check the durability of a weapon:

RegisterCommand('getdurability', function()
    local weapon = exports['qs-inventory']:GetCurrentWeapon()
    if not weapon then
        print("No weapon equipped.")
        return
    end

    print('Weapon info:', json.encode(weapon, { indent = true }))
    local durability = weapon.info.quality
    print('Weapon durability:', durability)
end, false)

This command retrieves the weapon currently in use, prints its information, and displays its durability. It’s a simple and flexible way to interact with weapon data during gameplay.

CheckIfInventoryBlocked

The CheckIfInventoryBlocked export allows you to check if the player's inventory is currently blocked (for example, when they are in a menu or in a restricted situation where they can't interact with their inventory). This is useful for ensuring certain actions only happen when the inventory is accessible.


How to Use

To check if the inventory is blocked, use the following code:

local isBlocked = exports['qs-inventory']:CheckIfInventoryBlocked()
if isBlocked then
    print("Inventory is blocked.")
else
    print("Inventory is not blocked.")
end

Here’s an example of a command that checks if the player's inventory is blocked:

RegisterCommand('checkinventory', function()
    local isBlocked = exports['qs-inventory']:CheckIfInventoryBlocked()

    if isBlocked then
        print("Result: Inventory is currently blocked.")
    else
        print("Result: Inventory is not blocked and can be used.")
    end
end)

This example checks if the inventory is blocked when using the /checkinventory command. If the inventory is blocked, it will print a corresponding message; otherwise, it will confirm that the inventory is usable.


Server Exports

This section provides all available server exports for the script. These functions allow developers to interact with the system from the server side, manage data, trigger actions, and integrate with other resources. Each export includes a clear description and a practical example to simplify its implementation.

GetItemList

The GetItemList export allows you to retrieve the complete list of items defined in your shared/items.lua file. This is useful for accessing and managing all item data programmatically within your scripts.


How to Use

To get the full list of items, use the following code:

local itemList = exports['qs-inventory']:GetItemList()

for itemName, itemData in pairs(itemList) do
    print("Item Name: " .. itemName)
    print("Label: " .. itemData.label)
    print("Weight: " .. itemData.weight)
end

This will return a table containing all the items and their properties, such as name, label, weight, type, and more. You can use this to interact with or display item details dynamically in your scripts.

GetWeaponList

The GetWeaponList export allows you to retrieve the complete list of weapons defined in your shared/weapons.lua file. This is useful for accessing and managing all weapon data programmatically within your scripts.


How to Use

To get the full list of weapons, use the following code:

local weaponList = exports['qs-inventory']:GetWeaponList()

for weaponName, weaponData in pairs(weaponList) do
    print("Weapon Name: " .. weaponName)
    print("Label: " .. weaponData.label)
end

This will return a table containing all the weapons and their properties, such as name, label, damage, and more. You can use this to interact with or display weapon details dynamically in your scripts.

GetWeaponAttachmentItems

The GetWeaponAttachmentItems export allows you to retrieve the full list of weapon attachments configured in your config.lua, including suppressors, scopes, magazines, flashlights, tints, and more. This is useful for managing compatible attachments dynamically within your scripts or inventory systems.


How to Use

To get the full list of weapon attachments, use the following code:

local attachmentList = exports['qs-inventory']:GetWeaponAttachmentItems()

for _, attachment in pairs(attachmentList) do
    print("Item: " .. attachment.item)
    print("Attachment Type: " .. attachment.type)
    print("Attachment ID: " .. attachment.attachment)
end

This will return a table with all available attachment entries. Each attachment contains properties such as:

  • item: The inventory item name.

  • attachment: The internal attachment ID used by the weapon system.

  • type: The category (e.g., suppressor, clip, scope, tint, flash).

  • Optional: tint, label, forEveryWeapon, isUrlTint.

You can use this export to build custom weapon customization UIs, validate items, or extend the functionality of your weapon systems with ease.

GetInventory

The GetInventory export allows you to retrieve the inventory of a specific player. This is useful for checking items, quantities, or metadata associated with the items in their inventory.


How to Use

To get a player's inventory, use the following code:

local inventory = exports['qs-inventory']:GetInventory(playerSource)

if inventory then
    for slot, item in pairs(inventory) do
        print("Slot: " .. slot)
        print("Item Name: " .. item.name)
        print("Quantity: " .. item.amount)
        print("Metadata: " .. json.encode(item.info))
    end
else
    print("No inventory found for this player.")
end

This returns a table where each key represents a slot number, and each value contains the item's data (name, amount, info, etc.). You can use this structure to validate items, read specific metadata, or apply your own custom logic.

AddItem

The AddItem export allows you to add items to a player's inventory programmatically. It is particularly useful for adding items with metadata but can also be used for simple item additions without metadata.


How to Use

Adding Items with Metadata

If you need to include metadata, use the following example:

local playerSource = 1 -- Replace with the player's source ID
local itemName = "water_bottle"
local itemCount = 5
local itemSlot = nil -- Use nil to assign the first available slot
local itemMetadata = { expiry = "2025-01-01", quality = 100 }

exports['qs-inventory']:AddItem(playerSource, itemName, itemCount, itemSlot, itemMetadata)

Adding Items Without Metadata

If no metadata is required, you can use this simpler version:

local playerSource = 1 -- Replace with the player's source ID
local itemName = "water_bottle"
local itemCount = 5

exports['qs-inventory']:AddItem(playerSource, itemName, itemCount)

Explanation

  • source: The player's source ID.

  • item: The name of the item to add.

  • count: The quantity of the item to deliver.

  • slot: (Optional) Specify a slot to place the item; use nil for the next available slot.

  • metadata: (Optional) Add custom data like quality, expiry, or other attributes.

This export is flexible and suitable for creating items dynamically or adding custom properties to items when required.

RemoveItem

The RemoveItem export allows you to remove items from a player's inventory. It is particularly useful for managing items with metadata but can also be used to remove items without metadata.


How to Use

Removing Items with Metadata

If the item has metadata, use the following example:

local playerSource = 1 -- Replace with the player's source ID
local itemName = "water_bottle"
local itemCount = 2
local itemSlot = nil -- Use nil to match any slot
local itemMetadata = { expiry = "2025-01-01", quality = 100 }

exports['qs-inventory']:RemoveItem(playerSource, itemName, itemCount, itemSlot, itemMetadata)

Removing Items Without Metadata

If metadata is not needed, you can use this simpler version:

local playerSource = 1 -- Replace with the player's source ID
local itemName = "water_bottle"
local itemCount = 2

exports['qs-inventory']:RemoveItem(playerSource, itemName, itemCount)

Explanation

  • source: The player's source ID.

  • item: The name of the item to remove.

  • count: The quantity of the item to remove.

  • slot: (Optional) Specify a slot to target; use nil to remove from any slot.

  • metadata: (Optional) Specify metadata to match the item you want to remove.

This export provides flexibility for managing player inventories, whether you're removing basic items or handling items with specific attributes.

CanCarryItem

The CanCarryItem export checks if a player can carry a specified item based on their inventory capacity.


How to Use

To verify if a player can carry an item, use the following code:

local playerSource = 1 -- Replace with the player's source ID
local itemName = "water_bottle"
local itemCount = 5

local canCarry = exports['qs-inventory']:CanCarryItem(playerSource, itemName, itemCount)
if canCarry then
    print("Player can carry the item.")
else
    print("Player cannot carry the item.")
end

This will return true if the player has enough space for the specified item and false if not.

GetItemTotalAmount

The GetItemTotalAmount export allows you to check the total quantity of a specific item in a player's inventory.


How to Use

To get the total amount of an item, use the following code:

local playerSource = 1 -- Replace with the player's source ID
local itemName = "water_bottle"

local totalAmount = exports['qs-inventory']:GetItemTotalAmount(playerSource, itemName)
print("Total amount of " .. itemName .. ": " .. totalAmount)

This will return the total number of the specified item in the player's inventory.

GetItemLabel

The GetItemLabel export returns the label of a specific item, allowing you to retrieve its display name.


How to Use

To get the label of an item, use the following code:

local itemLabel = exports['qs-inventory']:GetItemLabel('tosti')
print("Item Label: " .. itemLabel)

This will return the label associated with the specified item.

CreateUsableItem

The CreateUsableItem export allows you to create items using QS logic, making it ideal for adding metadata or custom functionality to items.


How to Use

To create a usable item, use the following code:

local itemName = "water_bottle"

exports['qs-inventory']:CreateUsableItem(itemName, function(source, item)
    print("Player used item: " .. item.name)
    -- Add your custom logic here
    if item.metadata and item.metadata.quality then
        print("Item quality: " .. item.metadata.quality)
    end
end)

This creates a usable item and attaches the specified logic to it, allowing for dynamic behavior based on item properties or metadata.

SetItemMetadata

The SetItemMetadata export allows you to assign metadata to an existing item in a player's inventory.


How to Use

To set metadata for an item, use the following code:

local playerSource = 1 -- Replace with the player's source ID
local itemSlot = 2 -- Replace with the item's slot
local itemMetadata = { quality = 100, expiry = "2025-01-01" }

exports['qs-inventory']:SetItemMetadata(playerSource, itemSlot, itemMetadata)
print("Metadata updated for item in slot: " .. itemSlot)

This assigns the specified metadata to the item in the given inventory slot.

SetMetaData

The SetMetaData export allows you to assign specific metadata to a player, enabling custom information storage tied to their profile.


How to Use

To set metadata for a player, use the following code:

local playerIdentifier = "Player_CitizenID" -- Replace with the player's CitizenID or identifier
local metaInfo = "player_rank"
local metaValue = "Elite"

exports['qs-inventory']:SetMetaData(playerIdentifier, { [metaInfo] = metaValue })
print("Metadata '" .. metaInfo .. "' set to: " .. metaValue)

This assigns the specified metadata (metaInfo) with the given value (metaValue) to the player, allowing for flexible customizations.

GetMetaData

The GetMetaData export allows you to retrieve specific metadata associated with a player, enabling you to access custom information stored in their profile.


How to Use

To get metadata for a player, use the following code:

local playerIdentifier = "Player_CitizenID" -- Replace with the player's identifier

local metaData = exports['qs-inventory']:GetMetaData(playerIdentifier)
if metaData then
    print("Player Metadata: " .. json.encode(metaData))
else
    print("No metadata found for the player.")
end

This retrieves and prints the metadata associated with the specified player, providing flexibility for custom logic and features.

GiveItemToPlayer

The GiveItemToPlayer export allows you to deliver items to a player, including items with metadata. It can be configured in server/custom for more customization.


How to Use

To give an item to a player, use the following code:

local playerSource = 1 -- Replace with the player's source ID
local itemName = "water_bottle"
local itemCount = 5

exports['qs-inventory']:GiveItemToPlayer(playerSource, itemName, itemCount)
print("Gave " .. itemCount .. " " .. itemName .. " to player.")

This delivers the specified item and quantity to the targeted player's inventory. You can expand the functionality by adding metadata configurations in server/custom.

GetTotalUsedSlots

The GetTotalUsedSlots export allows you to retrieve the total number of slots currently in use in a player's inventory.


How to Use

To get the used slots in a player's inventory, use the following code:

local playerSource = 1 -- Replace with the player's source ID

local usedSlots = exports['qs-inventory']:GetTotalUsedSlots(playerSource)
print("Total used slots: " .. usedSlots)

This returns the total number of inventory slots that are occupied by items for the specified player.

RegisterStash

The RegisterStash export allows you to create stashes dynamically with a simple and flexible configuration.


How to Use

To register a stash, use the following code:

local playerSource = 1 -- Replace with the player's source ID
local stashID = "police_armory" -- Unique identifier for the stash
local stashSlots = 50 -- Total number of slots available
local stashWeight = 1000 -- Maximum weight capacity of the stash

exports['qs-inventory']:RegisterStash(playerSource, stashID, stashSlots, stashWeight)
print("Stash registered: " .. stashID)

This creates a stash with the specified identifier, number of slots, and weight capacity for the specified player. Stashes can be used for custom storage solutions like personal lockers or organizational armories.

AddItemIntoStash

The AddItemIntoStash export allows you to add items directly into a specified stash, including specifying slots.


How to Use

To add an item to a stash, use the following code:

local stashID = "stash_house" -- Identifier for the stash
local itemName = "bread" -- Name of the item to add
local itemAmount = 10 -- Quantity of the item
local itemSlot = nil -- Specify a slot or use nil for automatic placement
local stashSlots = 50 -- Total slots available in the stash
local stashMaxWeight = 1000 -- Maximum weight capacity of the stash

exports['qs-inventory']:AddItemIntoStash(stashID, itemName, itemAmount, itemSlot, nil, stashSlots, stashMaxWeight)
print("Added " .. itemAmount .. " " .. itemName .. " to stash: " .. stashID)

This export enables you to manage stashes efficiently by dynamically adding items while respecting the stash's slot and weight limitations.

RemoveItemIntoStash

The RemoveItemIntoStash export allows you to remove items from a specified stash dynamically.


How to Use

To remove an item from a stash, use the following code:

local stashID = "stash_house" -- Identifier for the stash
local itemName = "bread" -- Name of the item to remove
local itemAmount = 5 -- Quantity of the item to remove
local itemSlot = nil -- Specify a slot or use nil for automatic targeting
local stashSlots = 50 -- Total slots available in the stash
local stashMaxWeight = 1000 -- Maximum weight capacity of the stash

exports['qs-inventory']:RemoveItemIntoStash(stashID, itemName, itemAmount, itemSlot, stashSlots, stashMaxWeight)
print("Removed " .. itemAmount .. " " .. itemName .. " from stash: " .. stashID)

This export ensures efficient management of stash contents by removing specified items while respecting slot and weight parameters.

GetStashItems

The GetStashItems export allows you to check all items currently stored in a specified stash.


How to Use

To retrieve items from a stash, use the following code:

local stashID = "stash_house" -- Identifier for the stash

local stashItems = exports['qs-inventory']:GetStashItems(stashID)

if stashItems then
    for slot, itemData in pairs(stashItems) do
        print("Slot: " .. slot)
        print("Item: " .. itemData.name)
        print("Amount: " .. itemData.amount)
    end
else
    print("No items found in stash: " .. stashID)
end

This retrieves all items in the specified stash, including their slot, name, and quantity, for further processing or display.

AddToTrunk

The AddToTrunk export allows you to add a specific item to a vehicle’s trunk.


How to Use

To add an item to a trunk, use the following code:

exports['qs-inventory']:AddToTrunk('plate', 1, 1, 'sandwich', 1)

This adds the item 'sandwich' to slot 1 of the trunk identified by the vehicle's plate, with a quantity of 1.

RemoveFromTrunk

The RemoveFromTrunk export allows you to remove a specific item from a vehicle’s trunk.


How to Use

To remove an item from a trunk, use the following code:

exports['qs-inventory']:RemoveFromTrunk(source, 'plate', 1, 'sandwich', 1)

This removes the item 'sandwich' from slot 1 of the trunk identified by the vehicle's plate, triggered by the given player source.

ClearOtherInventory

The ClearOtherInventory export allows you to wipe the contents of a specific external inventory, such as a stash, trunk, or custom storage.


How to Use

To clear an external inventory, use the following code:

RegisterCommand('clearother', function(source, args, raw)
    exports['qs-inventory']:ClearOtherInventory('stash', 'inventory_stash_example')
end)

This command clears the stash identified by the name 'inventory_stash_example'. The first parameter 'stash' indicates the inventory type (it could be 'trunk', 'glovebox', etc.). Once executed, all items inside that stash will be permanently removed.

🛑 Warning: This action cannot be undone. Use it with caution in live environments.

UpdateVehiclePlate

The UpdateVehiclePlate export allows you to update or change the license plate of a specific vehicle in the inventory system, ensuring that all references to that vehicle are correctly updated across the database or saved states.


How to Use

To update a vehicle’s plate, use the following code:

exports['qs-inventory']:UpdateVehiclePlate('LI3WDCRV', 'KVT78I33')

This function replaces the old plate 'LI3WDCRV' with the new one 'KVT78I33'. The first parameter is the current plate of the vehicle, and the second parameter is the new plate you want to assign.

Once executed, any inventory or storage data linked to the old plate will now be reassigned to the new one, maintaining consistency and preventing data conflicts.