-
Notifications
You must be signed in to change notification settings - Fork 3
UserFunction; Universe_RandomPlayerList
Cloaked edited this page Jun 10, 2020
·
1 revision
Universe_RandomPlayerList()
Returns a randomized list of player indices as the contents of a table.
local playerList = Universe_RandomPlayerList()
for i, playerIndex in playerList do
...code...
end
None.
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
Updated Formatting? Initial
Updated for HWRM? Initial
| Home | Search | Recent Changes | Revision History | About | User Help | Contributor Help | Discussion |