YaBackpackComponent¶
YaBackpackComponent
manages the backpack and items to be put in or moved out of the backpack.
Note: YaBackpackComponent
is attached to a player entity by default, rather than a character entity.Functions¶
Array<YaBackpackStacks> GetAll()¶
Returnsitems Info
Gets the information of all the items in the backpack.
number GetCapacity()¶
Returnsthe capacity
Gets the capacity of the backpack.
number GetCount(number itemID)¶
Returnsthe count
Returns the total number of the items in the backpack by itemId.
itemID
the item id
number Addable(number itemID, number count)¶
Returnscould be added to the backpack's count
Whether the item could be add to the backpack.
itemID
itemIdcount
add count
void Sort()¶
Sort the backpack.
void Clear()¶
Clear the backpack.
boolean Replace(number fromIndex, number toIndex)¶
SERVER ONLY
Returnstrue if success
Exchange the position of the two item in backpack.
fromIndex
fromtoIndex
to
void Add(number itemID, number count)¶
SERVER ONLY
Add item to backpack.
itemID
itemIdcount
count
void Add(number itemID, number entityId, number count)¶
SERVER ONLY DEPRECATED
Obsoleted,use Add(int itemID, int count) instead.
itemID
itemIdentityId
item's entityIdcount
item count
void Remove(number index, number count)¶
SERVER ONLY
Remove an item from backpack.
index
the index in backpackcount
count
void RemoveByItemId(number itemID, number count, number fromIndex)¶
SERVER ONLY
Remove item from backpack by itemId.
itemID
itemIdcount
countfromIndex
start position in backpack
void Enable()¶
SERVER ONLY
Enable backpack.
void Disable()¶
SERVER ONLY
Disable backpack.
Events¶
ChangedEvent<void>¶
Fired when the backpack's data changed.
ItemAddedEvent<BackpackItemChange>¶
Fired when an item is added.
ChangeInfo
The added item info.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
ItemRemovedEvent<BackpackItemChange>¶
Fired when an item is removed.
ChangeInfo
The removed item info.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Code sample¶
Code sample
1 2 3 4 5 6 7 8 9 10 11 12 |
|