# Backpack Management

Before using the backpack API, please create backpack management objects. Methods are as follow:

local Backpack = class.Backpack.new()

The specific function name and description are as follows:

Serial number Function name Description
1 getBackpackBarIDRange(...) Get the range of backpack bar's ID(Start ID~End ID)
2 getBackpackBarSize(...) Get the size of backpack bar
3 setGridItem(...) Set the backpack
4 removeGridItem(...) Remove some items in backpack bar. Removed by item slots. All removed by default
5 removeGridItemByItemID(...) Remove some items in backpack bar. Removed by item ID. All removed by default
6 clearPack(...) Clear designate backpack bar
7 clearAllPack(...) Clear all the backpack(including backpack bar, shortcut bar, equip bar)
8 moveGridItem(...) Remove items in backpack. All transferred by default
9 swapGridItem(...) Exchange item backpack
10 enoughSpaceForItem(...) If there is enough space in backpack(including backpack bar, shortcut bar) to store items
11 calcSpaceNumForItem(...) Calculate the total number of remaining items that the backpack(including backpack bar, shortcut bar) can store
12 getBackpackBarValidList(...) Get valid list of items' ID which are already in backpack bar. Item ID
13 getBackpackBarItemList(...) Get items already in backpack bar. Item ID
14 hasItemByBackpackBar(...) Detect if there is any designated item in backpack
15 getItemNumByBackpackBar(...) Get the total number of items in backpack. Return to backpacks with items
16 getGridItemID(...) Obtain ID of items in backpack slots(Return to itemid, num)
17 getGridItemName(...) Get item name in backpack
18 getGridStack(...) Obtain the number of stacks in backpack slot(Back to curstack, maxstack)
19 getGridDurability(...) Obtain the durability of backpack slot(Back to durcur, durmax)
20 getGridEnchantList(...) Get enchantment of items in backpack. Return to enchantment ID.
21 getGridToolType(...) Get the item tool type in backpack (<0 means non-tool)
22 addItem(...) Add the item to backpack
23 discardItem(...) Discard an item in backpack slot
24 getGridNum(...) Get the number of items in one slot of backpack

# getBackpackBarIDRange

  • Parameters and types:
    • bartype:number backpack type, shortcut bar, saving bar,equipment bar
  • Return value and types:
  • The main role of this method: Get the range of backpack bar's ID(Start ID~End ID)
  • The specific use cases are as follows:
local result = Backpack:getBackpackBarIDRange(bartype)

# getBackpackBarSize

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the size of backpack bar
  • The specific use cases are as follows:
local result = Backpack:getBackpackBarSize(bartype)

# setGridItem

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the backpack
  • The specific use cases are as follows:
local result = Backpack:setGridItem(playerid, gridid, itemid, num, durability)

# removeGridItem

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Remove some items in backpack bar. Removed by item slots. All removed by default
  • The specific use cases are as follows:
local result = Backpack:removeGridItem(playerid, gridid, num)

# removeGridItemByItemID

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Remove some items in backpack bar. Removed by item ID. All removed by default
  • The specific use cases are as follows:
local result = Backpack:removeGridItemByItemID(playerid, itemid, num)

# clearPack

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Clear designate backpack bar
  • The specific use cases are as follows:
local result = Backpack:clearPack(playerid, bartype)

# clearAllPack

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Clear all the backpack(including backpack bar, shortcut bar, equip bar)
  • The specific use cases are as follows:
local result = Backpack:clearAllPack(playerid)

# moveGridItem

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Remove items in backpack. All transferred by default
  • The specific use cases are as follows:
local result = Backpack:moveGridItem(playerid, gridsrc, griddst, num)

# swapGridItem

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Exchange item backpack
  • The specific use cases are as follows:
local result = Backpack:swapGridItem(playerid, gridsrc, griddst)

# enoughSpaceForItem

  • Parameters and types:
  • Return value and types:
  • The main role of this method: If there is enough space in backpack(including backpack bar, shortcut bar) to store items
  • The specific use cases are as follows:
local result = Backpack:enoughSpaceForItem(playerid, itemid, num)

# calcSpaceNumForItem

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Calculate the total number of remaining items that the backpack(including backpack bar, shortcut bar) can store
  • The specific use cases are as follows:
local result = Backpack:calcSpaceNumForItem(playerid, itemid)

# getBackpackBarValidList

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get valid list of items' ID which are already in backpack bar. Item ID
  • The specific use cases are as follows:
local result = Backpack:getBackpackBarValidList(playerid, bartype)

# getBackpackBarItemList

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get items already in backpack bar. Item ID
  • The specific use cases are as follows:
local result = Backpack:getBackpackBarItemList(playerid, bartype)

# hasItemByBackpackBar

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Detect if there is any designated item in backpack
  • The specific use cases are as follows:
local result = Backpack:hasItemByBackpackBar(playerid, bartype, itemid)

# getItemNumByBackpackBar

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the total number of items in backpack. Return to backpacks with items
  • The specific use cases are as follows:
local result = Backpack:getItemNumByBackpackBar(playerid, bartype, itemid)

# getGridItemID

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain ID of items in backpack slots(Return to itemid, num)
  • The specific use cases are as follows:
local result = Backpack:getGridItemID(playerid, gridid)

# getGridItemName

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get item name in backpack
  • The specific use cases are as follows:
local result = Backpack:getGridItemName(playerid, gridid)

# getGridStack

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain the number of stacks in backpack slot(Back to curstack, maxstack)
  • The specific use cases are as follows:
local result = Backpack:getGridStack(playerid, gridid)

# getGridDurability

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain the durability of backpack slot(Back to durcur, durmax)
  • The specific use cases are as follows:
local result = Backpack:getGridDurability(playerid, gridid)

# getGridEnchantList

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get enchantment of items in backpack. Return to enchantment ID.
  • The specific use cases are as follows:
local result = Backpack:getGridEnchantList(playerid, gridid)

# getGridToolType

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the item tool type in backpack (<0 means non-tool)
  • The specific use cases are as follows:
local result = Backpack:getGridToolType(playerid, gridid)

# addItem

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Add the item to backpack
  • The specific use cases are as follows:
local result = Backpack:addItem(playerid, itemid, num)

# discardItem

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Discard an item in backpack slot
  • The specific use cases are as follows:
local result = Backpack:discardItem(playerid, gridid, num)

# getGridNum

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the number of items in one slot of backpack
  • The specific use cases are as follows:
local result = Backpack:getGridNum(playerid, gridid)
Last Update: 11/22/2019, 2:31:59 PM