UserFunction; Universe_RandomPlayerList - HWRM/KarosGraveyard Wiki

Universe_RandomPlayerList()

Description

Returns a randomized list of player indices as the contents of a table.

Example

local playerList = Universe_RandomPlayerList()
for i, playerIndex in playerList do
...code...
end

Arguments

None.

Definition

function Universe_RandomPlayerList()
    local PlayerCount = Universe_PlayerCount()
    local PlayerTable = {}
    local PlayerIndex = 1
    while (getn(PlayerTable) < PlayerCount) do
        local PlayerRandom = random(0, PlayerCount - 1)
        local PlayerAlready = 0
        for i, k in PlayerTable do
            if (k == PlayerRandom) then
                PlayerAlready = 1
                break
            end
        end
        if (PlayerAlready == 0) then
            PlayerTable[PlayerIndex] = PlayerRandom
            PlayerIndex = PlayerIndex + 1
        end
    end
    return PlayerTable
end

Related Pages

User-Function Reference

Comments

Page Status

Updated Formatting? Initial
Updated for HWRM? Initial