Results 1 to 6 of 6

Thread: Getting a random player from team?

  1. #1
    Corporal voron00's Avatar
    Join Date
    Nov 2014
    Posts
    248
    Thanks
    64
    Thanked 216 Times in 116 Posts

    Getting a random player from team?

    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?

  2. #2
    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?

  3. #3
    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 18:04.

  4. #4
    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]

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

    voron00 (23rd June 2015)

  6. #5
    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

  7. #6
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    if you would have been running your mod in DEVELOPER mode it would have CRASHED and given you a clue where to look for fixes.

    Please ALWAYS use DEVELOPER mode to debug shit.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

Posting Permissions

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