Get ID with GetPlayers

Hi,

I want to get the id for a player with this function:

function GetPlayers()
    local players = {}

    for i = 0, 31 do
        if NetworkIsPlayerActive(i) then
            table.insert(players, i)
        end
    end

    return players
end

Thanks

Where is it changement ?

The ID of the player is going to be ā€˜iā€™ in that function.

But ā€œiā€ return 0 for my and 1 for my friend but the real ID this 9 and 11

use getplayerserverid after this

thanks so much you :slight_smile:

welcome :smiley: bro

The client and server have different ID sets. On the server, a connecting player will always choose the lowest ID available.

On the client, the IDs will always increment, event if a lower slot is available.

For example, say we have three players:
Player 1 joins (Client id 0 - Server id 0)
Player 2 joins (Client id 1 - Server id 1)
Player 1 quits (so id 0 is free on server and client)
Player 3 joins (Client id 2 - Server id 0)

I hope that makes some sense. Point being, they use separate numbering systems. Use the function @Synchro mentioned.

Ok thanks for this man :smiley: