Answered Random player picker?

Discussion in 'Call of Duty: Black Ops 2 Answered Questions' started by Craze, Jun 5, 2016.

  1. Craze

    Craze Alt + F4

    224
    156
    318
    Credits:
    760
    I'm making a custom gamemode, but at the start of the game someone random has to be chosen. Has anyone got a script? You will get credit. :grinning:
     
  2. CabCon

    CabCon Head Administrator Staff Member Head Staff Team

    3,960
    2,578
    403
    Credits:
    156,557
    That simpel:
    Code:
    getRandomPlayer()
    {
        return getplayers()[randomintrange(0,getplayers().size)]; // getplayers or level.players.
    }
     
  3. Craze

    Craze Alt + F4

    224
    156
    318
    Credits:
    760
    Can you set it as a variable, like this.
    Code:
    plr = return getplayers()[randomintrange(0,getplayers().size)]; 
     
  4. CabCon

    CabCon Head Administrator Staff Member Head Staff Team

    3,960
    2,578
    403
    Credits:
    156,557
    Is this a question?
    And yeah sure, but it need to look than like this:
    Code:
    plr = getplayers()[randomintrange(0,getplayers().size)];
    
     
  5. Craze

    Craze Alt + F4

    224
    156
    318
    Credits:
    760
    Here's my code.
    Code:
     
    gmi()
    {
    setDvar("party_autoteams", 0);
    setDvar("ui_allow_teamchange", "0");
    chosen = getplayers()[randomintrange(0,getplayers().size)];
    chosen iPrintln("^1You're on!");
    chosen freezeControls(true);
    
    } 
    How do I do something like this?
    Code:
    chosen self.chosen = true; 
     
  6. CabCon

    CabCon Head Administrator Staff Member Head Staff Team

    3,960
    2,578
    403
    Credits:
    156,557
    This looks correct.

    you can do it like this:
    Code:
    level.chosen_player = chosen;
    level.chosen_player_name = chosen.name;
     

Share This Page