<?php

    

    
    
require_once ('system/func.php');
        
     
$param = 2500; //сколько даем параметров

$almaz = 2000; //сколько даем золота

$gold = 10000; //сколько даем серебра


$win = mysql_fetch_array(mysql_query("SELECT * FROM `users` ORDER BY `cr_tour` DESC LIMIT 1"));  if($win){

 mysql_query('UPDATE `users` SET `str` = `str`-"'.$param.'",`def`=`def`-"'.$param.'",`max_health`=`max_health`-"'.$param.'" WHERE `win_tour` = 1');






 
mysql_query('UPDATE `users` SET `win_tour`=0 WHERE `win_tour` =1');  }  






mysql_query('UPDATE `users` SET `str` = `str`+"'.$param.'",`def`=`def`+"'.$param.'",`max_health`=`max_health`+"'.$param.'",`win_tour`=1 WHERE `id` = "'.$win['id'].'"');








 






$pasi = 'Турнир Пустоши окончен';


$bes = mysql_query("SELECT * FROM `users` where `cr_tour`>0 ORDER BY `cr_tour` DESC LIMIT 10"); 


$kes = 0;

  while($best = mysql_fetch_array($bes)) { 

$gold  = $gold -50;

$sera  = $sera -500;


$kes++;

mysql_query('UPDATE `users` SET `almaz` = `almaz`+'.$almaz.' , `gold`=`gold`+'.$gold.' WHERE `id` = '.$best[id].'');     




$pasi.= '</br><span class="login">'.$best['login'].'</span>(<img src="/cr_tour/cris.png">'.$best['cr_tour'].') <img src="/images/icons/almaz.png">'.$almaz.' <img src="/images/icons/gold.png">'.$gold.'';




$igro= '</br><span class="login">Вы Заняли '.$kes.' место в  турнире. Собрали <img src="/cr_tour/cris.png">'.$best['cr_tour'].' кристаллов. Ваша награда : <img src="/images/icons/almaz.png">'.$almaz.' <img src="/images/icons/gold.png">'.$gold.'</span>';





//$sem = 1;



                                           
                                         

                                         
   
}



      
      
      
                                                         
      
      




//}
//mysql_query("INSERT INTO `chat` SET `id_user` = '$sem', `time` = '".time()."', `text` = '".$pasi."'"); 






mysql_query('UPDATE `users` SET `cr_tour` =0');     
