How to Get a random player number

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
ibm5155
Addicted to Zandronum
Posts: 1641
Joined: Tue Jun 05, 2012 9:32 pm
Location: Somewhere, over the rainbow

How to Get a random player number

#1

Post by ibm5155 » Sun Mar 10, 2013 6:13 pm

Hi, so I need something to get a random player in game to print on the screen, and i don´t know how to do it :s

ex:

players playing:player1 ,player2, player3

then the mensage "player2 will receive the super shotgun, run!!!"

I think PlayerInGame could help with that but it´s limited to 8 players? O_o
Projects
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!

<this post is proof of "Decline">

User avatar
Dusk
Developer
Posts: 581
Joined: Thu May 24, 2012 9:59 pm
Location: Turku

RE: How to Get a random player number

#2

Post by Dusk » Sun Mar 10, 2013 7:00 pm

Code: Select all

int player;

do {
	player = random (0, 63);
} while (!PlayerInGame (player));
Make sure PlayerCount is not 0 before you do that, though or you'll end up in an infinite loop.
Last edited by Dusk on Sun Mar 10, 2013 7:00 pm, edited 1 time in total.

User avatar
ibm5155
Addicted to Zandronum
Posts: 1641
Joined: Tue Jun 05, 2012 9:32 pm
Location: Somewhere, over the rainbow

RE: How to Get a random player number

#3

Post by ibm5155 » Sun Mar 10, 2013 8:18 pm

Wow it really worked thanks Dusk, now I get it how to right use playeringame :D
Projects
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!

<this post is proof of "Decline">

Post Reply