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
mpplayer object, meaning anything with a numericremoteId, for examplemp.players.local, or an entry frommp.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()andonAdminNearbyevents, hidden admins always havedistance0. get()andall()do not report hidden admins: there such an admin hasdistancenullandstreamedfalse, like any player who is not visible.
leet.players.isAdmin
leet.players.isAdmin(player: PlayerMp | number): booleanReturns 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.
if (leet.players.isAdmin(42)) leet.ui.notify('#42 is an admin', 'warning');Parameters
player(player object | number): see Player arguments.
Errors: leet: invalid player (player is neither an object with a numeric remoteId nor an integer from 0 to 65535).
leet.players.isFriend
leet.players.isFriend(player: PlayerMp | number): booleanReturns true if the player is on the user's friends list, false otherwise, including for an unknown or absent player.
mp.players.forEachInStreamRange((p) => {
if (leet.players.isFriend(p)) mp.console.logInfo(`Friend nearby: ${p.name}`);
});Parameters
player(player object | number): see Player arguments.
Errors: leet: invalid player (player is neither an object with a numeric remoteId nor an integer from 0 to 65535).
leet.players.admins
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.
const admins = leet.players.admins();
if (admins.length > 0) leet.ui.notify(`Admins online: ${admins.length}`, 'info');The array is already sorted:
- hidden admins first;
- then visible admins, nearest first;
- then the rest (not visible), by
remoteId.
| Property | Type | Meaning |
|---|---|---|
remoteId | number | The admin's remote id. |
name | string | The 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. |
distance | number | null | Meters to the local player; 0 for hidden admins; null when not visible. See Distance and hidden admins. |
dimension | number | The admin's dimension. |
hidden | boolean | true for an admin who is close but invisible. |
leet.players.friends
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.
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.
| Property | Type | Meaning |
|---|---|---|
remoteId | number | The friend's remote id. |
name | string | The friend's name. |
distance | number | null | Meters to the local player; null when not visible. |
leet.players.get
leet.players.get(player: PlayerMp | number): PlayerInfo | nullReturns 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)).
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
player(player object | number): see Player arguments.
| Property | Type | Meaning |
|---|---|---|
remoteId | number | The player's remote id. |
name | string | The 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. |
nickname | string | null | The 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. |
faction | string | null | The 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. |
admin | boolean | true if the player is a server admin. Same as isAdmin. |
friend | boolean | true if the player is on the user's friends list. Same as isFriend. |
streamed | boolean | true when the player is loaded near you. |
distance | number | null | Meters to the local player when streamed; otherwise null (also, briefly, while your own character is not loaded). Your own entry has 0. |
dimension | number | The player's dimension. |
Keep in mind
nameandfactionare 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.
faction | Faction |
|---|---|
F_LSPD | Los Santos Police Department (LSPD) |
F_LSSD | Los Santos Sheriff's Department (LSSD) |
F_FIB | FIB |
F_LSARMY | Army |
F_EMS | Emergency medical services (EMS) |
F_LSCITYHALL | Government (City Hall) |
F_NEWS | News |
F_PRISON | Prison |
F_GANG_GROVE | Grove Street gang |
F_GANG_BALLAS | Ballas gang |
F_GANG_VAGOS | Vagos gang |
F_GANG_BLOODS | Bloods gang |
F_GANG_MARABUNTA | Marabunta Grande gang |
F_RUSSIANMAFIA | Russian mafia |
F_ITALYMAFIA | Italian mafia |
F_MEXICOMAFIA | Mexican mafia |
F_ARMENIAMAFIA | Armenian mafia |
F_YAKUZA | Yakuza |
Factions on Nova RP
On Nova RP faction is the server's faction number as text. Numbers as of November 2026:
1 EMS | 2 National Guard | 3 LSPD | 4 SAHP | 5 Prison |
7 Ballas | 8 Families | 9 Vagos | 10 Bloods | 11 Marabunta |
12 FIB | 13 LifeInvader | 14 Government | 15 Russian mafia | 16 La Cosa Nostra |
17 Yakuza | 18 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
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.
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 withsetInterval) and reuse the result.
Recipes
Who is around me
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
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.
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.
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.
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.