Difference between revisions of "GetPlayerIdFromPlayerIndex"

From Nomad DB
m
Line 5: Line 5:
 
GetPlayerIdFromPlayerIndex(playerIndex)
 
GetPlayerIdFromPlayerIndex(playerIndex)
 
</syntaxhighlight>
 
</syntaxhighlight>
* '''playerIndex''' (number): [[Player Index|index]] of the target player
+
* '''playerIndex''' (number): Target [[Player Index|player index]]
 
* '''Returns''' (number): [[PlayerId|ID]] of the specified player
 
* '''Returns''' (number): [[PlayerId|ID]] of the specified player
  

Revision as of 17:01, 15 April 2020

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

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