leet.players

A script can read players' names and factions, and tell who is a server admin and who is on the user's friends list (the client's friends list). Name and faction are available for every player on the server, even far away. Distance is known only for players near you.

To react to admins coming close, see leet.events.onAdminNearby.

Player arguments

Functions that take a player accept either of:

  • an mp player object, meaning anything with a numeric remoteId, for example mp.players.local, or an entry from mp.players.forEach / mp.players.forEachInStreamRange;
  • a remote id, an integer from 0 to 65535.

Anything else throws leet: invalid player. A valid argument that does not match a player on the server is not an error: the result is simply false (null for get).

Distance and hidden admins

The objects returned by admins(), friends(), get() and all(), and onAdminNearby events, carry a distance:

  • a number: the distance to the local player in meters, when the player is near enough to be visible;
  • null: the player is too far away to be visible (and, briefly, while your own character is not loaded).

An admin with hidden: true is close to you but invisible (not shown in the world). The Hidden Admins switch (Visuals, HUD) gives the most complete detection.

  • In admins() and onAdminNearby events, hidden admins always have distance 0.
  • get() and all() do not report hidden admins: there such an admin has distance null and streamed false, like any player who is not visible.

leet.players.isAdmin

TypeScript
leet.players.isAdmin(player: PlayerMp | number): boolean

Returns true if the player is a server admin, false otherwise, including for an unknown or absent player. On some servers this is an estimate and can be wrong.

JavaScript
if (leet.players.isAdmin(42)) leet.ui.notify('#42 is an admin', 'warning');

Parameters

Errors: leet: invalid player (player is neither an object with a numeric remoteId nor an integer from 0 to 65535).

leet.players.isFriend

TypeScript
leet.players.isFriend(player: PlayerMp | number): boolean

Returns true if the player is on the user's friends list, false otherwise, including for an unknown or absent player.

JavaScript
mp.players.forEachInStreamRange((p) => {
    if (leet.players.isFriend(p)) mp.console.logInfo(`Friend nearby: ${p.name}`);
});

Parameters

Errors: leet: invalid player (player is neither an object with a numeric remoteId nor an integer from 0 to 65535).

leet.players.admins

TypeScript
leet.players.admins(): Array<{ remoteId: number, name: string, distance: number | null, dimension: number, hidden: boolean }>

Returns all admins currently on the server, except the local player. The array is empty if there are no admins online. Never throws.

JavaScript
const admins = leet.players.admins();
if (admins.length > 0) leet.ui.notify(`Admins online: ${admins.length}`, 'info');

The array is already sorted:

  1. hidden admins first;
  2. then visible admins, nearest first;
  3. then the rest (not visible), by remoteId.
PropertyTypeMeaning
remoteIdnumberThe admin's remote id.
namestringThe admin's name. If it cannot be read at the moment, the last name the admin was seen with is used, and failing that the player's nickname, so it is practically never empty.
distancenumber | nullMeters to the local player; 0 for hidden admins; null when not visible. See Distance and hidden admins.
dimensionnumberThe admin's dimension.
hiddenbooleantrue for an admin who is close but invisible.

leet.players.friends

TypeScript
leet.players.friends(): Array<{ remoteId: number, name: string, distance: number | null }>

Returns the user's friends who are currently on the server. The array is empty if no friends are online. Never throws.

JavaScript
const friends = leet.players.friends(); // already nearest first

mp.console.logInfo(`[friends] ${friends.length} online`);
for (const f of friends) {
    const where = f.distance === null ? 'far away' : `${f.distance.toFixed(0)} m`;
    mp.console.logInfo(`[friends]   #${f.remoteId} ${f.name} - ${where}`);
}

The array is already sorted: visible friends nearest first, then the rest (not visible) by remoteId.

PropertyTypeMeaning
remoteIdnumberThe friend's remote id.
namestringThe friend's name.
distancenumber | nullMeters to the local player; null when not visible.

leet.players.get

TypeScript
leet.players.get(player: PlayerMp | number): PlayerInfo | null

Returns information about one player: a PlayerInfo object, or null when there is no such player on the server. Works for any player on the server, including players who are not near you, and for your own player (for example leet.players.get(mp.players.local)).

JavaScript
const info = leet.players.get(42);

if (info === null) {
    mp.console.logInfo('#42 is not on the server');
} else {
    mp.console.logInfo(`#${info.remoteId} ${info.name} (${info.nickname ?? '?'}): ${info.faction ?? 'no faction'}`);
}

Parameters

PropertyTypeMeaning
remoteIdnumberThe player's remote id.
namestringThe player's roleplay name; until it is known, their RAGE MP nickname. Can be an empty string for a moment, when neither is known yet.
nicknamestring | nullThe player's RAGE MP nickname; null when the server does not send it. On GTA5RP only your own nickname is known; everyone else has null.
factionstring | nullThe player's faction, exactly as the server provides it (on GTA5RP it starts with F_, for example F_RUSSIANMAFIA, F_GANG_GROVE, F_LSCITYHALL; on Nova RP it is the faction number as text, for example "7"); null when the player has no faction or the server has no factions.
adminbooleantrue if the player is a server admin. Same as isAdmin.
friendbooleantrue if the player is on the user's friends list. Same as isFriend.
streamedbooleantrue when the player is loaded near you.
distancenumber | nullMeters to the local player when streamed; otherwise null (also, briefly, while your own character is not loaded). Your own entry has 0.
dimensionnumberThe player's dimension.

Keep in mind

  • name and faction are available for every player on the server, near you or not.

Factions on GTA5RP

Compare faction with these strings exactly. Not every faction exists on every GTA5RP server, and a server may add factions that are not listed here.

factionFaction
F_LSPDLos Santos Police Department (LSPD)
F_LSSDLos Santos Sheriff's Department (LSSD)
F_FIBFIB
F_LSARMYArmy
F_EMSEmergency medical services (EMS)
F_LSCITYHALLGovernment (City Hall)
F_NEWSNews
F_PRISONPrison
F_GANG_GROVEGrove Street gang
F_GANG_BALLASBallas gang
F_GANG_VAGOSVagos gang
F_GANG_BLOODSBloods gang
F_GANG_MARABUNTAMarabunta Grande gang
F_RUSSIANMAFIARussian mafia
F_ITALYMAFIAItalian mafia
F_MEXICOMAFIAMexican mafia
F_ARMENIAMAFIAArmenian mafia
F_YAKUZAYakuza

Factions on Nova RP

On Nova RP faction is the server's faction number as text. Numbers as of November 2026:

1 EMS2 National Guard3 LSPD4 SAHP5 Prison
7 Ballas8 Families9 Vagos10 Bloods11 Marabunta
12 FIB13 LifeInvader14 Government15 Russian mafia16 La Cosa Nostra
17 Yakuza18 Mexican mafia

Errors: leet: invalid player (player is neither an object with a numeric remoteId nor an integer from 0 to 65535).

leet.players.all

TypeScript
leet.players.all(): Array<PlayerInfo>

Returns every other player on the server as PlayerInfo objects, the same as get returns. The local player is not included. The array is empty if you are alone on the server. Never throws.

JavaScript
const FACTION = 'F_GANG_GROVE';
const members = leet.players.all().filter((p) => p.faction === FACTION);

mp.console.logInfo(`[${FACTION}] ${members.length} online`);
for (const p of members) {
    const where = p.distance === null ? 'far away' : `${p.distance.toFixed(0)} m`;
    mp.console.logInfo(`[${FACTION}]   #${p.remoteId} ${p.name} - ${where}`);
}

Keep in mind

  • The array is already sorted: players loaded near you nearest first, then the rest by remoteId.

Careful. It builds an object for every player, and big servers can have over a thousand of them. Do not call it on every onDraw: call it occasionally (for example once a second with setInterval) and reuse the result.

Recipes

Who is around me

JavaScript
const me = mp.players.local;

mp.players.forEachInStreamRange((p) => {
    if (p === me) return;
    const dx = p.position.x - me.position.x;
    const dy = p.position.y - me.position.y;
    const dz = p.position.z - me.position.z;
    const dist = Math.sqrt(dx * dx + dy * dy + dz * dz);

    const tags = [];
    if (leet.players.isAdmin(p)) tags.push('ADMIN');
    if (leet.players.isFriend(p)) tags.push('friend');

    mp.console.logInfo(`#${p.remoteId} ${p.name} ${dist.toFixed(0)} m ${tags.join(' ')}`);
});

isAdmin and isFriend take the mp player object directly, so you do not need to pull out the remote id.

Checking a remote id from a chat command

JavaScript
const onCommand = (cmd) => {
    const [name, arg] = cmd.split(' ');
    if (name !== 'isadmin') return;
    try {
        const id = Number(arg);
        leet.ui.notify(`#${id}: ${leet.players.isAdmin(id) ? 'admin' : 'not an admin'}`);
    } catch (e) {
        leet.ui.notify(`Usage: /isadmin <remoteId> (${e.message})`, 'error');
    }
};

mp.events.add('playerCommand', onCommand);

leet.events.onUnload(() => {
    mp.events.remove('playerCommand', onCommand);
});

A bad id (not an integer, or outside 0–65535) throws leet: invalid player, which is why the call sits in try. The command handler is removed in onUnload.

Warn about strangers, ignore friends

Every 2 seconds, warns once about each non-friend player who comes within 15 m.

JavaScript
const RADIUS = 15;
const warned = new Set();

const timer = setInterval(() => {
    const me = mp.players.local;
    const close = new Set();

    mp.players.forEachInStreamRange((p) => {
        if (p === me || leet.players.isFriend(p)) return;
        const dx = p.position.x - me.position.x;
        const dy = p.position.y - me.position.y;
        const dz = p.position.z - me.position.z;
        if (dx * dx + dy * dy + dz * dz > RADIUS * RADIUS) return;

        close.add(p.remoteId);
        if (!warned.has(p.remoteId)) {
            leet.ui.notify(`Stranger nearby: ${p.name}`, 'warning');
        }
    });

    warned.clear();
    close.forEach((id) => warned.add(id));
}, 2000);

leet.events.onUnload(() => clearInterval(timer));

The warned set holds only the players who are close right now. Someone who walks away and comes back gets a new warning.

List admins online

The list is already in the right order: hidden, then nearest, then far away. Admins in another dimension than yours are marked.

JavaScript
const admins = leet.players.admins();
const myDim = mp.players.local.dimension;

if (admins.length === 0) {
    mp.console.logInfo('[admins] none online');
} else {
    for (const a of admins) {
        const where = a.hidden ? 'HIDDEN, right next to you'
            : a.distance === null ? 'far away'
            : `${a.distance.toFixed(0)} m`;
        const dim = a.dimension !== myDim ? ` [dimension ${a.dimension}]` : '';
        mp.console.logInfo(`[admins] #${a.remoteId} ${a.name}: ${where}${dim}`);
    }
    leet.ui.notify(`Admins online: ${admins.length}`, 'info');
}

hidden is checked first because a hidden admin has distance 0 and would otherwise look like they are standing on top of you.

The 5 nearest players on screen

The list is refreshed once a second with a timer; the handler only draws what was last read. Both are removed in onUnload.

JavaScript
let nearest = [];
const refresh = setInterval(() => {
    nearest = leet.players.all().filter((p) => p.streamed).slice(0, 5); // already nearest first
}, 1000);

const offDraw = leet.events.onDraw(() => {
    if (nearest.length === 0) return;
    const x = 20;
    let y = 300;
    leet.ui.fillRect(x - 8, y - 6, 300, 26 + nearest.length * 20, 0xA0000000);
    leet.ui.drawText('Nearest players', x, y, 0xFFFFC107, 18);
    for (const p of nearest) {
        y += 20;
        leet.ui.drawText(`${p.name}  ${p.distance.toFixed(0)} m`, x, y, 0xFFFFFFFF, 16);
    }
});

leet.events.onUnload(() => {
    clearInterval(refresh);
    offDraw();
});

all() is expensive, so it runs in the timer, not in onDraw. The streamed filter keeps only players near you.


Next: Logger