$this->info=mysql_fetch_array(mysql_query('SELECT * FROM `turnirs` WHERE `id` = "'.$u->info['inTurnir'].'" LIMIT 1'));
$this->user=mysql_fetch_array(mysql_query('SELECT * FROM `users_turnirs` WHERE `turnir` = "'.$u->info['inTurnir'].'" AND `bot` = "'.$u->info['id'].'" LIMIT 1'));
}
publicfunctionstartTurnir(){
global$c,$u;
$row=mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `users` WHERE `win` = "0" AND `lose` = "0" AND `nich` = "0"'));
$win='Победители турнира: '.$win.'. Следующий турнир начнется через '.$u->timeOut($this->info['time2']).' ('.date('d.m.Y H:i',(time()+$this->info['time2'])).').';
$win='Победители турнира отсутствует. Следующий турнир начнется через '.$u->timeOut($this->info['time2']).' ('.date('d.m.Y H:i',(time()+$this->info['time2'])).').';
$sp=mysql_query('SELECT `id`,`price1`,`inslot`,`price2` FROM `items_main` WHERE `inslot` > 0 AND `inslot` <= 26 AND `inslot` != 25 AND `inslot` != 24 AND `inslot` != 23 AND `inslot` != 16 AND `inslot` != 17 AND `inslot` != 2 AND `price2` = 0');
$sp=mysql_query('SELECT * FROM `users_turnirs` WHERE `turnir` = "'.$this->info['id'].'" ORDER BY `points` DESC LIMIT '.$this->info['users_in']);
$tmr=rand(1,2);
if($tmr==1){
$tmr=array(2,1);
}else{
$tmr=array(1,2);
}
while($pl=mysql_fetch_array($sp)){
$inf=mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$pl['uid'].'" LIMIT 1'));
$bot=mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$pl['bot'].'" LIMIT 1'));
if(isset($inf['id'],$bot['id'])){
if($po[1]==$po[2]){
$tm=rand(1,2);
}elseif($po[1]>$po[2]){
$tm=2;
}else{
$tm=1;
}
//$tm = $tmr[$tm];
$bot['team']=$tm;
$po[$bot['team']]+=$pl['points'];
mysql_query('UPDATE `stats` SET `team` = "'.$bot['team'].'" WHERE `id` = "'.$bot['id'].'" LIMIT 1');
mysql_query('UPDATE `users_turnirs` SET `team` = "'.$bot['team'].'" WHERE `id` = "'.$pl['id'].'" LIMIT 1');
}
}
mysql_query('UPDATE `turnirs` SET `step` = "1",`time` = "'.(time()+$this->info['time3']).'" WHERE `id` = "'.$this->info['id'].'" LIMIT 1');
}
$sp=mysql_query('SELECT * FROM `users_turnirs` WHERE `turnir` = "'.$this->info['id'].'" LIMIT '.$this->info['users_in']);
$po=array(0,0);
while($pl=mysql_fetch_array($sp)){
$inf=mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$pl['uid'].'" LIMIT 1'));
$bot=mysql_fetch_array(mysql_query('SELECT `u`.*,`st`.* FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON `u`.`id` = `st`.`id` WHERE `u`.`id` = "'.$pl['bot'].'" LIMIT 1'));