Auto-translated
And what about GetPlayerState?function GetPlayers()
local n = 0
for i=1,8 do
n = n + (GetPlayerState(i) == 1 or 0)
end
return n
end
But instead of the "magic" numbers 1 and 0, I used the constant PLAYER_ACTIVE (which, apparently, corresponds to 1).
-- Getting the number of players in the game
function getTotalPlayers()
local total = 0
for playerID = PLAYER_1, PLAYER_8 do
if GetPlayerState(playerID) == PLAYER_ACTIVE then
total = total + 1
end
end
return total
endAnd why use the value PLAYER_NOT_IN_GAME (0)?