Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock RandomPlayer(playerid) // Will return a random player ID
- {
- new player[MAX_PLAYERS]; // The ID assigned to each slot
- new plyrs; // Possible random players
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- player[plyrs] = i;
- plyrs++;
- }
- }
- if(!plyrs) return INVALID_PLAYER_ID // No players
- new rand = random(plyrs);
- while(rand == GetPVarInt(playerid, "Spectating")) rand = random(plyrs);
- return player[rand];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement