Skip to content
On this page

Athena.getters.player

Functions

byAccount

Usage

Athena.getters.player.byAccount(id): alt.Player | undefined

Gets an online player by account identifier based on their MongoDB account _id.

Example

ts
const player = Athena.getters.player.byAccount('123456789');
if (player) {
    console.log(`Found player ${player.id} with account ID ${player.account._id}`);
} else {
   console.log('No player found with that account ID');
}

Parameters

NameType
idstring

Returns

alt.Player | undefined

Defined in

server/getters/player.ts:26


byDatabaseID

Usage

Athena.getters.player.byDatabaseID(id): alt.Player | undefined

Get an online player based on their MongoDB _id

Example

ts
const id = 'abc123jkfewfwe';
const player = Athena.getters.player.byDatabaseID(id);

if (player) {
    console.log(`Found player with id ${id}`);
} else {
    console.log(`No player found with the id '${id}'`);
}

Parameters

NameType
idstring

Returns

alt.Player | undefined

Defined in

server/getters/player.ts:133


byID

Usage

Athena.getters.player.byID(id): alt.Player | undefined

Return a player based on their ID given the Identifier strategy currently setup. Use this to get the player in-game that you see with your eyes.

Parameters

NameType
idnumber

Returns

alt.Player | undefined

Defined in

server/getters/player.ts:155


byName

Usage

Athena.getters.player.byName(name): alt.Player | undefined

Gets an online player by their name.

Not case sensitive and returns the first player it finds matching that name.

Example

ts
const player = Athena.getters.player.byName('john_fettermanjoe');
if (player) {
    console.log(`Found player ${player.id} with name ${player.name}`);
} else {
    console.log('No player found with that name');
}

Parameters

NameType
namestring

Returns

alt.Player | undefined

Defined in

server/getters/player.ts:63


byPartialName

Usage

Athena.getters.player.byPartialName(partialName): alt.Player | undefined

Gets an online player by their partial name.

Not case sensitive and returns the first player it finds that includes the partial

Example

ts
const partialName = 'john';
const player = Athena.getters.player.byPartialName(partialName);

if (player) {
    console.log(`Found player ${player.id} with name ${player.name}`);
} else {
    console.log(`No player found with the partial name '${partialName}'`);
}

Parameters

NameType
partialNamestring

Returns

alt.Player | undefined

Defined in

server/getters/player.ts:99


characters

Usage

Athena.getters.player.characters(playerOrAccount): Promise<player[]>

Returns all characters that belong to a player. Requires account info, player, or account id string.

Parameters

NameType
playerOrAccountany

Returns

Promise<player[]>

Defined in

server/getters/player.ts:318


closestOwnedVehicle

Usage

Athena.getters.player.closestOwnedVehicle(player): alt.Vehicle | undefined

Returns the closest owned vehicle for a given player. Counts any owned vehicles from other players that have supplied an injection for ownership. Ignores vehicles with keyless for start.

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity

Returns

alt.Vehicle | undefined

Defined in

server/getters/player.ts:262


closestToPlayer

Usage

Athena.getters.player.closestToPlayer(player): alt.Player | undefined

The player closest to a player.

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity

Returns

alt.Player | undefined

Defined in

server/getters/player.ts:240


closestToVehicle

Usage

Athena.getters.player.closestToVehicle(vehicle): alt.Player | undefined

The player closest to a vehicle.

Parameters

NameTypeDescription
vehicleVehicleAn alt:V Vehicle Entity

Returns

alt.Player | undefined

Defined in

server/getters/player.ts:250


inFrontOf

Usage

Athena.getters.player.inFrontOf(player, startDistance?): Promise<alt.Player | undefined>

Creates a temporary ColShape in front of the player. The ColShape is then used to check if the entity is present within the ColShape. It will keep subtract distance until it finds a player near the player that is in the ColShape. Works best on flat land or very close distances.

Parameters

NameTypeDefault valueDescription
playerPlayerundefinedAn alt:V Player Entity
startDistance?number6

Returns

Promise<alt.Player | undefined>

Defined in

server/getters/player.ts:169


isDead

Usage

Athena.getters.player.isDead(player): boolean

Determine if a player is currently dead / marked as dead.

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity

Returns

boolean

Defined in

server/getters/player.ts:350


isNearPosition

Usage

Athena.getters.player.isNearPosition(player, pos, dist?): boolean

Checks if a player is within 3 distance of a position.

Parameters

NameTypeDefault valueDescription
playerPlayerundefinedAn alt:V Player Entity
posIVector3undefinedA position in the world.
distnumber3-

Returns

boolean

Defined in

server/getters/player.ts:220


isValid

Usage

Athena.getters.player.isValid(player): boolean

Determine if a player is valid, and spawned as a character.

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity

Returns

boolean

Defined in

server/getters/player.ts:366


ownedVehicleDocuments

Usage

Athena.getters.player.ownedVehicleDocuments(player): Promise<player[]>

Get all owned vehicles from the database for a given character.

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity

Returns

Promise<player[]>

Defined in

server/getters/player.ts:302


waypoint

Usage

Athena.getters.player.waypoint(player): alt.IVector3 | undefined

Get the current waypoint marked on a player's map. Will return undefined it is not currently set.

Parameters

NameTypeDescription
playerPlayerAn alt:V Player Entity

Returns

alt.IVector3 | undefined

Defined in

server/getters/player.ts:230

Created by Stuyk | Est. 2020