ItsMods
Help little stuck - Printable Version

+- ItsMods (https://www.itsmods.com)
+-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html)
+--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html)
+--- Thread: Help little stuck (/Thread-Help-little-stuck.html)



little stuck - Shanknight - 06-29-2011

need help making it to choose 1 random player out of everyone to be on axis team which is infected in this case.
I know there is a example in the jug file but the code differs from mine

what I want to do is get the number of players in the server into an array and then pick a random number within that array setting that player to infected.

Code:
players = GetEntArray( "player", "classname" ); for( x = 0; x < players.size; x++ ) { player = players[ x ]; num = RandomInt( players.size ); if( player.pers[x] == num ) { makeInfected(); } }



RE: little stuck - Pozzuh - 06-29-2011

Code:
players = GetEntArray( "player", "classname" ); num = RandomInt( players.size ); for( x = 0; x < players.size; x++ ) { if( x == num ) { players[x] makeInfected(); } }