Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock GetRandomPlayerId() //returns -1 when there are no players connected
- {
- new anybodyhere = 0;
- new counter = 0;
- new ids[MAX_PLAYERS];
- for(new i = 0;i<MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- ids[counter] = i;
- anybodyhere = 1;
- i++;
- }
- }
- new rnd = random(sizeof(ids));
- if(anybodyhere == 0)
- {
- return -1;
- } else {
- return ids[rnd];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment