Answered Random player picker?

Craze

Alt + F4
Messages
229
Reaction score
163
Points
903
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:
 

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
5,093
Reaction score
2,881
Points
1,103
That simpel:
Code:
getRandomPlayer()
{
    return getplayers()[randomintrange(0,getplayers().size)]; // getplayers or level.players.
}
 

Craze

Alt + F4
Messages
229
Reaction score
163
Points
903
That simpel:
Code:
getRandomPlayer()
{
    return getplayers()[randomintrange(0,getplayers().size)]; // getplayers or level.players.
}
Can you set it as a variable, like this.
Code:
plr = return getplayers()[randomintrange(0,getplayers().size)];
 

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
5,093
Reaction score
2,881
Points
1,103
Can you set it as a variable, like this.
Code:
plr = return getplayers()[randomintrange(0,getplayers().size)];
Is this a question?
And yeah sure, but it need to look than like this:
Code:
plr = getplayers()[randomintrange(0,getplayers().size)];
 

Craze

Alt + F4
Messages
229
Reaction score
163
Points
903
Is this a question?
And yeah sure, but it need to look than like this:
Code:
plr = getplayers()[randomintrange(0,getplayers().size)];
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;
 

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
5,093
Reaction score
2,881
Points
1,103
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);

}
This looks correct.

How do I do something like this?
Code:
chosen self.chosen = true;
you can do it like this:
Code:
level.chosen_player = chosen;
level.chosen_player_name = chosen.name;
 
Top