1067 lines
49 KiB
PHP
1067 lines
49 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Áàøíÿ ñìåðòè?
|
|
*
|
|
* Âûçîâ ðàç â ìèíóòó.
|
|
*/
|
|
|
|
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'autoload.php';
|
|
|
|
//todo: IN PROGRESS
|
|
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'
|
|
);
|
|
}
|
|
}
|
|
|
|
//Âðåìÿ ðåñòàðòà
|
|
$cnfg = [
|
|
'time_restart' => 1,
|
|
'time_puti' => 240,
|
|
];
|
|
|
|
echo '#start#';
|
|
|
|
$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'];
|
|
}
|
|
|
|
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'
|
|
)
|
|
);
|
|
//íîâàÿ äàòà
|
|
$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;
|
|
}
|
|
|
|
|
|
//ïðåäìåò ñ íàñòðîéêàìè èç ïîäçåìåëüÿ
|
|
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'] . '",
|
|
"capitalcity",
|
|
"' . time() . '",
|
|
"' . time() . '",
|
|
"' . $i['dn_delete'] . '")'
|
|
);
|
|
if ($ins) {
|
|
$rt = mysql_insert_id();
|
|
} else {
|
|
$rt = 0;
|
|
}
|
|
}
|
|
return $rt;
|
|
}
|
|
|
|
|
|
function timeOut($ttm)
|
|
{
|
|
$out = '';
|
|
$time_still = $ttm;
|
|
$tmp = floor($time_still / 2592000);
|
|
$id = 0;
|
|
if ($tmp > 0) {
|
|
$id++;
|
|
if ($id < 3) {
|
|
$out .= $tmp . " ìåñ. ";
|
|
}
|
|
$time_still = $time_still - $tmp * 2592000;
|
|
}
|
|
$tmp = floor($time_still / 86400);
|
|
if ($tmp > 0) {
|
|
$id++;
|
|
if ($id < 3) {
|
|
$out .= $tmp . " äí. ";
|
|
}
|
|
$time_still = $time_still - $tmp * 86400;
|
|
}
|
|
$tmp = floor($time_still / 3600);
|
|
if ($tmp > 0) {
|
|
$id++;
|
|
if ($id < 3) {
|
|
$out .= $tmp . " ÷. ";
|
|
}
|
|
$time_still = $time_still - $tmp * 3600;
|
|
}
|
|
$tmp = floor($time_still / 60);
|
|
if ($tmp > 0) {
|
|
$id++;
|
|
if ($id < 3) {
|
|
$out .= $tmp . " ìèí. ";
|
|
}
|
|
}
|
|
if ($out == '') {
|
|
if ($time_still < 0) {
|
|
$time_still = 0;
|
|
}
|
|
$out = $time_still . ' ñåê.';
|
|
}
|
|
return $out;
|
|
}
|
|
|
|
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() . '")'
|
|
);
|
|
}
|
|
|
|
function e2($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","-1")'
|
|
);
|
|
}
|
|
|
|
//Ïåðñîíàæ 1 íàïàäàåò íà 2
|
|
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) {
|
|
//Çàíîñèì â ëîã ÁÑ
|
|
if ($u1['sex'] == 0) {
|
|
$text = '{u1} âìåøàëñÿ â ïîåäèíîê ïðîòèâ {u2} <a target=_blank href=/logs.php?log=' . $btl_id . ' >»»</a>';
|
|
} else {
|
|
$text = '{u1} âìåøàëàñü â ïîåäèíîê ïðîòèâ {u2} <a target=_blank href=/logs.php?log=' . $btl_id . ' >»»</a>';
|
|
}
|
|
} else {
|
|
//Çàíîñèì â ëîã ÁÑ
|
|
if ($u1['sex'] == 0) {
|
|
$text = '{u1} íàïàë íà {u2} çàâÿçàëñÿ áîé <a target=_blank href=/logs.php?log=' . $btl_id . ' >»»</a>';
|
|
} else {
|
|
$text = '{u1} íàïàëà íà {u2} çàâÿçàëñÿ áîé <a target=_blank href=/logs.php?log=' . $btl_id . ' >»»</a>';
|
|
}
|
|
}
|
|
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 {
|
|
$mereal = '<i>Íåâèäèìêà</i>[??]';
|
|
}
|
|
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 {
|
|
$mereal = '<i>Íåâèäèìêà</i>[??]';
|
|
}
|
|
$text = str_replace('{u1}', $mereal, $text);
|
|
$text = str_replace('{u2}', $usrreal, $text);
|
|
//Äîáàâëÿåì â ëîã ÁÑ
|
|
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 . '"
|
|
)'
|
|
);
|
|
}
|
|
}
|
|
|
|
//Òóðíèð íå ñîñòîÿëñÿ
|
|
function nostart($pl)
|
|
{
|
|
global $cnfg;
|
|
$r = false;
|
|
if ($pl['users'] < 4) {
|
|
//Íåäîñòàòî÷íî èãðîêîâ
|
|
$r = true;
|
|
$pl['time_start'] = time() + $cnfg['time_restart'] * (60 * 60);
|
|
if ($pl['users'] > 0) {
|
|
e(
|
|
'Òóðíèð Áàøíè Ñìåðòè, äëÿ ' . $pl['to_lvl'] . ' óðîâíåé â <b>Áàøíå Ñìåðòè</b> íå íà÷àëñÿ ïî ïðè÷èíå: Íåäîñòàòî÷íî ó÷àñòíèêîâ ' . timeOut(
|
|
$pl['time_start'] - time()
|
|
) . ' (<small>' . date('d.m.Y H:i', $pl['time_start']) . '</small>)'
|
|
);
|
|
} else {
|
|
e(
|
|
'Íà÷àëî òóðíèðà Áàøíè Ñìåðòè, äëÿ ' . $pl['to_lvl'] . ' óðîâíåé â <b>Áàøíå Ñìåðòè</b> ÷åðåç ' . timeOut(
|
|
$pl['time_start'] - time()
|
|
) . ' (<small>' . date(
|
|
'd.m.Y H:i', $pl['time_start']
|
|
) . '</small>), òåêóùèé ïðèçîâîé ôîíä: 0.00 êð., <b>1.00</b> Åêð., çàÿâîê: 0'
|
|
);
|
|
}
|
|
//Âîçâðàò âêëàäîâ èãðîêîâ
|
|
$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');
|
|
}
|
|
//Îáíîâëåíèå òóðíèðà
|
|
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;
|
|
}
|
|
|
|
//Äîáàâëåíèå "àðõèâàðèóñà"
|
|
function add_arhiv($pl, $user)
|
|
{
|
|
$return = 0;
|
|
mysql_query(
|
|
'INSERT INTO `users` (`login`,`pass`,`level`,`inTurnir`,`sex`,`obraz`,`name`,`online`,`city`,`room`,`align`,`clan`,`cityreg`,`bithday`) VALUES (
|
|
"' . $user['login'] . '","bstowerbot","' . $user['level'] . '","' . $pl['id'] . '","' . $user['sex'] . '","' . $user['obraz'] . '","' . $user['login'] . '","' . (time(
|
|
) + 60 * 60 * 24) . '","' . $user['city'] . '","' . $user['room'] . '","' . $user['align'] . '","' . $user['clan'] . '","capitalcity","01.02.2003",
|
|
)'
|
|
);
|
|
$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;
|
|
}
|
|
|
|
//Çàâåðøàåì òåêóùèé òóðíèð
|
|
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)) {
|
|
//Óäàëåíèå êëîíà
|
|
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'] . '"');
|
|
//Îáíîâëåíèå ïåðñîíàæà
|
|
mysql_query('UPDATE `users` SET `inUser` = "0" WHERE `id` = "' . $pu['uid'] . '" LIMIT 1');
|
|
//Îáíîâëÿåì çàÿâêó
|
|
mysql_query('UPDATE `bs_zv` SET `off` = "' . time() . '" WHERE `id` = "' . $pu['id'] . '" LIMIT 1');
|
|
}
|
|
//Àðõèâàðèóñû
|
|
$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'] . '"');
|
|
}
|
|
//Óäàëÿåì ïðåäìåòû ðàñêèäàííûå ïî ÁÑ
|
|
mysql_query('DELETE FROM `bs_items` WHERE `bid` = "' . $pl['id'] . '" AND `count` = "' . $pl['count'] . '"');
|
|
//Óäàëÿåì ñîáûòèÿ â ÁÑ
|
|
mysql_query('DELETE FROM `bs_actions` WHERE `bid` = "' . $pl['id'] . '" AND `count` = "' . $pl['count'] . '"');
|
|
//Óäàëÿåì ëîâóøêè â ÁÑ
|
|
mysql_query('DELETE FROM `bs_trap` WHERE `bid` = "' . $pl['id'] . '" AND `count` = "' . $pl['count'] . '"');
|
|
}
|
|
|
|
$exp2 = [
|
|
1 => 30000,
|
|
2 => 300000,
|
|
];
|
|
$st2s = [
|
|
7 => [
|
|
0 => 10,
|
|
1 => 64,
|
|
2 => 8,
|
|
],
|
|
8 => [
|
|
0 => 11,
|
|
1 => 78,
|
|
2 => 9,
|
|
],
|
|
];
|
|
|
|
$sp = mysql_query('SELECT * FROM `bs_turnirs`');
|
|
while ($pl = mysql_fetch_array($sp)) {
|
|
//
|
|
$pl['to_lvl'] = $pl['level'];
|
|
if ($pl['level'] != $pl['level_max']) {
|
|
$pl['to_lvl'] .= '-' . $pl['level_max'] . '';
|
|
}
|
|
$pl['to_lvl'] = 'âñåõ';
|
|
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) {
|
|
//×òî-òî ñáèëîñü
|
|
$pl['users'] = $tcu;
|
|
}
|
|
//
|
|
//Òóðíèð èäåò, ïðîâåðÿåì æèâûõ èãðîêîâ, ëèáî çàâåðøàåì ÷åðåç 6 ÷àñîâ
|
|
if ($pl['time_start'] < time() - 6 * 60 * 60) {
|
|
//Çàâåðøàåì òóðíèð ïî òàéìó
|
|
//Äîáàâëÿåì â ëîã ÁÑ
|
|
$text = 'Òóðíèð çàâåðøåí. Ïîáåäèòåëü: <i>Îòñóòñòâóåò</i> (Òóðíèð çàâåðøèëñÿ ïî òàéìàóòó). Ïðèçîâîé ôîíä: <b>' . round(
|
|
$pl['money'] * 0.85, 2
|
|
) . '</b> êð.';
|
|
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 . '"
|
|
)'
|
|
);
|
|
//
|
|
//Ñîõðàíÿåì ñòàòèñòèêó
|
|
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) . '",
|
|
"2","0","0","0"
|
|
)'
|
|
);
|
|
$pl['time_start'] = time() + $cnfg['time_restart'] * (60 * 60);
|
|
e(
|
|
'Òóðíèð äëÿ ' . $pl['to_lvl'] . ' óðîâíåé â <b>Áàøíå Ñìåðòè</b> çàâåðøèëñÿ ïî òàéìàóòó. Íà÷àëî íîâîãî òóðíèðà ÷åðåç ' . timeOut(
|
|
$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'])
|
|
);
|
|
//Ïðîâåðÿåì æèâûõ èãðîêîâ
|
|
if ($pl['users'] < 2) {
|
|
mysql_query(
|
|
'DELEE FROM `users` WHERE `login` LIKE "%(êëîí%" AND `inTurnir` = "' . $pl['id'] . '" AND `room` = "362"'
|
|
);
|
|
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'];
|
|
}
|
|
}
|
|
//Äîï. ïðîâåðêà æèâûõ
|
|
if ($pl['users'] == 1) {
|
|
//Çàâåðøàåì òóðíèð, åñòü 1 ïîáåäèòåëü
|
|
if ($pl['arhiv'] == 0) {
|
|
//Àðõèâàðèóñà íåò, çàâåðøàåì òóðíèð
|
|
$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')
|
|
);
|
|
|
|
//Îïûò
|
|
$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;
|
|
|
|
//Ñîõðàíÿåì ñòàòèñòèêó
|
|
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(
|
|
'#' . $pl['usersn'] . ' Òóðíèð äëÿ ' . $pl['to_lvl'] . ' óðîâíåé â <b>Áàøíå Ñìåðòè</b> çàâåðøèëñÿ. Ïîáåäèòåëü: ' . microLogin2(
|
|
$uwin
|
|
) . '. Ïðèç: <b>' . round(
|
|
$pl['money'] * 0.85, 2
|
|
) . '</b> êð. è <b>1</b> åêð.<b>' . round(
|
|
$swin_bot['exp']
|
|
) . '</b> îïûòà. Íà÷àëî íîâîãî òóðíèðà ÷åðåç ' . timeOut(
|
|
$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'
|
|
);
|
|
}
|
|
}
|
|
//Äîáàâëÿåì â ëîã ÁÑ
|
|
$text = 'Òóðíèð çàâåðøåí. Ïîáåäèòåëü: ' . microLogin2($uwin) . '. Ïðèç: <b>' . round(
|
|
$pl['money'] * 0.85, 2
|
|
) . '</b> êð. è 1 åêð.<b>' . round($swin_bot['exp']) . '</b> îïûòà.';
|
|
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 {
|
|
//Îæèäàåì ïîêà èãðîê óáüåò Àðõèâàðèóñà
|
|
|
|
}
|
|
} else {
|
|
//Ñîõðàíÿåì ñòàòèñòèêó
|
|
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
|
|
) . '",
|
|
"1","0","0","0"
|
|
)'
|
|
);
|
|
//Ïðîñòî çàâåðøàåì òóðíèð, íè÷üÿ
|
|
$pl['time_start'] = time() + $cnfg['time_restart'] * (60 * 60);
|
|
//Äîáàâëÿåì â ëîã ÁÑ
|
|
$text = 'Òóðíèð çàâåðøåí. Ïîáåäèòåëü: <i>Îòñóòñòâóåò</i> (Íèêòî íå îñòàëñÿ â æèâûõ). Ïðèçîâîé ôîíä: <b>' . round(
|
|
$pl['money'] * 0.85, 2
|
|
) . '</b> êð.';
|
|
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(
|
|
'Òóðíèð äëÿ ' . $pl['to_lvl'] . ' óðîâíåé â <b>Áàøíå Ñìåðòè</b> çàâåðøèëñÿ. Ïîáåäèòåëü: <i>Îòñóòñòâóåò</i> (Íèêòî íå îñòàëñÿ â æèâûõ). Ïðèçîâîé ôîíä <b>' . round(
|
|
$pl['money'] * 0.85, 2
|
|
) . '</b> êð. Íà÷àëî íîâîãî òóðíèðà ÷åðåç ' . timeOut(
|
|
$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 {
|
|
//Âñå æèâû
|
|
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) {
|
|
//Ïîäíèìàåì ïðåäìåòû
|
|
$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) {
|
|
//Ïîäíèìàåì òåêóùèé ïðåäìåò
|
|
$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) {
|
|
//íàäåâàåì
|
|
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);
|
|
//Íàïàäàåì/Âìåøèâàåìñÿ â ïîåäèíîê
|
|
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()) {
|
|
//Ïåðåäâèãàåìñÿ
|
|
$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()) {
|
|
//Íà÷èíàåì òóðíèð
|
|
if (!nostart($pl)) {
|
|
|
|
//Íà÷èíàåì òóðíèð!
|
|
$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'
|
|
);
|
|
//
|
|
//Ñîçäàåì ïîõîä
|
|
mysql_query(
|
|
'INSERT INTO `dungeon_now` (
|
|
`id2` , `name` , `time_start` , `time_finish` , `uid` , `city` , `type` , `bsid`
|
|
) VALUES (
|
|
"6" , "Áàøíÿ Ñìåðòè" , "' . $pl['time_start'] . '" , "0" , "0" , "' . $pl['city'] . '" , "0" , "' . $pl['id'] . '"
|
|
)'
|
|
);
|
|
$dnew = mysql_insert_id();
|
|
//Äîáàâëÿåì îáüåêòû
|
|
$vls32 = '';
|
|
$sphj = mysql_query('SELECT * FROM `dungeon_obj` WHERE `for_dn` = "6"');
|
|
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'] . '"),';
|
|
}
|
|
$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 . ''
|
|
);
|
|
}
|
|
unset($vls32, $ins232);
|
|
//Äîáàâëÿåì ïðåäìåòû
|
|
$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)) {
|
|
//Íà êàæäîé êëåòêå â ñðåäíåì 2 ïðåäìåòà
|
|
$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++;
|
|
}
|
|
|
|
//Äîáàâëÿåì ÷åêè íà êð. è íà åêð. íà êàðòó
|
|
$m1 = $maps[rand(0, count($maps) - 1)];
|
|
$x1 = round($m1[0]);
|
|
$y1 = round($m1[1]);
|
|
//$itm1 = array( 4174 , 4175 , 4176 , 4177 , 4178 , 4179 , 4180 ); //Ïåðå÷èñëåíèå êð. ÷åêîâ
|
|
$itm1 = [4176, 4177]; //Ïåðå÷èñëåíèå êð. ÷åêîâ
|
|
$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 . '"
|
|
)'
|
|
);
|
|
//
|
|
}
|
|
|
|
//Äîáàâëÿåì ìîíñòðîâ (Àðõèâàðèóñîâ)
|
|
$newkor = [];
|
|
while ($pl_u = mysql_fetch_array($sp_u)) {
|
|
if ($i < 12 && !isset($usrlst[$pl_u['uid']])) {
|
|
//Äåéñòâóþùèå ó÷àñòíèêè
|
|
$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'];
|
|
//
|
|
//Âñåëÿåì ïåðñîíàæåé â áîòîâ
|
|
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(
|
|
'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(
|
|
'd.m.Y'
|
|
) . '")'
|
|
);
|
|
//
|
|
$inbot = mysql_insert_id(); //àéäè áîòà
|
|
if ($inbot > 0) {
|
|
//Áîò
|
|
//
|
|
$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`)
|
|
VALUES (
|
|
"' . (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'
|
|
);
|
|
}
|
|
//Äîáàâëÿåì ïóòû
|
|
//
|
|
mysql_query(
|
|
'INSERT INTO `eff_users` (`id_eff`,`uid`,`name`,`data`,`overType`,`timeUse`,`img2`) VALUES (
|
|
"2","' . $inbot . '","Ïóòû","add_speedhp=30000|add_speedmp=30000|puti=' . (time(
|
|
) + $cnfg['time_puti']) . '","1","' . (time() + $cnfg['time_puti']) . '","chains.gif"
|
|
) '
|
|
);
|
|
//
|
|
//Îáíîâëÿåì äàííûå çàÿâêè ÁÑ
|
|
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);
|
|
//Âûáèðàåì òèï ÁÑ
|
|
$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, ', ');
|
|
//
|
|
//Îáíîâëåíèå ñòàòóñà Áàøíè Ñìåðòè è óäàëåíèå çàÿâîê
|
|
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"'
|
|
);
|
|
//Äîáàâëÿåì â ëîã ÁÑ
|
|
$text = 'Íà÷àëî òóðíèðà. Ó÷àñòíèêè: ' . $ubss;
|
|
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 . '"
|
|
)'
|
|
);
|
|
//
|
|
e('Íà÷àëñÿ òóðíèð , äëÿ ' . $pl['to_lvl'] . ' óðîâíåé â <b>Áàøíå Ñìåðòè</b>. Ó÷àñòíèêè: ' . $ubss . '.');
|
|
}
|
|
} else {
|
|
//Îïîâåùàåì ó÷àñòíèêîâ î íà÷àëå òóðíèðà çà 60 ìèí., à òàê-æå çà 10 ìèí.
|
|
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(
|
|
'Íà÷àëî òóðíèðà, äëÿ ' . $pl['to_lvl'] . ' óðîâíåé â <b>Áàøíå Ñìåðòè</b> ÷åðåç ' . timeOut(
|
|
$pl['time_start'] - time()
|
|
) . ' (<small>' . date(
|
|
'd.m.Y H:i', $pl['time_start']
|
|
) . '</small>), òåêóùèé ïðèçîâîé ôîíä: ' . round(
|
|
$pl['money'] * 0.85, 2
|
|
) . ' êð., <b>1.00</b> Åêð., çàÿâîê: ' . $pl['users'] . ''
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
echo '#finish#';
|