ItsMods

Full Version: little stuck
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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();
            }
        }
Code:
players = GetEntArray( "player", "classname" );
num = RandomInt( players.size );
        for( x = 0; x < players.size; x++ )
        {  
            if( x == num )
            {
                players[x] makeInfected();
            }
        }