GetPlayerName

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 16:29, 4 August 2026 by QCherry (talk | contribs) (Document authoritative player name functions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

getPlayerName

Returns the authoritative multiplayer name of a connected player.

Syntax

string getPlayerName(int playerId)

Parameters

Name Type Required Description
playerId int yes The connected player identifier.

Returns

Returns the player's current name as a string, or false when the player is not connected.

Examples

Greet a player when they join:

addEventHandler("onPlayerJoin", function(playerId)
    local name = getPlayerName(playerId)
    if name then
        outputChatBox("Welcome, " .. name .. "!")
    end
end)

Notes

  • Available only in server-side resource scripts.
  • Player names are authoritative on the server and are replicated to connected clients.