Difference between revisions of "GetPlayerIdFromPlayerIndex"

From Nomad DB
Line 6: Line 6:
 
</pre>
 
</pre>
 
* '''playerIndex''' (number) Player index
 
* '''playerIndex''' (number) Player index
* '''Returns: [[PlayerID]]'''
+
* '''Returns: [[Player ID]]'''
  
 
== Example ==
 
== Example ==

Revision as of 18:48, 14 April 2020

Returns the Player ID based on the given Player Index.

Syntax

GetPlayerIdFromPlayerIndex(playerIndex)
  • playerIndex (number) Player index
  • Returns: Player ID

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