Sign in to follow this  
Followers 0
Pixel

Random Selected Player

9 posts in this topic

You know in Deathrun, where it can identify how many players are in the game then select one of these people randomly to become the activator? Well I want to know how to do that. I'm guessing it's used by arrays, and I want to get better at them :)

 

I am not asking for scripts used in the Deathrun mod, just a script which randomly selects someone.

 

Thanks.

0

Share this post


Link to post
Share on other sites
players = getAllPlayers(); // Gathering all players on the server
if( !isDefined( players ) || isDefined( players ) && !players.size ) // Making sure players are defined aka actual players
return;
 
num = randomInt( players.size ); // picking a random player
guy = players[num]; // randomplayer is now defined as "guy"

function to get all players

getAllPlayers()
{
return getEntArray( "player", "classname" );
}

something like this?

 

From deathrun

0

Share this post


Link to post
Share on other sites
players = getAllPlayers(); // Gathering all players on the server
if( !isDefined( players ) || isDefined( players ) && !players.size ) // Making sure players are defined aka actual players
return;
 
num = randomInt( players.size ); // picking a random player
guy = players[num]; // randomplayer is now defined as "guy"

function to get all players

getAllPlayers()
{
return getEntArray( "player", "classname" );
}

something like this?

 

From deathrun

 

I will try and work with this.

 

So, could I add something like:

 

iPrintLn("" + guy.name + "got randomly selected")
0

Share this post


Link to post
Share on other sites

ye but you can do guy.name + " text" instead of "" + guy.name + " text"

0

Share this post


Link to post
Share on other sites

ye but you can do guy.name + " text" instead of "" + guy.name + " text"

Oh I see, okay, thank you. Is this only eligible for Deathrun mod? (Player gathering script you posted)

0

Share this post


Link to post
Share on other sites

no, but you'll need that function in your scripts for it to work.

0

Share this post


Link to post
Share on other sites

no, but you'll need that function in your scripts for it to work.

To clear that up, if you're using the deathrun mod you don't need to include this part anywhere - 

getAllPlayers()
{
return getEntArray( "player", "classname" );
}

But if you're not then as long as you have those 4 lines in your script somewhere it'll work.

 

 

Feel like people may get confused so I thought I'd clear it up a bit :dave:

 

EDIT: If you're using it for deathrun then you need this line at the very top or it won't work - 

#include braxi\_common;
0

Share this post


Link to post
Share on other sites

 

To clear that up, if you're using the deathrun mod you don't need to include this part anywhere - 

getAllPlayers()
{
return getEntArray( "player", "classname" );
}

But if you're not then as long as you have those 4 lines in your script somewhere it'll work.

 

 

Feel like people may get confused so I thought I'd clear it up a bit :dave:

 

EDIT: If you're using it for deathrun then you need this line at the very top or it won't work - 

#include braxi\_common;

It's for a RotU map I am experimenting on :P Thanks 

0

Share this post


Link to post
Share on other sites

Rotu might have the function, decompile the FF and check.

0

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0