Jump to content

Recommended Posts

  • Leadership Team

Username:  @lordcara
Creator: 
Download:

This is the hidden content, please

This is the hidden content, please

 

 

image.pngimage.png

 

reply
type: ITEM_TYPES; //item type
typeCategory: ITEM_TYPE_CATEGORY; //item category see ITEM_TYPE_CATEGORY enum in index.d.ts
isPlaced: boolean; //whether item is 'placed' in clothes
quality: number; //item quality level
image: string; //item image
hash: string; //unique item hash, also used as linked to a child item
key: string; //item key which contains clothes data only (such as component id, drawable and texture)
render: string; //item render image which later on can be used in CDN if you have plenty items.
name: string; //item name
description: string; //item description
count: number; //item count, also determines whether you can split an item up
weight: number; //item weight
maxStack: number; //max stack determines how many items can be stacked in one slot
options: string[]; //item options (to be used when you right click an item) such
gender: number | null; //item gender, used on clothes whether the clothe is for female or male

modelHash?: string; //prop model name or hash that will be used to create object when dropping item
ammoType?: string; //ammo type that a weapon will contain
ammoInClip?: number; //ammo in weapon clip
amount?: number; //used for armor to contain its amount
effect?: {
//a feature to be developed whether the item will have an effect or not
[key: string]: number;
};
components?: Array<number>; //will be used for weapon attachments in future
reply

Class Structure

The Inventory class is the main class for managing player inventories in a game. It extends from other classes such as InventoryClothes, QuickUse, and InventoryItem.

  • InventoryBase: Base class for inventory management. It initializes the inventory structure and handles basic operations.
  • InventoryItem: Extends InventoryBase and adds methods for managing individual items in the inventory.
  • QuickUse: Extends InventoryItem and adds methods for managing quick-use slots.
  • InventoryClothes: Extends QuickUse and adds methods for managing clothing items in the inventory.

This class provides comprehensive functionality for managing player inventories, including adding, removing, equipping, and using items.

Properties

  • items: Contains the player's inventory items, divided into pockets and clothes.
  • quickUse: Contains items assigned to quick-use slots.
  • weight: Represents the total weight capacity of the inventory.
  • equippedWeapons: Keeps track of equipped weapons.

Constructor

  • Initializes the inventory with player-specific data such as clothes, pockets, and quick-use items.

Methods

  • addItem: Adds an item to the inventory's pockets.
  • addClothingItem: Adds a clothing item to the inventory.
  • removeClothes: Removes a clothing item from the player's character.
  • loadClothes: Loads clothing items onto the player's character.
  • setClothes: Sets clothing items on the player's character.
  • reloadClothes: Reloads clothing items onto the player's character.
  • getFreeSlot: Retrieves a free slot in the inventory pockets.
  • getTotalFreeSlots: Counts the total number of free slots in the inventory.
  • getClothingIndex: Retrieves the index of a specific clothing item type.
  • resetItemData, resetClothingItemData, resetBackpackItemData: Resets item data in the inventory.
  • updateOnScreenPed: Updates the player's character appearance on-screen.
  • getItemModel: Retrieves the model hash of an item type.
  • getItemAndStack, getItemsByHashName, getItemsInCategoryByHashName, getItemsByHashNameEx: Methods for retrieving items by their type or category.
  • getItemByUUID: Retrieves an item by its UUID.
  • hasPistolItem, hasShotgun, hasAssault, hasSMG, hasWeaponInFastSlot: Methods for checking if the inventory contains specific weapon types.
  • getActualWeight, getWeight, getItemsWeight: Methods for calculating the weight of the inventory and its items.
  • checkWeight: Checks if adding a new item will exceed the weight limit.
  • getFreeSlotCount: Retrieves the count of free slots in the inventory.
  • dropItem, splitStack, addPlayerItem, addPlayerItemEx, addMultipleItems, addCountToPlayerItem, manageFastSlots, pickupItem, moveItem, openItem, useItem: Methods for managing inventory actions such as dropping, splitting, adding, and using items.
  • deleteItemStack, deleteItem: Methods for deleting items from the inventory.
  • checkQuickUse: Checks if an item is in a quick-use slot.

 

Link to comment
https://easy-code.ro/topic/1486-inventory-system/
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.

Board Life Status


Board startup date: October 22, 2021 17:08:30


×
×
  • Create New...