07.11.2010, 05:57
How do I make choose a random player and move it to another team ? or a team balance kinda thing ?
new randomp;
randomp = random(MAX_PLAYERS);
gTeam[randomp] = TEAM; //Change this to your variables
SpawnPlayer(randomp);
new randomp; randomp = random(GetMaxPlayers()); gTeam[randomp] = TEAM; //Change this to your variables SpawnPlayer(randomp);
new RandomP;
RandomP = random(GetMaxPlayers());
if(!IsPlayerConnected(RandomP)) return false;
gTeam[RandomP] = team; //Change to your variables
SpawnPlayer(RandomP);
new randomplayer = Iter_Random(Player);
public GetRandomPlayer(){ //returns random playerid or -1 if no players
new test,test2,players[MAX_PLAYERS];
for(new i=0;i<MAX_PLAYERS;i++){
if(IsPlayerConnected(i)){
players[test] = i;
test++;
}
}
if(test == 0)return -1;
else test2 = random(test);
return players[test2];
}