random picking people???

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Post Reply
User avatar
IrishStorm
CJ Newbie
CJ Newbie
Posts: 96
Joined: January 8th, 2009, 3:48 am
Location: Ireland
Contact:

random picking people???

Post by IrishStorm » May 20th, 2009, 5:39 am

hey there,
how would i go about getting my mod to pick random people from axis?

or setting it so that only one player can join allies?
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||

User avatar
IrishStorm
CJ Newbie
CJ Newbie
Posts: 96
Joined: January 8th, 2009, 3:48 am
Location: Ireland
Contact:

Re: random picking people???

Post by IrishStorm » May 20th, 2009, 2:48 pm

anyone?
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: random picking people???

Post by waywaaaard » May 20th, 2009, 3:11 pm

first problem:

you have the players array and the you can check if the player is allies or axis, so place all axis in one array and then go over random 0 - array.length to get a player of the axis

2nd:
I am not sure 'cause I don't know if you can restrict that, but you can force all people if already one is axis to autoset to allies
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
IrishStorm
CJ Newbie
CJ Newbie
Posts: 96
Joined: January 8th, 2009, 3:48 am
Location: Ireland
Contact:

Re: random picking people???

Post by IrishStorm » May 20th, 2009, 5:51 pm

Lev!athan wrote:first problem:


2nd:
I am not sure 'cause I don't know if you can restrict that, but you can force all people if already one is axis to autoset to allies
hmm ok how would i do that
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: random picking people???

Post by Drofder2004 » May 20th, 2009, 8:46 pm

spawnPlayer() thread.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
IrishStorm
CJ Newbie
CJ Newbie
Posts: 96
Joined: January 8th, 2009, 3:48 am
Location: Ireland
Contact:

Re: random picking people???

Post by IrishStorm » May 20th, 2009, 11:43 pm

ok this is what i have

Code: Select all

random_pick()
{
    while(1)
    {
       temp = [];
       players = getentarray("player","classname");
       for(i=0;i<players.size;i++)
    {
       if(players[i].sessionstate != "spectator" && !players[i].ispicked)temp[temp.size] = players[i];
    }
       if(!temp.size)return;picked = temp[randomInt(temp.size)];
       if(temp.size == 1)
       break;
       wait 1;
       if(numofplayers("allies") > 0)
       return;
       continue;
    }
        break;
    }
        picked endon("disconnect");
        picked.isfirstpicked = true;
        picked.ispicked = true;
        picked.switching_teams = true;
        picked.madepicked = true;
        iprintln(picked.name + " ^2is the ^1Hunter");
        }
	}
}
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: random picking people???

Post by Drofder2004 » May 20th, 2009, 11:45 pm

Its seem a little over complicate for simply picking a player on a team...

Which game are you working on?
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
IrishStorm
CJ Newbie
CJ Newbie
Posts: 96
Joined: January 8th, 2009, 3:48 am
Location: Ireland
Contact:

Re: random picking people???

Post by IrishStorm » May 20th, 2009, 11:47 pm

cod5
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: random picking people???

Post by waywaaaard » May 21st, 2009, 9:21 am

you can also

do

getplayersarray

random
if == allies
break

while(getplayersarray > 0)

kind of pseudocode
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
IrishStorm
CJ Newbie
CJ Newbie
Posts: 96
Joined: January 8th, 2009, 3:48 am
Location: Ireland
Contact:

Re: random picking people???

Post by IrishStorm » May 22nd, 2009, 12:14 pm

Lev!athan wrote:you can also

do

getplayersarray

random
if == allies
break

while(getplayersarray > 0)

kind of pseudocode
would that be for setting the limit of player per team or random picking?
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||

User avatar
IrishStorm
CJ Newbie
CJ Newbie
Posts: 96
Joined: January 8th, 2009, 3:48 am
Location: Ireland
Contact:

Re: random picking people???

Post by IrishStorm » May 26th, 2009, 1:08 am

got it working
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: random picking people???

Post by Drofder2004 » May 26th, 2009, 10:18 pm

Grats! :)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests