0 Members and 1 Guest are viewing this topic.
function RandomPlayer(): byte;begin if (NumPlayers = 0) then exit; repeat Result := Random(1, 33); until (GetPlayerStat(Result, 'Active') = true);end;
function getRandomPlayerID(): byte;var players: array[1..32] of byte; playersNumber: byte; i: byte;begin // if there isn't a player in-game, then bail out if NumPlayers = 0 then begin Result := 0; exit; end; // get rrrreeaadyyy to rrrrumbleee playersNumber := 0; // loop through all player ID 'slots' for i := 1 to 32 do begin // if there's no player with this ID in-game, // then simply skip to the next ID in the loop if not getPlayerStat(i, 'active') then continue; // increment the numbers of players we've found... playersNumber := playersNumber + 1; // ...and tuck the latest player ID onto that array players[playersNumber] := i; end; // now just return a random ID from the aforementioned array // and you ought to be all peachy-keen! Result := players[Random(1, playersNumber + 1)];end;