0 || $bu[$i]['nich']) { mysql_query( 'UPDATE `users` SET `lose` = "' . $bu[$i]['lose'] . '", `nick` = "' . $bu[$i]['nich'] . '" WHERE `id` = "' . $bu[$i]['id'] . '" LIMIT 1' ); mysql_query( 'UPDATE `bs_turnirs` SET `users_finish` = `users_finish` + 1 WHERE `id` = "' . $id['id'] . '" LIMIT 1' ); /* ������� ����� */ if ($bu['inBot'] == 0) { $pls1 = mysql_fetch_array( mysql_query( 'SELECT `id`, `bsid`, `money`, `finish`, `time`, `inBot`, `uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `finish` = 0 AND `time` = "' . $id['time_start'] . '" AND `inBot` = "' . $bu[$i]['id'] . '" LIMIT 1' ) ); if (isset($pls1['id'])) { mysql_query('DELETE FROM `users` WHERE `id` = "' . $bu[$i]['id'] . '" LIMIT 1'); mysql_query('DELETE FROM `stats` WHERE `id` = "' . $bu[$i]['id'] . '" LIMIT 1'); //���������� �������� �� ����� $spi = mysql_query( 'SELECT `id`,`item_id` FROM `items_users` WHERE `uid` = "' . $bu[$i]['id'] . '" LIMIT 500' ); $ins = ''; while ($pli = mysql_fetch_array($spi)) { $ins .= '("' . $di['dn_id'] . '","' . $pli['item_id'] . '","' . time( ) . '","' . $di['x'] . '","' . $di['y'] . '"),'; } $ins = rtrim($ins, ','); mysql_query( 'INSERT INTO `dungeon_items` (`dn`,`item_id`,`time`,`x`,`y`) VALUES ' . $ins . '' ); mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $pls1['inBot'] . '" LIMIT 1'); mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $pls1['inBot'] . '" LIMIT 1'); mysql_query( 'UPDATE `bs_zv` SET `finish` = "' . time( ) . '" WHERE `id` = "' . $pls1['id'] . '" LIMIT 1' ); mysql_query('UPDATE `users` SET `inUser` = 0 WHERE `id` = "' . $pls1['uid'] . '" LIMIT 1'); } } $id['users_finish']++; } $i++; } } if ($id['users'] - $id['users_finish'] >= 2) { return; } $win = []; $sp = mysql_query( 'SELECT `id`,`bsid`,`money`,`finish`,`time`,`inBot`,`uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `finish` = "0" AND `time` = "' . $id['time_start'] . '" ORDER BY `money` DESC LIMIT 100' ); while ($pl = mysql_fetch_array($sp)) { $ur = mysql_fetch_array( mysql_query( 'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`twink`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1' ) ); $ub = mysql_fetch_array( mysql_query( 'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`twink`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $ur['inUser'] . '" LIMIT 1' ) ); if (isset($ur['id']) && isset($ub['id']) && $ub['lose'] <= 0 && $ub['nich'] <= 0) { $win = $ub; $winr = $ur; } } $chat = new Chat(); $cmsg = new ChatMessage(); /* ��������� �� */ if (isset($win['id']) && $win['lose'] == 0 && $win['nich'] == 0 && $win['id'] > 0) { //���� ���������� $bsep = 0; if ($winr['level'] < 6) { $bsep = 2500; } elseif ($winr['level'] < 7) { $bsep = 5000; } elseif ($winr['level'] < 8) { $bsep = 15000; } elseif ($winr['level'] < 9) { $bsep = 25000; } else { $bsep = 50000; } /* ������ ���� */ $mn = (round($id['money'] / 100 * 85)); mysql_query( 'UPDATE `users` SET `money` = `money` + "' . $mn . '" WHERE `id` = "' . $winr['id'] . '" LIMIT 1' ); mysql_query( 'UPDATE `stats` SET `exp` = `exp` + "' . $bsep . '" WHERE `id` = "' . $winr['id'] . '" LIMIT 1' ); /* ��� */ $cmsg->setTo($winr['login']); $cmsg->setText( "�����������! �� �������� � ������� "����� ������"! �������� �����: $bsep, ������: $mn ��." ); $cmsg->setType(6); $chat->sendMsg($cmsg); $cmsg->setTo(''); $cmsg->setIsAlert(true); $cmsg->setText( "���������� ������ "����� ������", ���������� �������: {$winr['login']}! �����������!" ); $cmsg->setType(5); $chat->sendMsg($cmsg); Delo::add( 1, 'WinTournament.' . $user->info['city'], $uid, '"WinTournament.' . $user->info['city'] . '" (����� ������): �������� "' . $mn . ' ��."', ); } else { /* ��� */ $cmsg->setIsAlert(true); $cmsg->setType(5); $cmsg->setText('���������� ������ ������ ������, ���������� �������: �����������.'); } $sp = mysql_query( 'SELECT `id`,`bsid`,`money`,`finish`,`time`,`inBot`,`uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `time` = "' . $id['time_start'] . '" ORDER BY `money` DESC LIMIT 100' ); while ($pl = mysql_fetch_array($sp)) { $ur = mysql_fetch_array( mysql_query( 'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1' ) ); $ub = mysql_fetch_array( mysql_query( 'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $ur['inUser'] . '" LIMIT 1' ) ); if (isset($ub['id'])) { //del mysql_query('DELETE FROM `users` WHERE `id` = "' . $ub['id'] . '" LIMIT 1'); mysql_query('DELETE FROM `stats` WHERE `id` = "' . $ub['id'] . '" LIMIT 1'); mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $ub['id'] . '" LIMIT 500'); mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $ub['id'] . '" LIMIT 500'); //upd mysql_query( 'UPDATE `bs_zv` SET `finish` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1' ); mysql_query('UPDATE `users` SET `inUser` = 0 WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'); } } } }