Samuel's Development, Official Documentation
  • 🎉Welcome
  • 📑Overview
    • Resources
      • Bobcat Weapon Heist
        • Installation Guide
        • Configuration
      • Traphouse Robbery
        • Installation Guide
        • Configuration
      • Pacific Bank Heist
        • Installation Guide
        • Configuration
      • Oxy Run
        • Installation Guide
        • Configuration
      • Dumpster Diving
        • Installation Guide
        • Configuration
        • Log Configuration
      • Warehouse Heist
        • Installation Guide
        • Configuration
      • Oil Rig
        • Installation Guide
        • Configuration
      • Beekeeping
        • Installation Guide
        • Configuration
        • Log Configuration
      • Yacht Robbery
        • Installation Guide
        • Configuration
      • Notify
        • Installation
        • Configuration
      • Cocaine Mission
        • Installation Guide
        • Configuration
      • Advanced Drug Sales
        • Installation Guide
        • Configuration
    • Library
      • Installation & Integration
      • Modules
        • Client
          • Callback
          • StartProgress
          • LoadAnim
          • LoadModel
          • LoadPtfxAsset
          • ShowNotification
          • SendEmail
          • PoliceDispatch
          • StartHack
        • Server
          • Callback
          • Name
          • Money
          • Logger
          • Inventory
          • HasGroup
          • GetPlayer
          • GetPlayers
          • GetPlayerByIdentifier
          • GetIdentifier
          • GetPlayerGender
          • CheckVersion
        • Shared
          • Array
          • Table
          • String
          • Math
          • Locale
            • JSON Example
          • AwaitLoad
          • Framework
  • 📚F.A.Q
    • How do I change Locales?!
    • How to add Police Alerts?!
    • What types of dirty money are supported?
Powered by GitBook
On this page
  • Overview
  • Inventory.HasItem
  • Inventory.AddItem
  • Inventory.RemoveItem
  • Inventory.AddWeapon
  • Inventory.RegisterUsableItem
  1. Overview
  2. Library
  3. Modules
  4. Server

Inventory

The SD.Inventory module provides a comprehensive set of functionalities for inventory management across different frameworks, supporting operations like adding, removing, and checking items in player inventories. It is designed to be adaptable to multiple backend systems, including custom integrations like 'ox_inventory' and popular frameworks like 'ESX' and 'QB/QBX'.

Overview

Purpose: Facilitates the management of player inventory system, providing seamless integration with various inventory frameworks.

Inventory.HasItem

Purpose: Checks the quantity of a specific item in a player's inventory.

Parameters:

  • source (number): The player's server ID.

  • item (string): The item's name.

Returns:

  • (number): The quantity of the item present in the player's inventory.

Usage Example:

local itemCount = SD.Inventory.HasItem(source, 'water')
print(itemCount)

Inventory.AddItem

Purpose: Adds a specified quantity of an item to a player's inventory.

Parameters:

  • source (number): The player's server ID.

  • item (string): The item's name.

  • count (number): The quantity of the item to add.

  • slot (number|nil): The specific inventory slot to use, if applicable.

  • metadata (table|nil): Additional metadata for the item, if needed.

Usage Example:

SD.Inventory.AddItem(source, 'water', 10)

Inventory.RemoveItem

Purpose: Removes a specified quantity of an item from a player's inventory. Parameters:

  • source (number): The player's server ID.

  • item (string): The item's name.

  • count (number): The quantity of the item to remove.

  • slot (number|nil): The specific inventory slot to use, if applicable.

  • metadata (table|nil): Additional metadata for the item, if needed.

Usage Example:

SD.Inventory.RemoveItem(source, 'water', 5)

Inventory.AddWeapon

Purpose: Adds a weapon to a player's inventory along with specified ammunition. Parameters:

  • source (number): The player's server ID.

  • weapon (string): The weapon's name.

  • ammo (number): The amount of ammunition to add with the weapon.

Usage Example:

SD.Inventory.AddWeapon(source, 'pistol', 50)

Inventory.RegisterUsableItem

Purpose: Registers an item as usable within the game, associating it with a callback function that is triggered when the item is used. Parameters:

  • item (string): The item's name.

  • cb (function): The callback function to execute when the item is used.

Usage Example:

SD.Inventory.RegisterUsableItem('medkit', function(player)
    print('Medkit used by', player)
end)

PreviousLoggerNextHasGroup

Last updated 1 year ago

📑