Difference between revisions of "GetPlayerIdFromPlayerIndex"

From Nomad DB
Line 1: Line 1:
Retrieves the [[PlayerId|Player ID]] of the player with the specified [[Player Index|index]].
+
Retrieves the [[PlayerId|ID]] of the player with the specified [[Player Index|index]].
  
 
== Syntax ==
 
== Syntax ==
Line 5: Line 5:
 
GetPlayerIdFromPlayerIndex(playerIndex)
 
GetPlayerIdFromPlayerIndex(playerIndex)
 
</syntaxhighlight>
 
</syntaxhighlight>
* '''playerIndex''' (number): Player index of the target player
+
* '''playerIndex''' (number): [[Player Index|index]] of the target player
* '''Returns''' (number): [[Player ID]]
+
* '''Returns''' (number): [[PlayerId|ID]] of the specified player
  
 
== Example ==
 
== Example ==

Revision as of 19:19, 14 April 2020

Retrieves the ID of the player with the specified 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