GetPlayerName: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Document authoritative player name functions
 
Complete Lua function catalog
 
Line 33: Line 33:
* Player names are authoritative on the server and are replicated to connected clients.
* Player names are authoritative on the server and are replicated to connected clients.


[[Category:Lua Functions]]
[[Category:Server Functions]]
[[Category:Server Functions]]
[[Category:Player Functions]]
[[Category:Player Functions]]

Latest revision as of 09:53, 15 August 2026

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.