Difference between revisions of "GetPlayerIdFromPlayerIndex"
From Nomad DB
Wasdennnoch (talk | contribs) (Created page with "Returns the Player ID based on the given Player Index. == Syntax == <pre> GetPlayerIdFromPlayerIndex(playerIndex) </pre> == Example == The example below checks wheth...") |
m |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | Retrieves the [[EntityId|player ID]] from the specified [[Player Index|player index]]. | |
== Syntax == | == Syntax == | ||
− | < | + | <syntaxhighlight lang="lua"> |
GetPlayerIdFromPlayerIndex(playerIndex) | GetPlayerIdFromPlayerIndex(playerIndex) | ||
− | </ | + | </syntaxhighlight> |
+ | * '''playerIndex''' (number): Target [[Player Index|player index]] | ||
+ | * '''Returns''' (number): [[PlayerId|ID]] of the specified player | ||
== Example == | == Example == | ||
− | + | Checks whether the [[EntityId|entity ID]] of the local player is valid or not. | |
− | < | + | <syntaxhighlight lang="lua"> |
local playerCount = GetNumberOfPlayers() | local playerCount = GetNumberOfPlayers() | ||
for i = 0, playerCount - 1 do | for i = 0, playerCount - 1 do | ||
Line 17: | Line 19: | ||
end | end | ||
end | end | ||
− | </ | + | </syntaxhighlight> |
== Related Pages == | == Related Pages == |
Latest revision as of 19:56, 16 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
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