modded reguser help
modded reguser help
ok so I have modded my reguser.php to fit faction wars' needs and I need a little bit of help on part of it. I am wondering how to piece out a couple lines of code that will put the player in a random faction, I plan on building on that piece of code later on to put players in a faction with the least amount of players to make it fair
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
Re: modded reguser help
Make an array of the different factions or pull it from your database or however you do it..
Then make php generate a random number between the length of the array and 0.
Then make php generate a random number between the length of the array and 0.
Code: Select all
$factions = array( 'gays', 'fags', 'homos', 'queers', 'emos' );
$number = rand(0, (count($factions)-1)); // -1 because the first key is of course 0 and not 1
echo "<select name=\"factions\">\n";
foreach( $factions as $key => $value )
{
echo "<option". ( $number == $key ? " selected=\"selected\"" : '' ) .">". $value ."</option>\n";
}
echo "</select>";
Fighting for peace is declaring war on war. If you want peace be peaceful.