Difference between revisions of "GetPlayerIdFromPlayerIndex"

From Nomad DB
Line 1: Line 1:
Retrieves the [[EntityId|player ID]] from the specified [[Player Index|index]].
+
Retrieves the [[EntityId|player ID]] from the specified [[Player Index|player index]].
  
 
== Syntax ==
 
== Syntax ==

Revision as of 17:00, 15 April 2020

Retrieves the player ID from the specified player index.

Syntax

GetPlayerIdFromPlayerIndex(playerIndex)
  • playerIndex (number): index of the target player
  • Returns (number): ID of the specified player

Example

The example below checks whether the entity ID of the local player is valid or not.

local playerCount = GetNumberOfPlayers()
for i = 0, playerCount - 1 do
    local playerId = GetPlayerIdFromPlayerIndex(i)
    local playerNameDebug = GetPlayerNameDebug(playerId)
    if playerNameDebug == "2XTheTap" then
        -- do stuff
    end
end

Related Pages