Answered Random player picker?

Craze

Alt + F4
Messages
237
Points
478
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
4,367
Points
553
That simpel:
Code:
getRandomPlayer()
{
    return getplayers()[randomintrange(0,getplayers().size)]; // getplayers or level.players.
}
 

Craze

Alt + F4
Messages
237
Points
478
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
4,367
Points
553
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
237
Points
478
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
4,367
Points
553
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;
 

Similar threads


Top