GetPlayerIdFromPlayerIndex

From Nomad DB

Retrieves the player ID from the specified player index.

Syntax

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

Example

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