2022-08-25 11:23:36 +00:00
< ? php
2022-06-06 21:30:34 +00:00
2022-12-30 19:03:37 +00:00
/**
2023-01-10 16:29:32 +00:00
* Башня смерти ?
2022-12-30 19:03:37 +00:00
*
2023-01-10 16:29:32 +00:00
* Вызов раз в минуту .
2022-12-30 19:03:37 +00:00
*/
2022-06-06 21:30:34 +00:00
2022-12-30 19:03:37 +00:00
require_once dirname ( __DIR__ ) . DIRECTORY_SEPARATOR . 'autoload.php' ;
//todo: IN PROGRESS
2022-08-25 11:23:36 +00:00
function changeSleep ( $uid , $sleep_action )
{
$u = User :: start ();
if ( $sleep_action == 1 ) {
mysql_query ( 'INSERT INTO `sleep` (`uid`,`time`,`sleep`) VALUES ("' . $uid . '","' . time () . '","1")' );
mysql_query (
" UPDATE `eff_users` SET `sleeptime`= " . time () . " ,`deactiveLast` = ( `deactiveTime` - " . time (
) . " ) WHERE `uid`=' " . mysql_real_escape_string ( $uid ) . " ' AND `no_Ace` = 0 AND `delete` = 0 "
);
mysql_query (
'UPDATE `items_users` SET `time_sleep` = "' . time (
) . '" WHERE `uid` = "' . $uid . '" AND `delete` < 1001 AND `data` LIKE "%|sleep_moroz=1%"'
);
$u -> addAction ( time (), 'sleep' , $u -> info [ 'city' ]);
} elseif ( $sleep_action == 2 ) {
mysql_query ( 'INSERT INTO `sleep` (`uid`,`time`,`sleep`) VALUES ("' . $uid . '","' . time () . '","2")' );
$sp = mysql_query (
'SELECT * FROM `items_users` WHERE `time_sleep` > 0 AND `uid` = "' . $uid . '" AND `delete` < 1001 AND `data` LIKE "%|sleep_moroz=1%"'
);
while ( $pl = mysql_fetch_array ( $sp )) {
$tm_add = time () - $pl [ 'time_sleep' ];
mysql_query (
'UPDATE `items_users` SET `time_sleep` = "0",`time_create` = "' . ( $pl [ 'time_create' ] + $tm_add ) . '" WHERE `id` = "' . $pl [ 'id' ] . '" LIMIT 1'
);
}
$sp = mysql_query (
'SELECT `id`,`deactiveTime`,`deactiveLast` FROM `eff_users` WHERE `v1` LIKE "pgb%" AND `delete` = "0" AND `deactiveTime` > 0 AND `uid` = "' . $uid . '" ORDER BY `timeUse` DESC'
);
while ( $pl = mysql_fetch_array ( $sp )) {
mysql_query (
" UPDATE `eff_users` SET `deactiveTime` = " . ( time (
) + $pl [ 'deactiveLast' ]) . " WHERE `id`=' " . $pl [ 'id' ] . " ' "
);
}
$sp = mysql_query (
'SELECT `id`,`sleeptime`,`timeUse` FROM `eff_users` WHERE `uid`="' . mysql_real_escape_string (
$uid
) . '" AND `no_Ace` = 0 AND `sleeptime` > 0 AND `delete` = 0'
);
while ( $pl = mysql_fetch_array ( $sp )) {
$timeUsen = time () - ( $pl [ 'sleeptime' ] - $pl [ 'timeUse' ]);
mysql_query (
" UPDATE `eff_users` SET `timeUse`=' " . $timeUsen . " ',`sleeptime`='0' WHERE `id`=' " . $pl [ 'id' ] . " ' "
);
}
mysql_query (
'UPDATE `actions` SET `vars` = "unsleep",`val` = "' . time (
) . '" WHERE `id` = "' . $sleep [ 'id' ] . '" LIMIT 1'
);
}
2022-06-06 21:30:34 +00:00
}
2023-01-10 16:29:32 +00:00
//Время рестарта
2022-08-25 11:23:36 +00:00
$cnfg = [
'time_restart' => 1 ,
'time_puti' => 240 ,
];
2022-06-06 21:30:34 +00:00
echo '#start#' ;
2022-08-25 11:23:36 +00:00
$magic = new Magic ();
$itbs = [
0 => 558 ,
1 => 722 ,
2 => 718 ,
3 => 700 ,
4 => 291 ,
5 => 545 ,
6 => 533 ,
7 => 536 ,
8 => 628 ,
9 => 710 ,
10 => 654 ,
11 => 684 ,
12 => 689 ,
13 => 552 ,
14 => 552 ,
15 => 716 ,
16 => 320 ,
17 => 290 ,
18 => 543 ,
19 => 528 ,
20 => 540 ,
21 => 627 ,
22 => 709 ,
23 => 653 ,
24 => 681 ,
25 => 687 ,
26 => 523 ,
27 => 523 ,
28 => 712 ,
29 => 1151 ,
30 => 544 ,
31 => 541 ,
32 => 525 ,
33 => 539 ,
34 => 633 ,
35 => 707 ,
36 => 647 ,
37 => 680 ,
38 => 685 ,
39 => 567 ,
40 => 717 ,
41 => 706 ,
42 => 527 ,
43 => 537 ,
44 => 626 ,
45 => 708 ,
46 => 723 ,
47 => 651 ,
48 => 683 ,
49 => 297 ,
50 => 485 ,
51 => 484 ,
52 => 686 ,
];
function microLogin2 ( $bus )
{
$bus [ 'login_BIG' ] = '<b>' ;
if ( $bus [ 'align' ] > 0 ) {
$bus [ 'login_BIG' ] .= '<img src=https://img.new-combats.com/i/align/align' . $bus [ 'align' ] . '.gif width=12 height=15 >' ;
}
if ( $bus [ 'clan' ] > 0 ) {
$bus [ 'login_BIG' ] .= '<img src=https://img.new-combats.com/i/clan/' . $bus [ 'clan' ] . '.gif width=24 height=15 >' ;
}
$bus [ 'login_BIG' ] .= '' . $bus [ 'login' ] . '</b>[' . $bus [ 'level' ] . ']<a target=_blank href=https://new-combats.com/info/' . $bus [ 'id' ] . ' ><img width=12 hiehgt=11 src=https://img.new-combats.com/i/inf_capitalcity.gif ></a>' ;
return $bus [ 'login_BIG' ];
2022-06-06 21:30:34 +00:00
}
2022-08-25 11:23:36 +00:00
function addItem ( $id , $uid , $md = null , $dn = null , $mxiznos = null )
{
$rt = - 1 ;
$i = mysql_fetch_array (
mysql_query (
'SELECT `im`.`id`,`im`.`name`,`im`.`img`,`im`.`type`,`im`.`inslot`,`im`.`2h`,`im`.`2too`,`im`.`iznosMAXi`,`im`.`inRazdel`,`im`.`price1`,`im`.`price2`,`im`.`magic_chance`,`im`.`info`,`im`.`massa`,`im`.`level`,`im`.`magic_inci`,`im`.`overTypei`,`im`.`group`,`im`.`group_max`,`im`.`geni`,`im`.`ts`,`im`.`srok`,`im`.`class`,`im`.`class_point`,`im`.`anti_class`,`im`.`anti_class_point`,`im`.`max_text`,`im`.`useInBattle`,`im`.`lbtl`,`im`.`lvl_itm`,`im`.`lvl_exp`,`im`.`lvl_aexp` FROM `items_main` AS `im` WHERE `im`.`id` = "' . mysql_real_escape_string (
$id
) . '" LIMIT 1'
)
);
if ( isset ( $i [ 'id' ])) {
$d = mysql_fetch_array (
mysql_query (
'SELECT `id`,`items_id`,`data` FROM `items_main_data` WHERE `items_id` = "' . $i [ 'id' ] . '" LIMIT 1'
)
);
2023-01-10 16:29:32 +00:00
//новая дата
2022-08-25 11:23:36 +00:00
$data = $d [ 'data' ];
if ( $i [ 'ts' ] > 0 ) {
$ui = mysql_fetch_array (
mysql_query (
'SELECT `id`,`login` FROM `users` WHERE `id` = "' . mysql_real_escape_string ( $uid ) . '" LIMIT 1'
)
);
$data .= '|sudba=' . $ui [ 'login' ];
}
if ( $md != null ) {
$data .= $md ;
}
2023-01-10 16:29:32 +00:00
//предмет с настройками из подземелья
2022-08-25 11:23:36 +00:00
if ( $dn != null && $dn [ 'del' ] > 0 ) {
$i [ 'dn_delete' ] = 1 ;
}
if ( $mxiznos > 0 ) {
$i [ 'iznosMAXi' ] = $mxiznos ;
}
$ins = mysql_query (
' INSERT INTO `items_users` ( `overType` , `item_id` , `uid` , `data` , `iznosMAX` , `geniration` , `magic_inc` , `maidin` , `lastUPD` , `time_create` , `dn_delete` ) VALUES (
" ' . $i['overTypei'] . ' " ,
" ' . $i['id'] . ' " ,
" ' . $uid . ' " ,
" ' . $data . ' " ,
" ' . $i['iznosMAXi'] . ' " ,
" ' . $i['geni'] . ' " ,
" ' . $i['magic_inci'] . ' " ,
2022-06-06 21:30:34 +00:00
" capitalcity " ,
2022-08-25 11:23:36 +00:00
" ' . time() . ' " ,
" ' . time() . ' " ,
" ' . $i['dn_delete'] . ' " ) '
);
if ( $ins ) {
$rt = mysql_insert_id ();
} else {
$rt = 0 ;
}
}
return $rt ;
2022-06-06 21:30:34 +00:00
}
2022-08-25 11:23:36 +00:00
function timeOut ( $ttm )
{
$out = '' ;
$time_still = $ttm ;
$tmp = floor ( $time_still / 2592000 );
$id = 0 ;
if ( $tmp > 0 ) {
$id ++ ;
if ( $id < 3 ) {
2023-01-10 16:29:32 +00:00
$out .= $tmp . " мес. " ;
2022-08-25 11:23:36 +00:00
}
$time_still = $time_still - $tmp * 2592000 ;
}
$tmp = floor ( $time_still / 86400 );
if ( $tmp > 0 ) {
$id ++ ;
if ( $id < 3 ) {
2023-01-10 16:29:32 +00:00
$out .= $tmp . " дн. " ;
2022-08-25 11:23:36 +00:00
}
$time_still = $time_still - $tmp * 86400 ;
}
$tmp = floor ( $time_still / 3600 );
if ( $tmp > 0 ) {
$id ++ ;
if ( $id < 3 ) {
2023-01-10 16:29:32 +00:00
$out .= $tmp . " ч. " ;
2022-08-25 11:23:36 +00:00
}
$time_still = $time_still - $tmp * 3600 ;
}
$tmp = floor ( $time_still / 60 );
if ( $tmp > 0 ) {
$id ++ ;
if ( $id < 3 ) {
2023-01-10 16:29:32 +00:00
$out .= $tmp . " мин. " ;
2022-08-25 11:23:36 +00:00
}
}
if ( $out == '' ) {
if ( $time_still < 0 ) {
$time_still = 0 ;
}
2023-01-10 16:29:32 +00:00
$out = $time_still . ' сек.' ;
2022-08-25 11:23:36 +00:00
}
return $out ;
2022-06-06 21:30:34 +00:00
}
2022-08-25 11:23:36 +00:00
function e ( $t )
{
mysql_query (
'INSERT INTO `chat` (`text`,`city`,`to`,`type`,`new`,`time`) VALUES ("<font color=#cb0000>' . mysql_real_escape_string (
$t
) . '</font>","capitalcity","","6","1","' . time () . '")'
);
2022-06-06 21:30:34 +00:00
}
2022-08-25 11:23:36 +00:00
function e2 ( $t )
{
mysql_query (
'INSERT INTO `chat` (`text`,`city`,`to`,`type`,`new`,`time`) VALUES ("<font color=#cb0000>' . mysql_real_escape_string (
$t
2023-01-10 16:29:32 +00:00
) . '</font>","capitalcity","Мусорщик","6","1","-1")'
2022-08-25 11:23:36 +00:00
);
2022-06-06 21:30:34 +00:00
}
2023-01-10 16:29:32 +00:00
//Персонаж 1 нападает на 2
2022-08-25 11:23:36 +00:00
function bs_atack ( $bs , $u1 , $u2 )
{
global $magic ;
if ( isset ( $u1 [ 'id' ], $u2 [ 'id' ])) {
$btl_id = $magic -> atackUser ( $u1 [ 'id' ], $u2 [ 'id' ], $u2 [ 'team' ], $u2 [ 'battle' ]);
if ( $btl_id > 0 ) {
mysql_query ( 'UPDATE `battle` SET `inTurnir` = "' . $bs [ 'id' ] . '" WHERE `id` = "' . $btl_id . '" LIMIT 1' );
}
$usr_real = mysql_fetch_array (
mysql_query (
'SELECT `id`,`sex`,`login`,`align`,`clan`,`battle`,`level` FROM `users` WHERE `login` = "' . $u2 [ 'login' ] . '" AND `inUser` = "' . $u2 [ 'id' ] . '" LIMIT 1'
)
);
if ( ! isset ( $usr_real [ 'id' ])) {
$usr_real = $u2 ;
}
$me_real = mysql_fetch_array (
mysql_query (
'SELECT `id`,`sex`,`login`,`align`,`clan`,`battle`,`level` FROM `users` WHERE `inUser` = "' . $u1 [ 'id' ] . '" AND `login` = "' . $u1 [ 'login' ] . '" LIMIT 1'
)
);
if ( ! isset ( $me_real [ 'id' ])) {
$me_real = $u1 ;
}
if ( $u2 [ 'battle' ] > 0 ) {
2023-01-10 16:29:32 +00:00
//Заносим в лог БС
2022-08-25 11:23:36 +00:00
if ( $u1 [ 'sex' ] == 0 ) {
2023-01-10 16:29:32 +00:00
$text = '{u1} вмешался в поединок против {u2} <a target=_blank href=/logs.php?log=' . $btl_id . ' >»»</a>' ;
2022-08-25 11:23:36 +00:00
} else {
2023-01-10 16:29:32 +00:00
$text = '{u1} вмешалась в поединок против {u2} <a target=_blank href=/logs.php?log=' . $btl_id . ' >»»</a>' ;
2022-08-25 11:23:36 +00:00
}
} else {
2023-01-10 16:29:32 +00:00
//Заносим в лог БС
2022-08-25 11:23:36 +00:00
if ( $u1 [ 'sex' ] == 0 ) {
2023-01-10 16:29:32 +00:00
$text = '{u1} напал на {u2} завязался бой <a target=_blank href=/logs.php?log=' . $btl_id . ' >»»</a>' ;
2022-08-25 11:23:36 +00:00
} else {
2023-01-10 16:29:32 +00:00
$text = '{u1} напала на {u2} завязался бой <a target=_blank href=/logs.php?log=' . $btl_id . ' >»»</a>' ;
2022-08-25 11:23:36 +00:00
}
}
if ( isset ( $usr_real [ 'id' ])) {
$usrreal = '' ;
if ( $usr_real [ 'align' ] > 0 ) {
$usrreal .= '<img src=https://img.new-combats.com/i/align/align' . $usr_real [ 'align' ] . '.gif width=12 height=15 >' ;
}
if ( $usr_real [ 'clan' ] > 0 ) {
$usrreal .= '<img src=https://img.new-combats.com/i/clan/' . $usr_real [ 'clan' ] . '.gif width=24 height=15 >' ;
}
$usrreal .= '<b>' . $usr_real [ 'login' ] . '</b>[' . $usr_real [ 'level' ] . ']<a target=_blank href=https://new-combats.com/info/' . $usr_real [ 'id' ] . ' ><img width=12 hiehgt=11 src=https://img.new-combats.com/i/inf_capitalcity.gif ></a>' ;
} else {
2023-01-10 16:29:32 +00:00
$mereal = '<i>Невидимка</i>[??]' ;
2022-08-25 11:23:36 +00:00
}
if ( isset ( $me_real [ 'id' ])) {
$mereal = '' ;
if ( $me_real [ 'align' ] > 0 ) {
$mereal .= '<img src=https://img.new-combats.com/i/align/align' . $me_real [ 'align' ] . '.gif width=12 height=15 >' ;
}
if ( $me_real [ 'clan' ] > 0 ) {
$mereal .= '<img src=https://img.new-combats.com/i/clan/' . $me_real [ 'clan' ] . '.gif width=24 height=15 >' ;
}
$mereal .= '<b>' . $me_real [ 'login' ] . '</b>[' . $me_real [ 'level' ] . ']<a target=_blank href=https://new-combats.com/info/' . $me_real [ 'id' ] . ' ><img width=12 hiehgt=11 src=https://img.new-combats.com/i/inf_capitalcity.gif ></a>' ;
} else {
2023-01-10 16:29:32 +00:00
$mereal = '<i>Невидимка</i>[??]' ;
2022-08-25 11:23:36 +00:00
}
$text = str_replace ( '{u1}' , $mereal , $text );
$text = str_replace ( '{u2}' , $usrreal , $text );
2023-01-10 16:29:32 +00:00
//Добавляем в лог БС
2022-08-25 11:23:36 +00:00
mysql_query (
' INSERT INTO `bs_logs` ( `type` , `text` , `time` , `id_bs` , `count_bs` , `city` , `m` , `u` ) VALUES (
" 1 " , " ' . mysql_real_escape_string( $text ) . ' " , " ' . time(
) . '", "' . $bs [ 'id' ] . '", "' . $bs [ 'count' ] . '", "' . $bs [ 'city' ] . ' " ,
" ' . round( $bs['money'] * 0.85, 2) . ' " , " ' . $i . ' "
) '
);
}
2022-06-06 21:30:34 +00:00
}
2023-01-10 16:29:32 +00:00
//Турнир не состоялся
2022-08-25 11:23:36 +00:00
function nostart ( $pl )
{
global $cnfg ;
$r = false ;
if ( $pl [ 'users' ] < 4 ) {
2023-01-10 16:29:32 +00:00
//Недостаточно игроков
2022-08-25 11:23:36 +00:00
$r = true ;
$pl [ 'time_start' ] = time () + $cnfg [ 'time_restart' ] * ( 60 * 60 );
if ( $pl [ 'users' ] > 0 ) {
e (
2023-01-10 16:29:32 +00:00
'Турнир Башни Смерти, для ' . $pl [ 'to_lvl' ] . ' уровней в <b>Башне Смерти</b> не начался по причине: Недостаточно участников ' . timeOut (
2022-08-25 11:23:36 +00:00
$pl [ 'time_start' ] - time ()
) . ' (<small>' . date ( 'd.m.Y H:i' , $pl [ 'time_start' ]) . '</small>)'
);
} else {
e (
2023-01-10 16:29:32 +00:00
'Начало турнира Башни Смерти, для ' . $pl [ 'to_lvl' ] . ' уровней в <b>Башне Смерти</b> через ' . timeOut (
2022-08-25 11:23:36 +00:00
$pl [ 'time_start' ] - time ()
) . ' (<small>' . date (
'd.m.Y H:i' , $pl [ 'time_start' ]
2023-01-10 16:29:32 +00:00
) . '</small>), текущий призовой фонд: 0.00 кр., <b>1.00</b> Екр., заявок: 0'
2022-08-25 11:23:36 +00:00
);
}
2023-01-10 16:29:32 +00:00
//Возврат вкладов игроков
2022-08-25 11:23:36 +00:00
$sp = mysql_query ( 'SELECT * FROM `bs_zv` WHERE `bsid` = "' . $pl [ 'id' ] . '" AND `finish` = "0"' );
while ( $pu = mysql_fetch_array ( $sp )) {
mysql_query (
'UPDATE `users` SET `money` = `money` + "' . $pu [ 'money' ] . '" WHERE `id` = "' . $pu [ 'uid' ] . '" LIMIT 1'
);
mysql_query ( 'UPDATE `bs_zv` SET `finish` = "' . time () . '" WHERE `id` = "' . $pu [ 'id' ] . '" LIMIT 1' );
}
2023-01-10 16:29:32 +00:00
//Обновление турнира
2022-08-25 11:23:36 +00:00
mysql_query (
'UPDATE `bs_turnirs` SET `ch1` = "0",`ch2` = "0", `status` = "0", `money` = "0", `time_start` = "' . $pl [ 'time_start' ] . '",`users` = "0",`users_finish` = "0" WHERE `id` = "' . $pl [ 'id' ] . '" LIMIT 1'
);
}
return $r ;
2022-06-06 21:30:34 +00:00
}
2023-01-10 16:29:32 +00:00
//Добавление "архивариуса"
2022-08-25 11:23:36 +00:00
function add_arhiv ( $pl , $user )
{
$return = 0 ;
mysql_query (
2023-01-06 14:57:25 +00:00
' INSERT INTO `users` ( `login` , `pass` , `level` , `inTurnir` , `sex` , `obraz` , `name` , `online` , `city` , `room` , `align` , `clan` , `cityreg` , `bithday` ) VALUES (
2022-08-25 11:23:36 +00:00
" ' . $user['login'] . ' " , " bstowerbot " , " ' . $user['level'] . ' " , " ' . $pl['id'] . ' " , " ' . $user['sex'] . ' " , " ' . $user['obraz'] . ' " , " ' . $user['login'] . ' " , " ' . (time(
2023-01-06 14:57:25 +00:00
) + 60 * 60 * 24 ) . '","' . $user [ 'city' ] . '","' . $user [ 'room' ] . '","' . $user [ 'align' ] . '","' . $user [ 'clan' ] . ' " , " capitalcity " , " 01.02 . 2003 " ,
2022-08-25 11:23:36 +00:00
) '
);
$return = mysql_insert_id ();
if ( $return > 0 ) {
$ins = mysql_query (
' INSERT INTO `stats` ( `id` , `stats` , `bot` , `x` , `y` , `upLevel` ) VALUES (
" ' . $return . ' " , " s1=30|s2=31|s3=33|s4=30|s5=30|s6=1|s7=25|rinv=40|m9=5|m6=10 " , " 2 " , " ' . $user['x'] . ' " , " ' . $user['y'] . ' " , " 98 "
) '
);
if ( ! $ins ) {
mysql_query ( 'DELETE FROM `users` WHERE `id` = "' . $return . '" LIMIT 1' );
$return = 0 ;
}
}
return $return ;
2022-06-06 21:30:34 +00:00
}
2023-01-10 16:29:32 +00:00
//Завершаем текущий турнир
2022-08-25 11:23:36 +00:00
function backusers ( $pl )
{
$sp = mysql_query ( 'SELECT * FROM `bs_zv` WHERE `bsid` = "' . $pl [ 'id' ] . '" AND `off` = "0" AND `inBot` > 0' );
while ( $pu = mysql_fetch_array ( $sp )) {
2023-01-10 16:29:32 +00:00
//Удаление клона
2022-08-25 11:23:36 +00:00
mysql_query ( 'DELETE FROM `users` WHERE `id` = "' . $pu [ 'inBot' ] . '" LIMIT 1' );
mysql_query ( 'DELETE FROM `stats` WHERE `id` = "' . $pu [ 'inBot' ] . '" LIMIT 1' );
mysql_query ( 'DELETE FROM `actions` WHERE `uid` = "' . $pu [ 'inBot' ] . '"' );
mysql_query ( 'DELETE FROM `items_users` WHERE `uid` = "' . $pu [ 'inBot' ] . '"' );
mysql_query ( 'DELETE FROM `eff_users` WHERE `uid` = "' . $pu [ 'inBot' ] . '"' );
mysql_query ( 'DELETE FROM `users_delo` WHERE `uid` = "' . $pu [ 'inBot' ] . '"' );
2023-01-10 16:29:32 +00:00
//Обновление персонажа
2022-08-25 11:23:36 +00:00
mysql_query ( 'UPDATE `users` SET `inUser` = "0" WHERE `id` = "' . $pu [ 'uid' ] . '" LIMIT 1' );
2023-01-10 16:29:32 +00:00
//Обновляем заявку
2022-08-25 11:23:36 +00:00
mysql_query ( 'UPDATE `bs_zv` SET `off` = "' . time () . '" WHERE `id` = "' . $pu [ 'id' ] . '" LIMIT 1' );
}
2023-01-10 16:29:32 +00:00
//Архивариусы
2022-08-25 11:23:36 +00:00
$sp = mysql_query (
'SELECT * FROM `users` WHERE `pass` = "bstowerbot" AND `inTurnir` = "' . $pl [ 'id' ] . '" AND `room` = "362"'
);
while ( $pu = mysql_fetch_array ( $sp )) {
mysql_query ( 'DELETE FROM `users` WHERE `id` = "' . $pu [ 'id' ] . '" LIMIT 1' );
mysql_query ( 'DELETE FROM `stats` WHERE `id` = "' . $pu [ 'id' ] . '" LIMIT 1' );
mysql_query ( 'DELETE FROM `actions` WHERE `uid` = "' . $pu [ 'id' ] . '"' );
mysql_query ( 'DELETE FROM `items_users` WHERE `uid` = "' . $pu [ 'id' ] . '"' );
mysql_query ( 'DELETE FROM `eff_users` WHERE `uid` = "' . $pu [ 'id' ] . '"' );
mysql_query ( 'DELETE FROM `users_delo` WHERE `uid` = "' . $pu [ 'id' ] . '"' );
}
2023-01-10 16:29:32 +00:00
//Удаляем предметы раскиданные по БС
2022-08-25 11:23:36 +00:00
mysql_query ( 'DELETE FROM `bs_items` WHERE `bid` = "' . $pl [ 'id' ] . '" AND `count` = "' . $pl [ 'count' ] . '"' );
2023-01-10 16:29:32 +00:00
//Удаляем события в БС
2022-08-25 11:23:36 +00:00
mysql_query ( 'DELETE FROM `bs_actions` WHERE `bid` = "' . $pl [ 'id' ] . '" AND `count` = "' . $pl [ 'count' ] . '"' );
2023-01-10 16:29:32 +00:00
//Удаляем ловушки в БС
2022-08-25 11:23:36 +00:00
mysql_query ( 'DELETE FROM `bs_trap` WHERE `bid` = "' . $pl [ 'id' ] . '" AND `count` = "' . $pl [ 'count' ] . '"' );
2022-06-06 21:30:34 +00:00
}
2022-08-25 11:23:36 +00:00
$exp2 = [
1 => 30000 ,
2 => 300000 ,
];
$st2s = [
7 => [
0 => 10 ,
1 => 64 ,
2 => 8 ,
],
8 => [
0 => 11 ,
1 => 78 ,
2 => 9 ,
],
];
2022-06-06 21:30:34 +00:00
$sp = mysql_query ( 'SELECT * FROM `bs_turnirs`' );
2022-08-25 11:23:36 +00:00
while ( $pl = mysql_fetch_array ( $sp )) {
//
$pl [ 'to_lvl' ] = $pl [ 'level' ];
if ( $pl [ 'level' ] != $pl [ 'level_max' ]) {
$pl [ 'to_lvl' ] .= '-' . $pl [ 'level_max' ] . '' ;
}
2023-01-10 16:29:32 +00:00
$pl [ 'to_lvl' ] = 'всех' ;
2022-08-25 11:23:36 +00:00
if ( $pl [ 'status' ] == 1 ) {
//
$tcu = mysql_fetch_array (
mysql_query ( 'SELECT COUNT(*) FROM `users` WHERE `inTurnir` = "' . $pl [ 'id' ] . '" AND `room` = "362"' )
);
$tcu = $tcu [ 0 ];
//
if ( $pl [ 'users' ] != $tcu ) {
2023-01-10 16:29:32 +00:00
//Что-то сбилось
2022-08-25 11:23:36 +00:00
$pl [ 'users' ] = $tcu ;
}
//
2023-01-10 16:29:32 +00:00
//Турнир идет, проверяем живых игроков, либо завершаем через 6 часов
2022-08-25 11:23:36 +00:00
if ( $pl [ 'time_start' ] < time () - 6 * 60 * 60 ) {
2023-01-10 16:29:32 +00:00
//Завершаем турнир по тайму
//Добавляем в лог БС
$text = 'Турнир завершен. Победитель: <i>Отсутствует</i> (Турнир завершился по таймауту). Призовой фонд: <b>' . round (
2022-08-25 11:23:36 +00:00
$pl [ 'money' ] * 0.85 , 2
2023-01-10 16:29:32 +00:00
) . '</b> кр.' ;
2022-08-25 11:23:36 +00:00
mysql_query (
' INSERT INTO `bs_logs` ( `type` , `text` , `time` , `id_bs` , `count_bs` , `city` , `m` , `u` ) VALUES (
" 1 " , " ' . mysql_real_escape_string( $text ) . ' " , " ' . time(
) . '", "' . $pl [ 'id' ] . '", "' . $pl [ 'count' ] . '", "' . $pl [ 'city' ] . ' " ,
" ' . round( $pl['money'] * 0.85, 2) . ' " , " ' . $i . ' "
) '
);
//
2023-01-10 16:29:32 +00:00
//Сохраняем статистику
2022-08-25 11:23:36 +00:00
mysql_query (
' INSERT INTO `bs_statistic` ( `bsid` , `count` , `time_start` , `time_finish` , `time_sf` , `type_bs` , `money` , `wlogin` , `wuid` , `walign` , `wclan` ) VALUES (
" ' . $pl['id'] . ' " , " ' . $pl['count'] . ' " , " ' . $pl['time_start'] . ' " , " ' . time() . ' " , " ' . (time(
) - $pl [ 'time_start' ]) . '","' . $pl [ 'type_btl' ] . '","' . round ( $pl [ 'money' ] * 0.85 , 2 ) . ' " ,
2022-06-06 21:30:34 +00:00
" 2 " , " 0 " , " 0 " , " 0 "
2022-08-25 11:23:36 +00:00
) '
);
$pl [ 'time_start' ] = time () + $cnfg [ 'time_restart' ] * ( 60 * 60 );
e (
2023-01-10 16:29:32 +00:00
'Турнир для ' . $pl [ 'to_lvl' ] . ' уровней в <b>Башне Смерти</b> завершился по таймауту. Начало нового турнира через ' . timeOut (
2022-08-25 11:23:36 +00:00
$pl [ 'time_start' ] - time () - 3600
) . ' (<small>' . date ( 'd.m.Y H:i' , $pl [ 'time_start' ]) . '</small>)'
);
backusers ( $pl );
$pl [ 'count' ] ++ ;
mysql_query (
'UPDATE `bs_turnirs` SET `money` = "0",`count` = "' . $pl [ 'count' ] . '",`status` = "0",`time_start` = "' . $pl [ 'time_start' ] . '",`users` = "0",`users_finish` = "0",`ch1` = "0",`arhiv` = "0" WHERE `id` = "' . $pl [ 'id' ] . '" LIMIT 1'
);
} else {
mysql_query (
'UPDATE `users` SET `online` = "' . ( time (
) + 60 * 60 * 6 ) . '" WHERE `inTurnir` = "' . $pl [ 'id' ] . '" OR (`room` >= 362 AND `room` <= 366) LIMIT ' . ( $pl [ 'users' ] + $pl [ 'arhiv' ])
);
2023-01-10 16:29:32 +00:00
//Проверяем живых игроков
2022-08-25 11:23:36 +00:00
if ( $pl [ 'users' ] < 2 ) {
mysql_query (
2023-01-10 16:29:32 +00:00
'DELEE FROM `users` WHERE `login` LIKE "%(клон%" AND `inTurnir` = "' . $pl [ 'id' ] . '" AND `room` = "362"'
2022-08-25 11:23:36 +00:00
);
if ( $pl [ 'users' ] == 1 ) {
$pl [ 'usersn' ] = mysql_fetch_array (
mysql_query (
'SELECT COUNT(*) FROM `users` WHERE `inTurnir` = "' . $pl [ 'id' ] . '" AND `room` = "362" LIMIT 1'
)
);
$pl [ 'usersn' ] = $pl [ 'usersn' ][ 0 ];
if ( $pl [ 'users' ] != $pl [ 'usersn' ]) {
//$pl['users'] = $pl['usersn'];
}
}
2023-01-10 16:29:32 +00:00
//Доп. проверка живых
2022-08-25 11:23:36 +00:00
if ( $pl [ 'users' ] == 1 ) {
2023-01-10 16:29:32 +00:00
//Завершаем турнир, есть 1 победитель
2022-08-25 11:23:36 +00:00
if ( $pl [ 'arhiv' ] == 0 ) {
2023-01-10 16:29:32 +00:00
//Архивариуса нет, завершаем турнир
2022-08-25 11:23:36 +00:00
$uwin_bot = mysql_fetch_array (
mysql_query (
'SELECT `id`,`money`,`login`,`level`,`align`,`clan` FROM `users` WHERE `inTurnir` = "' . $pl [ 'id' ] . '" AND `room` = "362" LIMIT 1'
)
);
$swin_bot = mysql_fetch_array (
mysql_query ( 'SELECT `id`,`exp` FROM `stats` WHERE `id` = "' . $uwin_bot [ 'id' ] . '" LIMIT 1' )
);
$uwin = mysql_fetch_array (
mysql_query (
'SELECT `id`,`money`,`money2`,`login`,`level`,`align`,`clan` FROM `users` WHERE `inUser` = "' . $uwin_bot [ 'id' ] . '" LIMIT 1'
)
);
$swin = mysql_fetch_array (
mysql_query ( 'SELECT `id`,`exp` FROM `stats` WHERE `id` = "' . $uwin [ 'id' ] . '" LIMIT 1' )
);
2023-01-10 16:29:32 +00:00
//Опыт
2022-08-25 11:23:36 +00:00
$swin_bot [ 'exp' ] -= 30000 ;
$swin_bot [ 'exp' ] = round ( $swin_bot [ 'exp' ] / 2 );
if ( $swin_bot [ 'exp' ] < 0 ) {
$swin_bot [ 'exp' ] = 0 ;
}
$swin_bot [ 'exp' ] += 1500 ;
2023-01-10 16:29:32 +00:00
//Сохраняем статистику
2022-08-25 11:23:36 +00:00
mysql_query (
' INSERT INTO `bs_statistic` ( `bsid` , `count` , `time_start` , `time_finish` , `time_sf` , `type_bs` , `money` , `wlogin` , `wuid` , `walign` , `wclan` , `wlevel` ) VALUES (
" ' . $pl['id'] . ' " , " ' . $pl['count'] . ' " , " ' . $pl['time_start'] . ' " , " ' . time(
) . '","' . ( time () - $pl [ 'time_start' ]) . '","' . $pl [ 'type_btl' ] . '","' . round (
$pl [ 'money' ] * 0.85 , 2
) . ' " ,
" ' . $uwin['login'] . ' " , " ' . $uwin['id'] . ' " , " ' . $uwin['align'] . ' " , " ' . $uwin['clan'] . ' " , " ' . $uwin['level'] . ' "
) '
);
$pl [ 'time_start' ] = time () + $cnfg [ 'time_restart' ] * ( 60 * 60 );
if ( isset ( $uwin [ 'id' ])) {
mysql_query (
'UPDATE `users` SET `money` = "' . ( $uwin [ 'money' ] + round (
$pl [ 'money' ] * 0.85 , 2
)) . '", `money2` = "' . ( $uwin [ 'money2' ] + 1 ) . '", `win_bs` = IFNULL(`win_bs`, 0) + 1 WHERE `login` = "' . $uwin [ 'login' ] . '"'
);
mysql_query (
'UPDATE `stats` SET `exp` = "' . ( $swin [ 'exp' ] + $swin_bot [ 'exp' ]) . '" WHERE `id` = "' . $uwin [ 'id' ] . '" LIMIT 1'
);
e (
2023-01-10 16:29:32 +00:00
'#' . $pl [ 'usersn' ] . ' Турнир для ' . $pl [ 'to_lvl' ] . ' уровней в <b>Башне Смерти</b> завершился. Победитель: ' . microLogin2 (
2022-08-25 11:23:36 +00:00
$uwin
2023-01-10 16:29:32 +00:00
) . '. Приз: <b>' . round (
2022-08-25 11:23:36 +00:00
$pl [ 'money' ] * 0.85 , 2
2023-01-10 16:29:32 +00:00
) . '</b> кр. и <b>1</b> екр.<b>' . round (
2022-08-25 11:23:36 +00:00
$swin_bot [ 'exp' ]
2023-01-10 16:29:32 +00:00
) . '</b> опыта. Начало нового турнира через ' . timeOut (
2022-08-25 11:23:36 +00:00
$pl [ 'time_start' ] - time ()
) . ' (<small>' . date ( 'd.m.Y H:i' , $pl [ 'time_start' ]) . '</small>)'
);
if ( date ( 'w' ) == 0 || date ( 'w' ) == 6 || date ( 'w' ) == 3 ) {
mysql_query (
'UPDATE `stats` SET `repexp` = `repexp` + 25 WHERE `id` = "' . $uwin [ 'id' ] . '" LIMIT 1'
);
} else {
mysql_query (
'UPDATE `stats` SET `repexp` = `repexp` + 10 WHERE `id` = "' . $uwin [ 'id' ] . '" LIMIT 1'
);
}
}
2023-01-10 16:29:32 +00:00
//Добавляем в лог БС
$text = 'Турнир завершен. Победитель: ' . microLogin2 ( $uwin ) . '. Приз: <b>' . round (
2022-08-25 11:23:36 +00:00
$pl [ 'money' ] * 0.85 , 2
2023-01-10 16:29:32 +00:00
) . '</b> кр. и 1 екр.<b>' . round ( $swin_bot [ 'exp' ]) . '</b> опыта.' ;
2022-08-25 11:23:36 +00:00
mysql_query (
' INSERT INTO `bs_logs` ( `type` , `text` , `time` , `id_bs` , `count_bs` , `city` , `m` , `u` ) VALUES (
" 1 " , " ' . mysql_real_escape_string( $text ) . ' " , " ' . time(
) . '", "' . $pl [ 'id' ] . '", "' . $pl [ 'count' ] . '", "' . $pl [ 'city' ] . ' " ,
" ' . round( $pl['money'] * 0.85, 2) . ' " , " ' . $i . ' "
) '
);
//
backusers ( $pl );
$pl [ 'count' ] ++ ;
mysql_query (
'UPDATE `bs_turnirs` SET `money` = "0",`count` = "' . $pl [ 'count' ] . '",`status` = "0",`time_start` = "' . $pl [ 'time_start' ] . '",`users` = "0",`users_finish` = "0",`ch1` = "0",`arhiv` = "0" WHERE `id` = "' . $pl [ 'id' ] . '" LIMIT 1'
);
} else {
2023-01-10 16:29:32 +00:00
//Ожидаем пока игрок убьет Архивариуса
2022-08-25 11:23:36 +00:00
}
} else {
2023-01-10 16:29:32 +00:00
//Сохраняем статистику
2022-08-25 11:23:36 +00:00
mysql_query (
' INSERT INTO `bs_statistic` ( `bsid` , `count` , `time_start` , `time_finish` , `time_sf` , `type_bs` , `money` , `wlogin` , `wuid` , `walign` , `wclan` ) VALUES (
" ' . $pl['id'] . ' " , " ' . $pl['count'] . ' " , " ' . $pl['time_start'] . ' " , " ' . time(
) . '","' . ( time () - $pl [ 'time_start' ]) . '","' . $pl [ 'type_btl' ] . '","' . round (
$pl [ 'money' ] * 0.85 , 2
) . ' " ,
2022-06-06 21:30:34 +00:00
" 1 " , " 0 " , " 0 " , " 0 "
2022-08-25 11:23:36 +00:00
) '
);
2023-01-10 16:29:32 +00:00
//Просто завершаем турнир, ничья
2022-08-25 11:23:36 +00:00
$pl [ 'time_start' ] = time () + $cnfg [ 'time_restart' ] * ( 60 * 60 );
2023-01-10 16:29:32 +00:00
//Добавляем в лог БС
$text = 'Турнир завершен. Победитель: <i>Отсутствует</i> (Никто не остался в живых). Призовой фонд: <b>' . round (
2022-08-25 11:23:36 +00:00
$pl [ 'money' ] * 0.85 , 2
2023-01-10 16:29:32 +00:00
) . '</b> кр.' ;
2022-08-25 11:23:36 +00:00
mysql_query (
' INSERT INTO `bs_logs` ( `type` , `text` , `time` , `id_bs` , `count_bs` , `city` , `m` , `u` ) VALUES (
" 1 " , " ' . mysql_real_escape_string( $text ) . ' " , " ' . time(
) . '", "' . $pl [ 'id' ] . '", "' . $pl [ 'count' ] . '", "' . $pl [ 'city' ] . ' " ,
" ' . round( $pl['money'] * 0.85, 2) . ' " , " ' . $i . ' "
) '
);
//
backusers ( $pl );
$pl [ 'count' ] ++ ;
e (
2023-01-10 16:29:32 +00:00
'Турнир для ' . $pl [ 'to_lvl' ] . ' уровней в <b>Башне Смерти</b> завершился. Победитель: <i>Отсутствует</i> (Никто не остался в живых). Призовой фонд <b>' . round (
2022-08-25 11:23:36 +00:00
$pl [ 'money' ] * 0.85 , 2
2023-01-10 16:29:32 +00:00
) . '</b> кр. Начало нового турнира через ' . timeOut (
2022-08-25 11:23:36 +00:00
$pl [ 'time_start' ] - time () - 3600
) . ' (<small>' . date ( 'd.m.Y H:i' , $pl [ 'time_start' ]) . '</small>)'
);
mysql_query (
'UPDATE `bs_turnirs` SET `money` = "' . round (
$pl [ 'money' ] * 0.85 , 2
) . '",`count` = "' . $pl [ 'count' ] . '",`status` = "0",`time_start` = "' . $pl [ 'time_start' ] . '",`users` = "0",`users_finish` = "0",`ch1` = "0",`arhiv` = "0" WHERE `id` = "' . $pl [ 'id' ] . '" LIMIT 1'
);
}
} else {
2023-01-10 16:29:32 +00:00
//В с е живы
2022-08-25 11:23:36 +00:00
if ( $pl [ 'arhiv' ] > 0 ) {
$a_sp = mysql_query (
'SELECT `s`.`timeGo`,`u`.`align`,`u`.`clan`,`u`.`sex`,`u`.`pass`,`u`.`id`,`u`.`level`,`u`.`login`,`u`.`battle`,`s`.`x`,`s`.`y` FROM `users` AS `u` LEFT JOIN `stats` AS `s` ON `s`.`id` = `u`.`id` WHERE `u`.`pass` = "bstowerbot" AND `u`.`inTurnir` = "' . mysql_real_escape_string (
$pl [ 'id' ]
) . '" AND `u`.`room` = "362" LIMIT 10'
);
while ( $a_pl = mysql_fetch_array ( $a_sp )) {
$xy = mysql_fetch_array (
mysql_query (
'SELECT * FROM `bs_map` WHERE `x` = "' . $a_pl [ 'x' ] . '" AND `y` = "' . $a_pl [ 'y' ] . '" LIMIT 1'
)
);
if ( isset ( $xy [ 'id' ])) {
if ( $a_pl [ 'battle' ] == 0 ) {
2023-01-10 16:29:32 +00:00
//Поднимаем предметы
2022-08-25 11:23:36 +00:00
$sp_itm = mysql_query (
'SELECT * FROM `bs_items` WHERE `x` = "' . $a_pl [ 'x' ] . '" AND `y` = "' . $a_pl [ 'y' ] . '" AND `bid` = "' . $pl [ 'id' ] . '" AND `count` = "' . $pl [ 'count' ] . '" LIMIT 20'
);
while ( $pl_itm = mysql_fetch_array ( $sp_itm )) {
if ( rand ( 0 , 100 ) < 21 ) {
2023-01-10 16:29:32 +00:00
//Поднимаем текущий предмет
2022-08-25 11:23:36 +00:00
$itm_id = mysql_fetch_array (
mysql_query (
'SELECT * FROM `items_main` WHERE `id` = "' . $pl_itm [ 'item_id' ] . '" LIMIT 1'
)
);
if ( isset ( $itm_id [ 'id' ])) {
$itm_id [ 'odevaem' ] = addItem ( $itm_id [ 'id' ], $a_pl [ 'id' ]);
mysql_query (
'DELETE FROM `bs_items` WHERE `id` = "' . $pl_itm [ 'id' ] . '" LIMIT 1'
);
if ( $itm_id [ 'level' ] <= $a_pl [ 'level' ] && $itm_id [ 'odevaem' ] > 0 ) {
2023-01-10 16:29:32 +00:00
//надеваем
2022-08-25 11:23:36 +00:00
if ( $itm_id [ 'inslot' ] == 10 ) {
$itm_id [ 'inslot' ] = rand ( 10 , 12 );
}
mysql_query (
'UPDATE `items_users` SET `inOdet` = "0" WHERE `inOdet` = "' . $itm_id [ 'inslot' ] . '" AND `uid` = "' . $a_pl [ 'id' ] . '" LIMIT 1'
);
mysql_query (
'UPDATE `items_users` SET `inOdet` = "' . $itm_id [ 'inslot' ] . '" WHERE `id` = "' . $itm_id [ 'odevaem' ] . '" LIMIT 1'
);
}
}
}
}
unset ( $itm_id , $sp_itm , $pl_itm );
2023-01-10 16:29:32 +00:00
//Нападаем/Вмешиваемся в поединок
2022-08-25 11:23:36 +00:00
if ( $pl [ 'time_start' ] < time () - $cnfg [ 'time_puti' ]) {
$sp_usr = mysql_query (
'SELECT `u`.`id`,`u`.`battle`,`u`.`login`,`u`.`level`,`u`.`align`,`u`.`clan`,`u`.`sex`,`s`.`team` FROM `stats` AS `s` LEFT JOIN `users` AS `u` ON `u`.`id` = `s`.`id` WHERE `s`.`x` = "' . $a_pl [ 'x' ] . '" AND `u`.`pass` != "' . $a_pl [ 'pass' ] . '" AND `s`.`y` = "' . $a_pl [ 'y' ] . '" ORDER BY `s`.`timeGo` ASC LIMIT 5'
);
while ( $pl_usr = mysql_fetch_array ( $sp_usr )) {
if ( rand ( 0 , 100 ) < 31 && $a_pl [ 'battle' ] == 0 ) {
$pl_usr_real = mysql_fetch_array (
mysql_query (
'SELECT `id`,`sex`,`login`,`level`,`clan`,`align`,`battle` FROM `users` WHERE `inUser` = "' . $pl_usr [ 'id' ] . '" LIMIT 1'
)
);
if ( isset ( $pl_usr_real [ 'id' ])) {
mysql_query (
'UPDATE `stats` SET `hpNow` = `hpNow` + 10 WHERE `id` = "' . $a_pl [ 'id' ] . '" LIMIT 1'
);
mysql_query (
'UPDATE `stats` SET `hpNow` = `hpNow` + 10 WHERE `id` = "' . $pl_usr [ 'id' ] . '" LIMIT 1'
);
bs_atack ( $pl , $a_pl , $pl_usr );
$a_pl [ 'battle' ] = 1 ;
}
}
}
unset ( $sp_usr , $pl_usr );
if ( $a_pl [ 'battle' ] == 0 && rand ( 0 , 100 ) < 71 && $a_pl [ 'timeGo' ] < time ()) {
2023-01-10 16:29:32 +00:00
//Передвигаемся
2022-08-25 11:23:36 +00:00
$stor = [];
if ( $xy [ 'up' ] > 0 ) {
$stor [] = 'up' ;
}
if ( $xy [ 'down' ] > 0 ) {
$stor [] = 'down' ;
}
if ( $xy [ 'left' ] > 0 ) {
$stor [] = 'left' ;
}
if ( $xy [ 'right' ] > 0 ) {
$stor [] = 'right' ;
}
$stor = $stor [ rand ( 0 , count ( $stor ) - 1 )];
if ( $stor == 'up' ) {
$stgo = $xy [ $stor ];
} elseif ( $stor == 'down' ) {
$stgo = $xy [ $stor ];
} elseif ( $stor == 'left' ) {
$stgo = $xy [ $stor ];
} elseif ( $stor == 'right' ) {
$stgo = $xy [ $stor ];
}
if ( $stgo == 1 ) {
if ( $stor == 'up' ) {
$a_pl [ 'x' ] -- ;
} elseif ( $stor == 'down' ) {
$a_pl [ 'x' ] ++ ;
} elseif ( $stor == 'left' ) {
$a_pl [ 'y' ] -- ;
} elseif ( $stor == 'right' ) {
$a_pl [ 'y' ] ++ ;
}
} else {
$stgo = mysql_fetch_array (
mysql_query (
'SELECT * FROM `bs_map` WHERE `id` = "' . $stgo . '" LIMIT 1'
)
);
if ( isset ( $stgo [ 'id' ])) {
$a_pl [ 'x' ] = $stgo [ 'x' ];
$a_pl [ 'y' ] = $stgo [ 'y' ];
}
}
mysql_query (
'UPDATE `stats` SET `x` = "' . $a_pl [ 'x' ] . '",`y` = "' . $a_pl [ 'y' ] . '" WHERE `id` = "' . $a_pl [ 'id' ] . '" LIMIT 1'
);
unset ( $stor , $stgo );
}
}
}
}
}
}
}
}
} elseif ( $pl [ 'status' ] == 0 && $pl [ 'time_start' ] < time ()) {
2023-01-10 16:29:32 +00:00
//Начинаем турнир
2022-12-19 21:15:56 +00:00
if ( ! nostart ( $pl )) {
2022-08-25 11:23:36 +00:00
2023-01-10 16:29:32 +00:00
//Начинаем турнир!
2022-08-25 11:23:36 +00:00
$spm = mysql_query ( 'SELECT `x`,`y` FROM `bs_map` WHERE `mid` = "' . $pl [ 'type_map' ] . '"' );
$maps = [];
while ( $plm = mysql_fetch_array ( $spm )) {
$maps [] = [ $plm [ 'x' ], $plm [ 'y' ]];
}
$i = 0 ;
$j = 0 ;
$usrlst = [];
$ubss = '' ;
$sp_u = mysql_query (
'SELECT * FROM `bs_zv` WHERE `finish` = "0" AND `bsid` = "' . $pl [ 'id' ] . '" ORDER BY `money` DESC LIMIT 12'
);
//
2023-01-10 16:29:32 +00:00
//Создаем поход
2022-08-25 11:23:36 +00:00
mysql_query (
' INSERT INTO `dungeon_now` (
2022-06-06 21:30:34 +00:00
`id2` , `name` , `time_start` , `time_finish` , `uid` , `city` , `type` , `bsid`
) VALUES (
2023-01-10 16:29:32 +00:00
" 6 " , " Башня Смерти " , " ' . $pl['time_start'] . ' " , " 0 " , " 0 " , " ' . $pl['city'] . ' " , " 0 " , " ' . $pl['id'] . ' "
2022-08-25 11:23:36 +00:00
) '
);
$dnew = mysql_insert_id ();
2023-01-10 16:29:32 +00:00
//Добавляем обьекты
2022-06-06 21:30:34 +00:00
$vls32 = '' ;
$sphj = mysql_query ( 'SELECT * FROM `dungeon_obj` WHERE `for_dn` = "6"' );
2022-08-25 11:23:36 +00:00
while ( $plhj = mysql_fetch_array ( $sphj )) {
$vls32 .= '("' . $dnew . '","' . $plhj [ 'name' ] . '","' . $plhj [ 'img' ] . '","' . $plhj [ 'x' ] . '","' . $plhj [ 'y' ] . '","' . $plhj [ 'action' ] . '","' . $plhj [ 'type' ] . '","' . $plhj [ 'w' ] . '","' . $plhj [ 'h' ] . '","' . $plhj [ 's' ] . '","' . $plhj [ 's2' ] . '","' . $plhj [ 'os1' ] . '","' . $plhj [ 'os2' ] . '","' . $plhj [ 'os3' ] . '","' . $plhj [ 'os4' ] . '","' . $plhj [ 'type2' ] . '","' . $plhj [ 'top' ] . '","' . $plhj [ 'left' ] . '","' . $plhj [ 'date' ] . '"),' ;
2022-06-06 21:30:34 +00:00
}
2022-08-25 11:23:36 +00:00
$vls32 = rtrim ( $vls32 , ',' );
if ( $vls32 != '' ) {
$ins232 = mysql_query (
'INSERT INTO `dungeon_obj` (`dn`,`name`,`img`,`x`,`y`,`action`,`type`,`w`,`h`,`s`,`s2`,`os1`,`os2`,`os3`,`os4`,`type2`,`top`,`left`,`date`) VALUES ' . $vls32 . ''
);
2022-06-06 21:30:34 +00:00
}
2022-08-25 11:23:36 +00:00
unset ( $vls32 , $ins232 );
2023-01-10 16:29:32 +00:00
//Добавляем предметы
2022-08-25 11:23:36 +00:00
$map = [];
$mapsp = mysql_query ( 'SELECT `x`,`y` FROM `dungeon_map` WHERE `id_dng` = 6' );
while ( $mappl = mysql_fetch_array ( $mapsp )) {
$map [] = [ 'x' => $mappl [ 'x' ], 'y' => $mappl [ 'y' ]];
}
$mapu = $map ;
//
$ii1 = 0 ;
while ( $ii1 < count ( $map )) {
2023-01-10 16:29:32 +00:00
//Н а каждой клетке в среднем 2 предмета
2022-08-25 11:23:36 +00:00
$itbsrnd = $itbs [ rand ( 0 , count ( $itbs ) - 1 )];
$mp = rand ( 0 , count ( $map ) - 1 );
//
$x1 = $map [ $mp ][ 'x' ];
$y1 = $map [ $mp ][ 'y' ];
//
mysql_query (
' INSERT INTO `dungeon_items` ( `dn` , `item_id` , `time` , `x` , `y` ) VALUES (
" ' . $dnew . ' " , " ' . $itbsrnd . ' " , " ' . (time() - 600) . ' " , " ' . $x1 . ' " , " ' . $y1 . ' "
) '
);
//
$ii1 ++ ;
}
2023-01-10 16:29:32 +00:00
//Добавляем чеки на кр. и на екр. на карту
2022-08-25 11:23:36 +00:00
$m1 = $maps [ rand ( 0 , count ( $maps ) - 1 )];
$x1 = round ( $m1 [ 0 ]);
$y1 = round ( $m1 [ 1 ]);
2023-01-10 16:29:32 +00:00
//$itm1 = array( 4174 , 4175 , 4176 , 4177 , 4178 , 4179 , 4180 ); //Перечисление кр. чеков
$itm1 = [ 4176 , 4177 ]; //Перечисление кр. чеков
2022-08-25 11:23:36 +00:00
$itm1 = $itm1 [ rand ( 0 , count ( $itm1 ) - 1 )];
if ( $itm1 > 0 ) {
//
$mp = rand ( 0 , count ( $map ) - 1 );
//
$x1 = $map [ $mp ][ 'x' ];
$y1 = $map [ $mp ][ 'y' ];
//
mysql_query (
' INSERT INTO `dungeon_items` ( `dn` , `item_id` , `time` , `x` , `y` ) VALUES (
" ' . $dnew . ' " , " ' . $itm1 . ' " , " ' . (time() - 600) . ' " , " ' . $x1 . ' " , " ' . $y1 . ' "
) '
);
//
2022-06-06 21:30:34 +00:00
}
2022-08-25 11:23:36 +00:00
2023-01-10 16:29:32 +00:00
//Добавляем монстров (Архивариусов)
2022-08-25 11:23:36 +00:00
$newkor = [];
while ( $pl_u = mysql_fetch_array ( $sp_u )) {
if ( $i < 12 && ! isset ( $usrlst [ $pl_u [ 'uid' ]])) {
2023-01-10 16:29:32 +00:00
//Действующие участники
2022-08-25 11:23:36 +00:00
$usrlst [ $pl_u [ 'uid' ]] = true ;
$bus = mysql_fetch_array (
mysql_query (
'SELECT `align`,`chatColor`,`molch1`,`molch2`,`id`,`login`,`clan`,`align`,`level`,`sex`,`online`,`room` FROM `users` WHERE `id` = "' . mysql_real_escape_string (
$pl_u [ 'uid' ]
) . '" LIMIT 1'
)
);
mysql_query (
'UPDATE `stats` SET `repexp` = `repexp` + 5 WHERE `id` = "' . $bus [ 'id' ] . '" LIMIT 1'
);
$bus [ 'login_BIG' ] = '<b>' ;
if ( $bus [ 'align' ] > 0 ) {
$bus [ 'login_BIG' ] .= '<img src=https://img.new-combats.com/i/align/align' . $bus [ 'align' ] . '.gif width=12 height=15 >' ;
}
if ( $bus [ 'clan' ] > 0 ) {
$bus [ 'login_BIG' ] .= '<img src=https://img.new-combats.com/i/clan/' . $bus [ 'clan' ] . '.gif width=24 height=15 >' ;
}
$bus [ 'login_BIG' ] .= '' . $bus [ 'login' ] . '</b>[' . $bus [ 'level' ] . ']<a target=_blank href=https://new-combats.com/info/' . $bus [ 'id' ] . ' ><img width=12 hiehgt=11 src=https://img.new-combats.com/i/inf_capitalcity.gif ></a>' ;
$ubss .= ', ' . $bus [ 'login_BIG' ];
//
2023-01-10 16:29:32 +00:00
//Вселяем персонажей в ботов
2022-08-25 11:23:36 +00:00
if ( $bus [ 'align' ] >= 1 && $bus [ 'align' ] < 2 ) {
$bus [ 'align' ] = 1 ;
} elseif ( $bus [ 'align' ] >= 3 && $bus [ 'align' ] < 4 ) {
$bus [ 'align' ] = 3 ;
} elseif ( $bus [ 'align' ] == 7 ) {
$bus [ 'align' ] = 7 ;
} else {
$bus [ 'align' ] = 0 ;
}
mysql_query (
2023-01-06 14:57:25 +00:00
' INSERT INTO `users` ( `chatColor` , `align` , `inTurnir` , `molch1` , `molch2` , `login` , `room` , `name` , `sex` , `level` , `bithday` ) VALUES (
" ' . $bus['chatColor'] . ' " , " ' . $bus['align'] . ' " , " ' . $pl['id'] . ' " , " ' . $bus['molch1'] . ' " , " ' . $bus['molch2'] . ' " , " ' . $bus['login'] . ' " , " 362 " , " ' . $bus['name'] . ' " , " ' . $bus['sex'] . ' " , " ' . $pl['level'] . ' " , " ' . date(
2022-08-25 11:23:36 +00:00
'd.m.Y'
) . '")'
);
//
2023-01-10 16:29:32 +00:00
$inbot = mysql_insert_id (); //айди бота
2022-08-25 11:23:36 +00:00
if ( $inbot > 0 ) {
2023-01-10 16:29:32 +00:00
//Бот
2022-08-25 11:23:36 +00:00
//
$mp = rand ( 0 , count ( $mapu ) - 1 );
$testxy = 0 ;
$jj = count ( $newkor );
if ( $i == 0 ) {
$x1 = $mapu [ $mp ][ 'x' ];
$y1 = $mapu [ $mp ][ 'y' ];
$newkor [ $i ][ 'x' ] = $mapu [ $mp ][ 'x' ];
$newkor [ $i ][ 'y' ] = $mapu [ $mp ][ 'y' ];
} else {
while ( $testxy < 1 ) {
$iii = 0 ;
while ( $iii < $jj ) {
if (( $newkor [ $iii ][ 'x' ] <= $mapu [ $mp ][ 'x' ] + 3 ) && ( $newkor [ $iii ][ 'x' ] >= $mapu [ $mp ][ 'x' ] - 3 ) && ( $newkor [ $iii ][ 'y' ] <= $mapu [ $mp ][ 'y' ] + 3 ) && ( $newkor [ $iii ][ 'y' ] >= $mapu [ $mp ][ 'y' ] - 3 )) {
$testxy = 1 ;
}
$iii ++ ;
}
if ( $testxy == 1 ) {
$mp = rand ( 0 , count ( $mapu ) - 1 );
$testxy = 0 ;
} else {
$testxy = 1 ;
$x1 = $mapu [ $mp ][ 'x' ];
$y1 = $mapu [ $mp ][ 'y' ];
$newkor [ $i ][ 'x' ] = $mapu [ $mp ][ 'x' ];
$newkor [ $i ][ 'y' ] = $mapu [ $mp ][ 'y' ];
}
}
}
//
unset ( $mapu [ $mp ]);
//
mysql_query (
' INSERT INTO `stats` ( `timeGo` , `timeGoL` , `upLevel` , `dnow` , `id` , `stats` , `exp` , `ability` , `skills` , `x` , `y` )
2022-06-06 21:30:34 +00:00
VALUES (
2022-08-25 11:23:36 +00:00
" ' . (time() + $cnfg['time_puti'] ) . ' " , " ' . (time(
) + $cnfg [ 'time_puti' ]) . '","98","' . $dnew . '","' . $inbot . ' " ,
" s1=3|s2=3|s3=3|s4=' . $st2s[$pl['level'] ][0] . '|s5=0|s6=0|rinv=40|m9=5|m6=10 " , " ' . $exp2[$pl['level'] ] . ' " ,
" ' . $st2s[$pl['level'] ][1] . ' " , " ' . $st2s[$pl['level'] ][2] . ' " , " ' . $x1 . ' " , " ' . $y1 . ' "
) '
);
mysql_query (
'UPDATE `users` SET `inUser` = "' . $inbot . '" WHERE `id` = "' . $bus [ 'id' ] . '" LIMIT 1'
);
}
2023-01-10 16:29:32 +00:00
//Добавляем путы
2022-08-25 11:23:36 +00:00
//
mysql_query (
' INSERT INTO `eff_users` ( `id_eff` , `uid` , `name` , `data` , `overType` , `timeUse` , `img2` ) VALUES (
2023-01-10 16:29:32 +00:00
" 2 " , " ' . $inbot . ' " , " Путы " , " add_speedhp=30000|add_speedmp=30000|puti=' . (time(
2022-08-25 11:23:36 +00:00
) + $cnfg [ 'time_puti' ]) . '","1","' . ( time () + $cnfg [ 'time_puti' ]) . ' " , " chains . gif "
) '
);
//
2023-01-10 16:29:32 +00:00
//Обновляем данные заявки БС
2022-08-25 11:23:36 +00:00
mysql_query (
'UPDATE `bs_zv` SET `finish` = "' . time (
) . '",`inBot` = "' . $inbot . '" WHERE `id` = "' . $pl_u [ 'id' ] . '" LIMIT 1'
);
//
unset ( $bus [ 'login_BIG' ]);
$i ++ ;
}
$j ++ ;
}
unset ( $sp_u , $pl_u , $bus , $usrlst , $testxy , $iii , $jj );
2023-01-10 16:29:32 +00:00
//Выбираем тип БС
2022-08-25 11:23:36 +00:00
$pl [ 'type_btl' ] = 0 ;
//
$m1 = $maps [ rand ( 0 , count ( $maps ) - 1 )];
$x1 = round ( $m1 [ 0 ]);
$y1 = round ( $m1 [ 1 ]);
//
unset ( $mis , $m1 , $x1 , $y1 , $i2 );
//
$ubss = ltrim ( $ubss , ', ' );
//
2023-01-10 16:29:32 +00:00
//Обновление статуса Башни Смерти и удаление заявок
2022-08-25 11:23:36 +00:00
mysql_query (
'UPDATE `bs_turnirs` SET `type_btl` = "' . $pl [ 'type_btl' ] . '", `status` = "1", `users` = "' . $i . '", `arhiv` = "' . $pl [ 'arhiv' ] . '", `users_finish` = "0" WHERE `id` = "' . $pl [ 'id' ] . '" LIMIT 1'
);
mysql_query (
'UPDATE `bs_zv` SET `finish` = "' . time (
) . '" WHERE `bsid` = "' . $pl [ 'id' ] . '" AND `finish` = "0" AND `inBot` = "0"'
);
2023-01-10 16:29:32 +00:00
//Добавляем в лог БС
$text = 'Начало турнира. Участники: ' . $ubss ;
2022-08-25 11:23:36 +00:00
mysql_query (
' INSERT INTO `bs_logs` ( `type` , `text` , `time` , `id_bs` , `count_bs` , `city` , `m` , `u` ) VALUES (
" 1 " , " ' . mysql_real_escape_string( $text ) . ' " , " ' . time(
) . '", "' . $pl [ 'id' ] . '", "' . $pl [ 'count' ] . '", "' . $pl [ 'city' ] . ' " ,
" ' . round( $pl['money'] * 0.85, 2) . ' " , " ' . $i . ' "
) '
);
//
2023-01-10 16:29:32 +00:00
e ( 'Начался турнир , для ' . $pl [ 'to_lvl' ] . ' уровней в <b>Башне Смерти</b>. Участники: ' . $ubss . '.' );
2022-08-25 11:23:36 +00:00
}
} else {
2023-01-10 16:29:32 +00:00
//Оповещаем участников о начале турнира за 60 мин., а так-же за 10 мин.
2022-08-25 11:23:36 +00:00
if ( $pl [ 'status' ] == 0 ) {
if ( $pl [ 'ch1' ] == 0 && $pl [ 'time_start' ] - 60 * 60 < time ()) {
mysql_query ( 'UPDATE `bs_turnirs` SET `ch1` = `ch1` + 1 WHERE `id` = "' . $pl [ 'id' ] . '" LIMIT 1' );
} elseif ( $pl [ 'ch1' ] == 1 && $pl [ 'time_start' ] - 10 * 60 < time ()) {
mysql_query ( 'UPDATE `bs_turnirs` SET `ch1` = `ch1` + 1 WHERE `id` = "' . $pl [ 'id' ] . '" LIMIT 1' );
e (
2023-01-10 16:29:32 +00:00
'Начало турнира, для ' . $pl [ 'to_lvl' ] . ' уровней в <b>Башне Смерти</b> через ' . timeOut (
2022-08-25 11:23:36 +00:00
$pl [ 'time_start' ] - time ()
) . ' (<small>' . date (
'd.m.Y H:i' , $pl [ 'time_start' ]
2023-01-10 16:29:32 +00:00
) . '</small>), текущий призовой фонд: ' . round (
2022-08-25 11:23:36 +00:00
$pl [ 'money' ] * 0.85 , 2
2023-01-10 16:29:32 +00:00
) . ' кр., <b>1.00</b> Екр., заявок: ' . $pl [ 'users' ] . ''
2022-08-25 11:23:36 +00:00
);
}
}
}
2022-06-06 21:30:34 +00:00
}
echo '#finish#' ;