PersonaNonGrata, [code]
<?
$ql=mysql_query(\"SELECT * FROM `duel` WHERE `act` = \'1\' AND `time` < \'\".$time.\"\' ORDER BY time\"
;
while ($finish = mysql_fetch_array($ql))
{
$vote=mysql_result(mysql_query(\"SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = \'$finish[id]\' AND `id_opponent` = \'$finish[user]\'\"
,0);
$vote2=mysql_result(mysql_query(\"SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = \'$finish[id]\' AND `id_opponent` = \'$finish[opponent]\'\"
,0);
if($vote>$vote2){
mysql_query(\"UPDATE `user` SET `rating`=`rating`+\'$vote\' WHERE `id`=\'\".$finish[\'user\'].\"\'\"
;
mysql_query(\"UPDATE `duel` SET `finish` = \'\".$finish[\'user\'].\"\', `act`=\'2\' WHERE `id`=\'\".$finish[\'id\'].\"\'\"
;
$msg = \'Поздравляем, вы выиграли в дуэли и ваш рейтинг вырос на \'.$vote.\'!\';
mysql_query(\"INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values (\'0\', \'\".$finish[\'user\'].\"\', \'\".$msg.\"\', \'\".$time.\"\')\"
;
$msgs = \'Сожалеем вам, но вы проиграли схватку в дуэли!\';
mysql_query(\"INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values (\'0\', \'\".$finish[\'opponent\'].\"\', \'\".$msgs.\"\', \'\".$time.\"\')\"
;
}
else if(($vote + $vote2) == 0){
$msg = \'К сожалению за вашу дуэль никто не проголосовал!\';
mysql_query(\"UPDATE `duel` SET `act`=\'2\' WHERE `id`=\'\".$finish[\'id\'].\"\'\"
;
mysql_query(\"INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values (\'0\', \'\".$finish[\'user\'].\"\', \'\".$msg.\"\', \'\".$time.\"\')\"
;
mysql_query(\"INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values (\'0\', \'\".$finish[\'opponent\'].\"\', \'\".$msg.\"\', \'\".$time.\"\')\"
;
}
else if($vote == $vote2){
$rat = ($vote/2);
mysql_query(\"UPDATE `user` SET `rating`=`rating`+\'$rat\' WHERE `id`=\'\".$finish[\'user\'].\"\'\"
;
mysql_query(\"UPDATE `user` SET `rating`=`rating`+\'$rat\' WHERE `id`=\'\".$finish[\'opponent\'].\"\'\"
;
mysql_query(\"UPDATE `duel` SET `act`=\'2\' WHERE `id`=\'\".$finish[\'id\'].\"\'\"
;
$msg = \'Поздравляем, схватка прошла вничью, и ваш рейтинг вырос на \'.$rat.\'!\';
mysql_query(\"INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values(\'0\', \'\".$finish[\'user\'].\"\', \'\".$msg.\"\', \'\".$time.\"\')\"
;
mysql_query(\"INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values(\'0\', \'\".$finish[\'opponent\'].\"\', \'\".$msg.\"\', \'\".$time.\"\')\"
;
}
else if($vote<$vote2){
mysql_query(\"UPDATE `user` SET `rating`=`rating`+\'$vote2\' WHERE `id`=\'\".$finish[\'opponent\'].\"\'\"
;
mysql_query(\"UPDATE `duel` SET `finish` = \'\".$finish[\'opponent\'].\"\', `act`=\'2\' WHERE `id`=\'\".$finish[\'id\'].\"\'\"
;
$msg = \'Поздравляем, вы выиграли в дуэли и ваш рейтинг вырос на \'.$vote2.\'!\';
mysql_query(\"INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values(\'0\', \'\".$finish[\'opponent\'].\"\', \'\".$msg.\"\', \'\".$time.\"\')\"
;
$msgs = \'Сожалеем вам, но вы проиграли схватку в дуэли!\';
mysql_query(\"INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values(\'0\', \'\".$finish[\'user\'].\"\', \'\".$msgs.\"\', \'\".$time.\"\')\"
;
}
}
$qld=mysql_query(\"SELECT * FROM `duel` WHERE `act` = \'0\' AND `time` < \'\".$time.\"\' ORDER BY time\"
;
while ($exit = mysql_fetch_array($qld))
{
$ald = mysql_fetch_array(mysql_query(\"SELECT * FROM `user` WHERE `id` = \'\".$exit[\'user\'].\"\' LIMIT 1\"
);
$msg = \'К сожалению \'.$ald[\'nick\'].\' проигнорировал ваш вызов на дуэль!\';
mysql_query(\"INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values(\'0\', \'\".$exit[\'user\'].\"\', \'\".$msg.\"\', \'\".$time.\"\')\"
;
mysql_query(\"DELETE FROM `duel` WHERE `id` = \'$exit[id]\' LIMIT 1\"
;
}
?>
[/code]