Player Identifiers
Server-side utilities for working with FiveM player identifiers.
Overview
FiveM players have multiple identifiers from different authentication providers. This module provides type-safe access to parse and query these identifiers.
Identifier Format
Identifiers follow the pattern type:value:
| Type | Example | Source |
|---|---|---|
license | license:abc123def456 | Rockstar license |
steam | steam:110000102345678 | Steam ID |
discord | discord:123456789012345678 | Discord ID |
xbl | xbl:2535123456789 | Xbox Live |
fivem | fivem:12345 | FiveM account |
Usage
"use server";
import {
collectPlayerIdentifiers,
getPrimaryLicense
} from "@core/player";
// Get all identifiers
const identifiers = collectPlayerIdentifiers(playerId);
// Returns: [{ type: "license", value: "abc...", raw: "license:abc..." }, ...]
// Get primary license (used for persistence)
const license = getPrimaryLicense(playerId);
if (license) {
await db.collection("players").findOne({ license });
}
Common Patterns
Player Profile Lookup
@Server
async getPlayerProfile(ctx: EventContext<[]>): Promise<Profile | null> {
const license = getPrimaryLicense(ctx.source);
if (!license) return null;
return await playerRepository.findByLicense(license);
}
Multi-Identifier Matching
function findPlayerByAnyIdentifier(identifiers: PlayerIdentifier[]) {
return db.collection("players").findOne({
$or: identifiers.map(id => ({ [`identifiers.${id.type}`]: id.value }))
});
}
Best Practices
- Use
licenseas primary key - Most reliable identifier - Store multiple identifiers - For account linking and recovery
- Handle missing identifiers - Not all players have all types
- Server-side only - Identifiers are available on server