Results 1 to 6 of 6

Thread: Getting a random player from team?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by voron00 View Post
    Hello, i need to get random player from team (axis or allies), what i tried - didn't work, but im not much of a dev. Anyone can help, please?
    Can you post the code that you used? And for which cod version is it?

  2. #2
    Corporal voron00's Avatar
    Join Date
    Nov 2014
    Posts
    248
    Thanks
    64
    Thanked 216 Times in 116 Posts
    Quote Originally Posted by Mitch View Post
    Can you post the code that you used? And for which cod version is it?
    cod2, well i tried many things but something like that, but that not work:


    PHP Code:
    level.alliesteam = [];
    players getentarray("player""classname");
        for(
    0players.sizei++)
        {
            if((
    isdefined(players.pers["team"])) && (players.pers["team"] == "allies") && (players.sessionstate == "playing"))
                
    level.alliesteam[level.level.alliesteam.size] = players;
        }
          
    random level.alliesteam[randomint(level.alliesteam.size)]; 
    Last edited by voron00; 23rd June 2015 at 17:04.

  3. #3
    Private First Class php's Avatar
    Join Date
    Nov 2012
    Posts
    142
    Thanks
    28
    Thanked 116 Times in 59 Posts
    try

    PHP Code:
    level.alliesteam = [];
    players getentarray("player""classname");
    for(
    0players.sizei++)
    if(
    isdefined(players[i].pers["team"]) && players[i].pers["team"] == "allies" && players[i].sessionstate == "playing")
    level.alliesteam[level.alliesteam.size] = players[i];
    random level.alliesteam[randomint(level.alliesteam.size)]; 
    I edited the players to players[i]

  4. The Following User Says Thank You to php For This Useful Post:

    voron00 (23rd June 2015)

  5. #4
    Corporal voron00's Avatar
    Join Date
    Nov 2014
    Posts
    248
    Thanks
    64
    Thanked 216 Times in 116 Posts
    Quote Originally Posted by php View Post
    try

    PHP Code:
    level.alliesteam = [];
    players getentarray("player""classname");
    for(
    0players.sizei++)
    if(
    isdefined(players[i].pers["team"]) && players[i].pers["team"] == "allies" && players[i].sessionstate == "playing")
    level.alliesteam[level.alliesteam.size] = players[i];
    random level.alliesteam[randomint(level.alliesteam.size)]; 
    I edited the players to players[i]
    Works, thanks, at least i was close to the solution:P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •