Taylor_1978
01-27-2004, 04:03 AM
Hiya,
I have a bad habit of writing scripts that are way too big and doing things the hard way - last time I posted like this a 30 line script turned into a 4 line script! LOL
So here is my script:
// Set all 4 players as the 4th seed.
$seed1 = 4;
$seed2 = 4;
$seed3 = 4;
$seed4 = 4;
// Move each player up one seed when their rating is higher.
if ($p1rating > $p2rating) { $seed1 = $seed1 - 1; } else { $seed2 = $seed2 - 1; }
if ($p1rating > $p3rating) { $seed1 = $seed1 - 1; } else { $seed3 = $seed3 - 1; }
if ($p1rating > $p4rating) { $seed1 = $seed1 - 1; } else { $seed4 = $seed4 - 1; }
if ($p2rating > $p3rating) { $seed2 = $seed2 - 1; } else { $seed3 = $seed3 - 1; }
if ($p2rating > $p4rating) { $seed2 = $seed2 - 1; } else { $seed4 = $seed4 - 1; }
if ($p3rating > $p4rating) { $seed3 = $seed3 - 1; } else { $seed4 = $seed4 - 1; }
// Insert seed numbers.
mysql_db_query($tourneys, "UPDATE info SET s1='$seed1', s2='$seed2', s3='$seed3', s4='$seed4' WHERE tid='$tid'");
// Place players into appropriate positions according to seed.
if ($seed1 == 1) { mysql_db_query($tourneys, "UPDATE info SET pos1='$p1' WHERE tid='$tid'"); }
if ($seed1 == 2) { mysql_db_query($tourneys, "UPDATE info SET pos3='$p1' WHERE tid='$tid'"); }
if ($seed1 == 3) { mysql_db_query($tourneys, "UPDATE info SET pos4='$p1' WHERE tid='$tid'"); }
if ($seed1 == 4) { mysql_db_query($tourneys, "UPDATE info SET pos2='$p1' WHERE tid='$tid'"); }
if ($seed2 == 1) { mysql_db_query($tourneys, "UPDATE info SET pos1='$p2' WHERE tid='$tid'"); }
if ($seed2 == 2) { mysql_db_query($tourneys, "UPDATE info SET pos3='$p2' WHERE tid='$tid'"); }
if ($seed2 == 3) { mysql_db_query($tourneys, "UPDATE info SET pos4='$p2' WHERE tid='$tid'"); }
if ($seed2 == 4) { mysql_db_query($tourneys, "UPDATE info SET pos2='$p2' WHERE tid='$tid'"); }
if ($seed3 == 1) { mysql_db_query($tourneys, "UPDATE info SET pos1='$p3' WHERE tid='$tid'"); }
if ($seed3 == 2) { mysql_db_query($tourneys, "UPDATE info SET pos3='$p3' WHERE tid='$tid'"); }
if ($seed3 == 3) { mysql_db_query($tourneys, "UPDATE info SET pos4='$p3' WHERE tid='$tid'"); }
if ($seed3 == 4) { mysql_db_query($tourneys, "UPDATE info SET pos2='$p3' WHERE tid='$tid'"); }
if ($seed4 == 1) { mysql_db_query($tourneys, "UPDATE info SET pos1='$p4' WHERE tid='$tid'"); }
if ($seed4 == 2) { mysql_db_query($tourneys, "UPDATE info SET pos3='$p4' WHERE tid='$tid'"); }
if ($seed4 == 3) { mysql_db_query($tourneys, "UPDATE info SET pos4='$p4' WHERE tid='$tid'"); }
if ($seed4 == 4) { mysql_db_query($tourneys, "UPDATE info SET pos2='$p4' WHERE tid='$tid'"); }
Ok, just to explain - this is based on part of my tournament script. All tournaments are in the one table. 'p1', 'p2' etc stands for "player 1's userid #' etc. Hence 'p1rating' is player 1's rating.
Once it works out who is seeded in what position, it places them in pos1, pos2, pos3, or pos4 which allows the "standings to know who goes in what part of the tree.
Make sense? Probably not! LOL
This is a small version of my script - we go up to 8 players - so it doubles in size - I am concerned though when I go up to 16, 32 and OMG 64!! lol
Any idea's?
Thanks in advance! :thumbsup:
I have a bad habit of writing scripts that are way too big and doing things the hard way - last time I posted like this a 30 line script turned into a 4 line script! LOL
So here is my script:
// Set all 4 players as the 4th seed.
$seed1 = 4;
$seed2 = 4;
$seed3 = 4;
$seed4 = 4;
// Move each player up one seed when their rating is higher.
if ($p1rating > $p2rating) { $seed1 = $seed1 - 1; } else { $seed2 = $seed2 - 1; }
if ($p1rating > $p3rating) { $seed1 = $seed1 - 1; } else { $seed3 = $seed3 - 1; }
if ($p1rating > $p4rating) { $seed1 = $seed1 - 1; } else { $seed4 = $seed4 - 1; }
if ($p2rating > $p3rating) { $seed2 = $seed2 - 1; } else { $seed3 = $seed3 - 1; }
if ($p2rating > $p4rating) { $seed2 = $seed2 - 1; } else { $seed4 = $seed4 - 1; }
if ($p3rating > $p4rating) { $seed3 = $seed3 - 1; } else { $seed4 = $seed4 - 1; }
// Insert seed numbers.
mysql_db_query($tourneys, "UPDATE info SET s1='$seed1', s2='$seed2', s3='$seed3', s4='$seed4' WHERE tid='$tid'");
// Place players into appropriate positions according to seed.
if ($seed1 == 1) { mysql_db_query($tourneys, "UPDATE info SET pos1='$p1' WHERE tid='$tid'"); }
if ($seed1 == 2) { mysql_db_query($tourneys, "UPDATE info SET pos3='$p1' WHERE tid='$tid'"); }
if ($seed1 == 3) { mysql_db_query($tourneys, "UPDATE info SET pos4='$p1' WHERE tid='$tid'"); }
if ($seed1 == 4) { mysql_db_query($tourneys, "UPDATE info SET pos2='$p1' WHERE tid='$tid'"); }
if ($seed2 == 1) { mysql_db_query($tourneys, "UPDATE info SET pos1='$p2' WHERE tid='$tid'"); }
if ($seed2 == 2) { mysql_db_query($tourneys, "UPDATE info SET pos3='$p2' WHERE tid='$tid'"); }
if ($seed2 == 3) { mysql_db_query($tourneys, "UPDATE info SET pos4='$p2' WHERE tid='$tid'"); }
if ($seed2 == 4) { mysql_db_query($tourneys, "UPDATE info SET pos2='$p2' WHERE tid='$tid'"); }
if ($seed3 == 1) { mysql_db_query($tourneys, "UPDATE info SET pos1='$p3' WHERE tid='$tid'"); }
if ($seed3 == 2) { mysql_db_query($tourneys, "UPDATE info SET pos3='$p3' WHERE tid='$tid'"); }
if ($seed3 == 3) { mysql_db_query($tourneys, "UPDATE info SET pos4='$p3' WHERE tid='$tid'"); }
if ($seed3 == 4) { mysql_db_query($tourneys, "UPDATE info SET pos2='$p3' WHERE tid='$tid'"); }
if ($seed4 == 1) { mysql_db_query($tourneys, "UPDATE info SET pos1='$p4' WHERE tid='$tid'"); }
if ($seed4 == 2) { mysql_db_query($tourneys, "UPDATE info SET pos3='$p4' WHERE tid='$tid'"); }
if ($seed4 == 3) { mysql_db_query($tourneys, "UPDATE info SET pos4='$p4' WHERE tid='$tid'"); }
if ($seed4 == 4) { mysql_db_query($tourneys, "UPDATE info SET pos2='$p4' WHERE tid='$tid'"); }
Ok, just to explain - this is based on part of my tournament script. All tournaments are in the one table. 'p1', 'p2' etc stands for "player 1's userid #' etc. Hence 'p1rating' is player 1's rating.
Once it works out who is seeded in what position, it places them in pos1, pos2, pos3, or pos4 which allows the "standings to know who goes in what part of the tree.
Make sense? Probably not! LOL
This is a small version of my script - we go up to 8 players - so it doubles in size - I am concerned though when I go up to 16, 32 and OMG 64!! lol
Any idea's?
Thanks in advance! :thumbsup: