Skip to content
On this page

Athena.player.inventory

Modules

Functions

add

Usage

Athena.player.inventory.add(player, item): Promise<boolean>

Add a new stored item to a user, must specify a quantity of greater than zero.

Automatically checks weight upon new item additions. Exceeding the weight; cancels the add.

Does not look into toolbar.

Example

ts
const didAdd = await Athena.player.inventory.add(somePlayer, { dbName: 'burger', quantity: 1, data: {} })

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity
itemOmit<StoredItem, "slot">

Returns

Promise<boolean>

Defined in

server/player/inventory.ts:24


getAt

Usage

Athena.player.inventory.getAt<CustomData>(player, slot): player<CustomData> | undefined

Returns an item from a specific slot.

This item is cloned, and not attached to the inventory.

Never modify the item directly; this is only to get item information.

Example

ts
const someData = Athena.player.inventory.getAt<{ myCustomStuff: string }>(somePlayer, someSlot);

Type parameters

NameType
CustomData{}

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity
slotnumber

Returns

player<CustomData> | undefined

Defined in

server/player/inventory.ts:219


getItemData

Usage

Athena.player.inventory.getItemData<CustomData>(player, slot): CustomData | undefined

Returns the custom item data assigned to a specific item.

Will return undefined if the custom data is not available.

Only checks the inventory.

Example

ts
const someData = Athena.player.inventory.getItemData<{ myCustomStuff: string }>(somePlayer, someSlot);

Type parameters

NameType
CustomData{}

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity
slotnumber

Returns

CustomData | undefined

Defined in

server/player/inventory.ts:178


has

Usage

Athena.player.inventory.has(player, dbName, quantity, version?): any

Verify that the player has at least 'x' of an item in their inventory

Example

ts
const hasItem = await Athena.player.inventory.has(somePlayer, 'burger', 1);

Parameters

NameTypeDefault valueDescription
playerPlayerundefinedAn alt:V Player Entity
dbNamestringundefined-
quantitynumberundefined-
versionanyundefined-

Returns

any

Defined in

server/player/inventory.ts:143


modifyItemData

Usage

Athena.player.inventory.modifyItemData<CustomData>(player, slot, customData): Promise<boolean>

Find an item at a specific slot, and changes its entire custom data section.

Think of this like an easy to use 'setter' for item data.

Only checks the inventory.

Example

ts
const someData = Athena.player.inventory.getItemData<{ myCustomStuff: string }>(somePlayer, someSlot);

someData.myCustomStuff = 'Hello World!';

await Athena.player.inventory.modifyItemData<typeof someData>(player, someSlot, someData);

Type parameters

NameType
CustomData{}

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity
slotnumber
customDataCustomData-

Returns

Promise<boolean>

Defined in

server/player/inventory.ts:264


override

Usage

Athena.player.inventory.override(functionName, callback): any

Used to override any internal inventory functions

Parameters

NameType
functionName"add"
callback(player: Player, item: Omit<StoredItem, "slot">) => Promise<boolean>

Returns

any

Defined in

server/player/inventory.ts:305

Usage

Athena.player.inventory.override(functionName, callback): any

Used to override any internal inventory functions

Parameters

NameType
functionName"getAt"
callback<CustomData>(player: Player, slot: number) => player<CustomData> | undefined

Returns

any

Defined in

server/player/inventory.ts:306

Usage

Athena.player.inventory.override(functionName, callback): any

Used to override any internal inventory functions

Parameters

NameType
functionName"has"
callback(player: Player, dbName: string, quantity: number, version: any) => any

Returns

any

Defined in

server/player/inventory.ts:307

Usage

Athena.player.inventory.override(functionName, callback): any

Used to override any internal inventory functions

Parameters

NameType
functionName"sub"
callback(player: Player, item: Omit<StoredItem, "slot" | "data">) => Promise<boolean>

Returns

any

Defined in

server/player/inventory.ts:308

Usage

Athena.player.inventory.override(functionName, callback): any

Used to override any internal inventory functions

Parameters

NameType
functionName"remove"
callback(player: Player, slot: number) => Promise<boolean>

Returns

any

Defined in

server/player/inventory.ts:309

Usage

Athena.player.inventory.override(functionName, callback): any

Used to override any internal inventory functions

Parameters

NameType
functionName"modifyItemData"
callback<CustomData>(player: Player, slot: number, customData: CustomData) => Promise<boolean>

Returns

any

Defined in

server/player/inventory.ts:310

Usage

Athena.player.inventory.override(functionName, callback): any

Used to override any internal inventory functions

Parameters

NameType
functionName"getItemData"
callback<CustomData>(player: Player, slot: number) => CustomData | undefined

Returns

any

Defined in

server/player/inventory.ts:311


remove

Usage

Athena.player.inventory.remove(player, slot): Promise<boolean>

Delete an item in a specific slot in an inventory data set.

Does not look into toolbar.

Example

ts
const didRemove = await Athena.player.inventory.remove(somePlayer, someSlot);

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity
slotnumber

Returns

Promise<boolean>

Defined in

server/player/inventory.ts:107


sub

Usage

Athena.player.inventory.sub(player, item): Promise<boolean>

Subtract a quantity of an item from a player's inventory. Does not look into toolbar.

Example

ts
const didRemove = await Athena.player.inventory.sub(somePlayer, { dbName: 'burger', quantity: 1 });

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity
itemOmit<StoredItem, "slot" | "data">

Returns

Promise<boolean>

Defined in

server/player/inventory.ts:70

Created by Stuyk | Est. 2020