Перенос крон-задач по Башне Смерти в отдельный файл.

This commit is contained in:
Igor Barkov [iwork] 2018-12-13 18:18:31 +02:00
parent f057b5b410
commit 7972ce9a56
3 changed files with 229 additions and 232 deletions

View File

@ -106,73 +106,18 @@ function startbattle($id, $zay, $r)
}
}
function enter_bs($u)
{
$pers = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $u . '" LIMIT 1'));
undressall($pers['id']);
###
mysql_query('UPDATE `inventory` SET `owner` = "' . ($pers['id'] + _BOTSEPARATOR_) . '" WHERE `owner` = "' . $pers['id'] . '"');
###
###
$efs = mysql_query('SELECT * FROM `effects` WHERE `owner` = "' . $pers['id'] . '"');
$travm = [11, 12, 13, 14];
while ($row = mysql_fetch_array($efs)) {
if (in_array($row['type'], $travm)) {
$pers['sila'] += $row['sila'];
$pers['lovk'] += $row['lovk'];
$pers['inta'] += $row['inta'];
$pers['vinos'] += $row['vinos'];
} else {
$pers['sila'] -= $row['sila'];
$pers['lovk'] -= $row['lovk'];
$pers['inta'] -= $row['inta'];
$pers['vinos'] -= $row['vinos'];
$pers['maxhp'] -= $row['hp'];
}
$row['owner'] = ($user['id'] + _BOTSEPARATOR_);
mysql_query('UPDATE `effects` SET `owner` = "' . $row['owner'] . '" WHERE `id` = "' . $row['id'] . '" LIMIT 1');
mysql_query('UPDATE `users` SET `sila` = "' . $pers['sila'] . '", `lovk` = "' . $pers['lovk'] . '", `inta` = "' . $pers['inta'] . '", `vinos` = "' . $pers['vinos'] . '", `maxhp` = "' . $pers['maxhp'] . '" WHERE `id` = "' . $pers['id'] . '" LIMIT 1');
}
$udata = mysql_fetch_array(mysql_query('SELECT * FROM `deztow_realchars` WHERE `owner` = "' . $pers['id'] . '" LIMIT 1'));
if (isset($udata['id'])) {
$udata['sila'] = $pers['sila'];
$udata['lovk'] = $pers['lovk'];
$udata['inta'] = $pers['inta'];
$udata['vinos'] = $pers['vinos'];
$udata['maxhp'] = $pers['maxhp'];
$udata['money'] = $pers['money'];
$udata['level'] = $pers['level'];
$udata['exp'] = $pers['exp'];
$udata['nextup'] = $pers['nextup'];
$udata['align'] = $pers['align'];
$udata['stats'] = $pers['stats'];
$udata['master'] = $pers['master'];
$udata['intel'] = $pers['intel'];
$udata['noj'] = $pers['noj'];
$udata['mec'] = $pers['mec'];
$udata['topor'] = $pers['topor'];
$udata['dubina'] = $pers['dubina'];
$udata['mlight'] = $pers['mlight'];
$udata['mgray'] = $pers['mgray'];
$udata['mdark'] = $pers['mdark'];
mysql_query('UPDATE `deztow_realchars` SET `sila` = "' . $udata['sila'] . '", `lovk` = "' . $udata['lovk'] . '", `inta` = "' . $udata['inta'] . '", `vinos` = "' . $udata['vinos'] . '", `maxhp` = "' . $udata['maxhp'] . '", `money` = "' . $udata['money'] . '", `intel` = "' . $udata['intel'] . '", `level` = "' . $udata['level'] . '", `exp` = "' . $udata['exp'] . '", `nextup` = "' . $udata['nextup'] . '", `align` = "' . $udata['align'] . '", `stats` = "' . $udata['stats'] . '", `master` = "' . $udata['master'] . '", `noj` = "' . $udata['noj'] . '", `mec` = "' . $udata['mec'] . '", `topor` = "' . $udata['topor'] . '", `dubina` = "' . $udata['dubina'] . '", `mlight` = "' . $udata['mlight'] . '", `mgray` = "' . $udata['mgray'] . '", `mdark` = "' . $udata['mdark'] . '" WHERE `owner` = "' . $udata['id'] . '" LIMIT 1');
} else {
mysql_query('INSERT INTO `deztow_realchars` (`owner`, `sila`, `lovk`, `inta`, `vinos`, `maxhp`, `intel`, `level`, `money`, `exp`, `nextup`, `align`, `stats`, `master`, `noj`, `mec`, `topor`, `dubina`, `mlight`, `mgray`, `mdark`) VALUES ("' . $pers['id'] . '", "' . $pers['sila'] . '", "' . $pers['lovk'] . '", "' . $pers['inta'] . '", "' . $pers['vinos'] . '", "' . $pers['maxhp'] . '", "' . $pers['intel'] . '", "' . $pers['level'] . '", "' . $pers['money'] . '", "' . $pers['exp'] . '", "' . $pers['nextup'] . '", "' . $pers['align'] . '", "' . $pers['stats'] . '", "' . $pers['master'] . '", "' . $pers['noj'] . '", "' . $pers['mec'] . '", "' . $pers['topor'] . '", "' . $pers['dubina'] . '", "' . $pers['mlight'] . '", "' . $pers['mgray'] . '", "' . $pers['mdark'] . '")');
}
}
// Групповой/хаотический бой накрылся потому что меньше 4 человек.
if ($z['type'] == 3 || $z['type'] == 5) {
if ($count_users < 4) {
mysql_query("UPDATE `users` SET `zayavka` = '0' WHERE `zayavka` = '" . $zay . "'");
db::c()->query('UPDATE `users` SET `zayavka` = 0 WHERE `zayavka` = ?i', $zay);
foreach ($z['team1'] as $k => $v) {
if ($v < _BOTSEPARATOR_) {
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=6&user=' . $v);
// Сообщение в чат: Ваш бой не может начаться, группа не набрана.
file_get_contents(GAMEDOMAIN . '/chats.php?id=6&user=' . $v);
}
}
mysql_query("UPDATE `variables` SET `value` = '{$count_users}}' WHERE `var` = 'haos_match' LIMIT 1");
mysql_query("DELETE FROM `zayavka` WHERE `id` = '" . $zay . "' LIMIT 1");
db::c()->query('UPDATE `variables` SET `value` = "?s" WHERE `var` = "?s"', $count_users, 'haos_match');
db::c()->query('DELETE FROM `zayavka` WHERE `id` = ?i', $zay);
}
$all = count($z['team1']) - 1;
@ -236,7 +181,7 @@ function startbattle($id, $zay, $r)
if (count($z['team2']) == 0) {
mysql_query("UPDATE `users` SET `zayavka` = 0 WHERE `zayavka` = '" . $zay . "'");
foreach ($z['team1'] as $k => $v) {
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=6&user=' . $v);
file_get_contents(GAMEDOMAIN . '/chats.php?id=6&user=' . $v);
}
mysql_query("DELETE FROM `zayavka` WHERE `id` = '" . $zay . "' LIMIT 1");
die();
@ -315,7 +260,7 @@ if (!isset($battle_bots['id']) && !isset($zay_bots['id'])) {
$haos_match[$lvl] = mysql_insert_id();
}
}
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=1');
file_get_contents(GAMEDOMAIN . '/chats.php?id=1');
}
########End Заявки для ботов в хаоты########
@ -340,7 +285,7 @@ if (date("H-i") == "03-00") {
mysql_query("OPTIMIZE `battle`, `delo`");
}
// Снятие VIP.
// Снятие VIP. Раз в день, полночь.
if (date("H-i") == "00-00") {
$q = db::c()->query('SELECT `id`,`vip`,`vip_time` FROM `users` WHERE `vip` > 0 AND `vip_time` > 0');
@ -372,11 +317,14 @@ while ($pl = $sp->fetch_assoc()) {
mysql_query('UPDATE `actions` SET `vals` = "end" WHERE `vars` LIKE "start_quest%" AND `vals` = "go" AND `val` <= "' . time() . '"');
// Раз в день. 6 утра.
if (date("H-i") == "06-00") {
// Первое число каждого месяца.
if (date("d") == "01") {
mysql_query("UPDATE `variables` SET `value` = '{$tm}' WHERE `var` = 'ref_month' LIMIT 1");
mysql_query("UPDATE `variables` SET `value` = '0' WHERE `var` = 'ref_m_id' LIMIT 1");
}
// Каждый седьмой день недели.
if (date("N") == "7") {
mysql_query("UPDATE `variables` SET `value` = '{$tm}' WHERE `var` = 'ref_week' LIMIT 1");
mysql_query("UPDATE `variables` SET `value` = '0' WHERE `var` = 'ref_w_id' LIMIT 1");
@ -402,13 +350,13 @@ if ($st_ar['value'] <= time()) {
$rr = "<b>" . nick::id($dark['id_at'])->full(1) . "</b> и <b>" . nick::id($light['id_at'])->full(1) . "</b>";
addlog($id, "Часы показывали <span class=date>" . date("Y.m.d H.i") . "</span>, когда " . $rr . " бросили вызов друг другу. <br />");
mysql_query("UPDATE `users` SET `battle` = {$id}, `zayavka` = 0 WHERE (`id` = {$dark['id']} OR `id` = {$light['id']}) LIMIT 2");
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=2');
file_get_contents(GAMEDOMAIN . '/chats.php?id=2');
mysql_query('UPDATE `variables` SET `value` = "' . (time() + 60 * 60 * 24 * 7) . '" WHERE `var` = "arena_of_gods" LIMIT 1');
}
$st_ar['value'] -= 3600;
if (date("z-H-i") == date("z-H-i", $st_ar['value'])) {
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=3');
file_get_contents(GAMEDOMAIN . '/chats.php?id=3');
}
$komp_users = mysql_query("SELECT * FROM `users`, `online` WHERE `users`.`id` = `online`.`id` AND `online`.`date` >= " . (time() - 60) . "");
@ -421,10 +369,10 @@ while ($ku = mysql_fetch_array($komp_users)) {
mysql_query("UPDATE `users` SET `maxhp` = (IFNULL((SELECT SUM(`ghp`) FROM `inventory` WHERE `dressed` = 1 AND `owner` = `users`.`id`),0) + (`users`.`vinos`*6)+$bns) WHERE `id` = '{$ku['id']}'");
}
mysql_query("UPDATE `users` SET `hp` = 0 WHERE `hp` < 0");
mysql_query("UPDATE `users` SET `mana` = 0 WHERE `mana` < 0");
db::c()->query('UPDATE `users` SET `hp` = 0 WHERE `hp` < 0');
db::c()->query('UPDATE `users` SET `mana` = 0 WHERE `mana` < 0');
$its = mysql_query("SELECT `id`, `owner`, `name` FROM `inventory` WHERE `dressed` = 0 AND ((`maxdur` <= `duration`) OR (`dategoden` > 0 AND `dategoden` <= '" . time() . "'))");
$its = mysql_query("SELECT `id`, `owner`, `name` FROM `inventory` WHERE AND ((`maxdur` <= `duration`) OR (`dategoden` > 0 AND `dategoden` <= '" . time() . "'))");
while ($it = mysql_fetch_array($its)) {
mysql_query("DELETE FROM `inventory` WHERE `id` = '" . $it['id'] . "' LIMIT 1;");
mysql_query("INSERT INTO `delo` (`author`, `pers`, `text`, `type`, `date`) VALUES ('0', '" . $it['owner'] . "' '\"" . $it['name'] . "\" разрушился id:(cap" . $it['id'] . ").', 1, '" . time() . "')");
@ -472,155 +420,4 @@ while ($pl = mysql_fetch_array($hostel)) {
mysql_query('UPDATE `effects` SET `time` = "' . $tm . '", `sleep` = "0" WHERE `id` = "' . $ps['id'] . '" AND `owner` = "' . $pl['id'] . '"');
}
}
}
mysql_query('LOCK TABLES `inventory` WRITE, `variables` WRITE, `deztow_turnir` WRITE, `deztow_stavka` WRITE, `effects` WRITE, `deztow_charstams` WRITE, `deztow_gamers_inv` WRITE, `deztow_items` WRITE, `deztow_trap` WRITE, `online` WRITE');
$turnirstart = mysql_fetch_array(mysql_query("SELECT `value`, `bs_art` FROM `variables` WHERE `var` = 'startbs' LIMIT 1"));
$turnirstart['value'] -= 900;
if (date("z-H-i") == date("z-H-i", $turnirstart['value']))
if ($turnirstart['bs_art'] == 0) {
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=4');
} elseif ($turnirstart['bs_art'] == 1) {
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=4');
}
$tr = mysql_fetch_array(mysql_query("SELECT `id`, `type`, `winner`, `coin`, `start_time`, `log`, `endtime`, `active`, `winnerlog`, `art` FROM `deztow_turnir` WHERE `active` = TRUE LIMIT 1"));
$turnirstart = mysql_fetch_array(mysql_query("SELECT `value`, `bs_art` FROM `variables` WHERE `var` = 'startbs' LIMIT 1"));
$dd = mysql_fetch_array(mysql_query("SELECT COUNT(`kredit`) FROM `deztow_stavka` WHERE `owner` != 1254"));
if ($dd[0] < 2 && $turnirstart[0] <= time()) {
if ($turnirstart['bs_art'] == 1) {
$bs_art = 0;
} elseif ($turnirstart['bs_art'] == 0) {
$bs_art = 0;
}
mysql_query('UPDATE `variables` SET `value` = "' . (time() + 60 * 60) . '", `bs_art` = "' . $bs_art . '" WHERE `var` = "startbs" LIMIT 1');
mysql_query("INSERT INTO `deztow_stavka` (`owner`, `kredit`, `time`) VALUES ('1254', '30', '" . time() . "')");
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=5');
}
if (!$tr && $turnirstart[0] <= time() && $dd[0] >= 2) {
$minroom = 501;
$maxroom = 560;
$data = mysql_query("SELECT `dt`.`owner` FROM `deztow_stavka` AS `dt`, `online` AS `o` WHERE (SELECT COUNT(`id`) FROM `effects` WHERE `effects`.`owner` = `dt`.`owner` AND (`type` = 11 OR `type` = 12 OR `type` = 13 OR `type` = 14 OR `type` = 2 OR `type` = 3 OR `type` = 4 OR `type` = 202 OR `type` = 201 OR `type` = 21)) = 0 AND `o`.`id` = `dt`.`owner` AND `room` = 31 AND `o`.`date` >= '" . (time() - 300) . "' ORDER BY `kredit` DESC, `dt`.`time` ASC LIMIT 50");
$stavka = mysql_fetch_array(mysql_query("SELECT SUM(`kredit`)*0.7 FROM `deztow_stavka`"));
while ($row = mysql_fetch_array($data)) {
enter_bs($row[0]);
$tec = mysql_fetch_array(mysql_query("SELECT `id`, `owner`, `name`, `sila`, `lovk`, `inta`, `vinos`, `intel`, `mudra`, `def` FROM `deztow_charstams` WHERE `owner` = '{$row['owner']}' AND `def` = '1' LIMIT 1"));
$usk = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $row[0] . "' LIMIT 1"));
if (isset($tec['id'])) {
mysql_query("UPDATE `users` SET `sila` = '" . $tec['sila'] . "', `lovk` = '" . $tec['lovk'] . "', `inta` = '" . $tec['inta'] . "', `vinos` = '" . $tec['vinos'] . "', `intel` = '" . $tec['intel'] . "', `stats` = 0, `noj` = 0, `mec` = 0, `topor` = 0, `dubina` = 0, `mfire` = 0, `mwater` = 0, `mair` = 0, `mearth` = 0, `mlight` = 0, `mgray` = 0, `mdark` = 0, `master` = '8', `maxhp` = '" . ($tec['vinos'] * 6) . "', `hp` = '" . ($tec['vinos'] * 6) . "', `level` = 7, `nextup` = 999999999 WHERE `id` = '" . $usk['id'] . "' LIMIT 1");
} else {
mysql_query("UPDATE `users` SET `sila` = '3', `lovk` = '3', `inta` = '3', `vinos` = '10', `intel` = '0', `stats` = 64, `noj` = 0, `mec` = 0, `topor` = 0, `dubina` = 0, `mfire` = 0, `mwater` = 0, `mair` = 0, `mearth` = 0, `mlight` = 0, `mgray` = 0, `mdark` = 0, `master` = '8', `maxhp` = '60', `hp` = '60', `level` = 7, `nextup` = 999999999 WHERE `id` = '" . $usk['id'] . "' LIMIT 1");
}
$rum = rand($minroom, $maxroom);
$urs[$row['owner']] = $rum;
$i++;
if ($i > 1) {
$lors .= ", ";
}
$lors .= nick::id($row['owner'])->full(1);
}
undressall(233);
undressall(234);
undressall(235);
mysql_query("DELETE FROM `inventory` WHERE `owner` = 233");
mysql_query("DELETE FROM `inventory` WHERE `owner` = 234");
mysql_query("DELETE FROM `inventory` WHERE `owner` = 235");
$rums = rand($minroom, $maxroom);
mysql_query("UPDATE `users` SET `in_tower` = 1, `chattime` = '999999999999', `room` = '" . $rums . "' WHERE `id` = '233' LIMIT 1");
mysql_query("UPDATE `users` SET `in_tower` = 1, `chattime` = '999999999999', `room` = '" . $rums . "' WHERE `id` = '234' LIMIT 1");
mysql_query("UPDATE `users` SET `in_tower` = 1, `chattime` = '999999999999', `room` = '" . $rums . "' WHERE `id` = '235' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '" . $rums . "', `date` = '999999999999' WHERE `id` = '233' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '" . $rums . "', `date` = '999999999999' WHERE `id` = '234' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '" . $rums . "', `date` = '999999999999' WHERE `id` = '235' LIMIT 1");
echo mysql_error();
$i++;
$lors .= ", " . nick::id(233)->full(1);
$lors .= ", " . nick::id(234)->full(1);
$lors .= ", " . nick::id(235)->full(1);
$lors .= ltrim(",", $lors);
mysql_query("TRUNCATE TABLE `deztow_items`");
$shmots = ["1", "1", "92", "92", "93", "93", "19", "19", "20", "20", "20", "23", "23", "24", "14", "87", "87", "6", "6", "17", "17", "17", "17", "11", "11", "12", "12", "12", "28", "28", "43", "43", "36", "36", "36", "37", "37", "37", "38", "38", "38", "50", "50", "57", "52", "52", "51", "51", "48", "48", "47", "47", "49", "49", "59", "59", "60", "60", "61", "61", "63", "64", "64", "65", "65", "66", "66", "68", "68", "69", "69", "72", "72", "4", "5", "79", "79", "80", "76", "75", "75", "94", "94", "95", "95", "82", "91", "91", "34", "34", "86", "86", "86", "9", "9", "101", "101", "101", "101", "101", "97", "97", "97", "97", "100", "100", "100", "100", "171", "171", "171", "171", "103", "103", "103", "104", "105", "105", "106", "106", "107", "107", "108", "108", "109", "110", "111", "112", "112", "113", "113", "119", "364", "284", "284", "284", "284", "284", "285", "285", "285", "285", "286", "286", "286", "286"];
while ($sh = array_shift($shmots)) {
$shopid = mysql_fetch_array(mysql_query("SELECT `id`, `name`, `img` FROM `shop` WHERE `id` = '" . $sh . "' LIMIT 1"));
if (isset($shopid['id'])) {
mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $shopid['id'] . "', '" . $shopid['name'] . "', '" . $shopid['img'] . "', '" . rand($minroom, $maxroom) . "')");
}
}
$log = '<span class=date>' . date("d.m.y H:i") . '</span> Начало турнира. Участники : ' . $lors . '<br />';
$end = (time() + 21600);
mysql_query("INSERT `deztow_turnir` (`type`, `winner`, `coin`, `start_time`, `log`, `endtime`, `active`) VALUES ('" . rand(1, 7) . "', '', '" . $stavka[0] . "', '" . time() . "', '" . $log . "', '" . $end . "', '1')");
foreach ($urs as $row => $rum) {
mysql_query("UPDATE `users` SET `in_tower` = 1, `room` = '" . $rum . "' WHERE `id` = '" . $row . "'");
mysql_query("UPDATE `online` SET `room` = '" . $rum . "' WHERE `id` = '" . $row . "' LIMIT 1");
}
}
$tur_data = mysql_fetch_array(mysql_query("SELECT `id`, `type`, `winner`, `coin`, `start_time`, `log`, `endtime`, `active`, `winnerlog`, `art` FROM `deztow_turnir` WHERE `active` = '1' LIMIT 1"));
if ($tur_data['endtime'] < time() && $tur_data['id']) {
$list = mysql_query("SELECT * FROM `users` WHERE `in_tower` = 1");
while ($u = mysql_fetch_array($list)) {
undressall($u['id']);
$rep = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '" . $u['id'] . "' AND `bs` = 1");
while ($r = mysql_fetch_array($rep)) {
mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $r['prototype'] . "', '" . $r['name'] . "', '" . $r['img'] . "', '" . $u['room'] . "')");
}
mysql_query("DELETE FROM `inventory` WHERE `owner` = '" . $u['id'] . "' AND `bs` = 1");
$rep = mysql_query("SELECT `id_item`, `owner` FROM `deztow_gamers_inv` WHERE `owner` = '" . $u['id'] . "'");
while ($r = mysql_fetch_array($rep)) {
mysql_query("UPDATE `inventory` SET `owner` = '" . $u['id'] . "' WHERE `owner` = '0' AND `id` = '" . $r['id_item'] . "'");
}
$tec = mysql_fetch_array(mysql_query("SELECT `id`, `owner`, `name`, `sila`, `lovk`, `inta`, `vinos`, `intel`, `maxhp`, `money`, `exp`, `mudra`, `stats`, `nextup`, `level`, `align`, `master`, `noj`, `mec`, `topor`, `dubina`, `mlight`, `mgray`, `mdark` FROM `deztow_realchars` WHERE `owner` = '{$u['id']}' LIMIT 1"));
if (isset($tec['id'])) {
$u = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$u['id']}' LIMIT 1"));
$stats = $tec['stats'];
$master = $tec['master'];
mysql_query("UPDATE `users` SET `sila` = '" . $tec['sila'] . "', `lovk` = '" . $tec['lovk'] . "', `inta` = '" . $tec['inta'] . "', `vinos` = '" . $tec['vinos'] . "', `hp` = '" . ($tec['vinos'] * 6) . "', `maxhp` = '" . ($tec['vinos'] * 6) . "', `intel` = '" . $tec['intel'] . "', `stats` = '" . $tec['stats'] . "', `nextup` = '" . $tec['nextup'] . "', `level` = '" . $tec['level'] . "', `align` = '" . $tec['align'] . "', `noj` = '" . $tec['noj'] . "', `mec` = '" . $tec['mec'] . "', `topor` = '" . $tec['topor'] . "', `dubina` = '" . $tec['dubina'] . "', `mlight` = '" . $tec['mlight'] . "', `mgray` = '" . $tec['mgray'] . "', `mdark` = '" . $tec['mdark'] . "', `master` = '" . $tec['master'] . "' WHERE `id` = '" . $u['id'] . "' LIMIT 1");
mysql_query("DELETE FROM `deztow_realchars` WHERE `owner` = '{$u['id']}'");
$eff = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = '" . $u['id'] . "' AND (`type` = 1 `type` = 2 `type` = 3 `type` = 4 `type` = 11 OR `type` = 12 OR `type` = 13 OR `type` = 14 `type` = 21 `type` = 201 `type` = 202)"));
mysql_query("DELETE FROM `effects` WHERE `owner` = '" . $u['id'] . "' AND `type` != 1 AND `type` != 2 AND `type` != 3 AND `type` != 4 AND `type` != 5 AND `type` != 6 AND `type` != 11 AND `type` != 12 AND `type` != 13 AND `type` != 14");
if (isset($tec['id'])) {
mysql_query("UPDATE `users` SET `sila` = (`sila`-'" . $eff['sila'] . "'), `lovk` = (`lovk`-'" . $eff['lovk'] . "'), `inta` = (`inta`-'" . $eff['inta'] . "'), `maxhp` = (`maxhp`-'" . $eff['hp'] . "') WHERE `id` = '" . $eff['owner'] . "' LIMIT 1");
}
if ($u['id'] != 233 && $u['id'] != 234 && $u['id'] != 235) {
settravma($u['id'], 100, 86400, 1);
}
get_out($u['id']);
mysql_query("UPDATE `users` SET `in_tower` = 0, `room` = '31' WHERE `id` = '" . $u['id'] . "' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '31' WHERE `id` = '" . $u['id'] . "' LIMIT 1");
}
}
mysql_query('UPDATE `deztow_turnir` SET `winner` = \'NO!\', `winnerlog` = \'<b>Ничья</b>\', `endtime` = ' . time() . ', `active` = 0, `log` = CONCAT(`log`,\'' . "Турнир закончен по тайм-ауту. Победителя нет!<br />" . '\') WHERE `active` = TRUE LIMIT 1');
$turnirstart = mysql_fetch_array(mysql_query("SELECT `value`, `bs_art` FROM `variables` WHERE `var` = 'startbs' LIMIT 1"));
if ($turnirstart['bs_art'] == 1) {
$bs_art = 0;
} elseif ($turnirstart['bs_art'] == 0) {
$bs_art = 0; #1
}
$times = (time() + 7200);
mysql_query("UPDATE `variables` SET `value` = '" . $times . "', `bs_art` = '" . $bs_art . "' WHERE `var` = 'startbs' LIMIT 1");
mysql_query("TRUNCATE TABLE `deztow_stavka`");
mysql_query("TRUNCATE TABLE `deztow_gamers_inv`");
mysql_query("TRUNCATE TABLE `deztow_items`");
mysql_query("TRUNCATE TABLE `deztow_trap`");
}
mysql_query('UNLOCK TABLES');
}

View File

@ -1,11 +0,0 @@
<?php
/**
* Copyright (c) 2018.
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
#include_once 'config.php';
#include_once 'functions.php';
file_get_contents(GAMEDOMAIN.'/chats.php?id=6&user=10022');

211
cronjobs/cron_tower.php Normal file
View File

@ -0,0 +1,211 @@
<?php
/**
* Copyright (c) 2018.
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
require_once '../functions.php';
if (!$tr && $turnirstart[0] <= time() && $dd[0] >= 2) {
$minroom = 501;
$maxroom = 560;
$data = mysql_query("SELECT `dt`.`owner` FROM `deztow_stavka` AS `dt`, `online` AS `o` WHERE (SELECT COUNT(`id`) FROM `effects` WHERE `effects`.`owner` = `dt`.`owner` AND (`type` = 11 OR `type` = 12 OR `type` = 13 OR `type` = 14 OR `type` = 2 OR `type` = 3 OR `type` = 4 OR `type` = 202 OR `type` = 201 OR `type` = 21)) = 0 AND `o`.`id` = `dt`.`owner` AND `room` = 31 AND `o`.`date` >= '" . (time() - 300) . "' ORDER BY `kredit` DESC, `dt`.`time` ASC LIMIT 50");
$stavka = mysql_fetch_array(mysql_query("SELECT SUM(`kredit`)*0.7 FROM `deztow_stavka`"));
while ($row = mysql_fetch_array($data)) {
$pers = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $row[0] . '" LIMIT 1'));
undressall($pers['id']);
###
mysql_query('UPDATE `inventory` SET `owner` = "' . ($pers['id'] + _BOTSEPARATOR_) . '" WHERE `owner` = "' . $pers['id'] . '"');
###
###
$efs = mysql_query('SELECT * FROM `effects` WHERE `owner` = "' . $pers['id'] . '"');
$travm = [11, 12, 13, 14];
while ($row = mysql_fetch_array($efs)) {
if (in_array($row['type'], $travm)) {
$pers['sila'] += $row['sila'];
$pers['lovk'] += $row['lovk'];
$pers['inta'] += $row['inta'];
$pers['vinos'] += $row['vinos'];
} else {
$pers['sila'] -= $row['sila'];
$pers['lovk'] -= $row['lovk'];
$pers['inta'] -= $row['inta'];
$pers['vinos'] -= $row['vinos'];
$pers['maxhp'] -= $row['hp'];
}
$row['owner'] = ($user['id'] + _BOTSEPARATOR_);
mysql_query('UPDATE `effects` SET `owner` = "' . $row['owner'] . '" WHERE `id` = "' . $row['id'] . '" LIMIT 1');
mysql_query('UPDATE `users` SET `sila` = "' . $pers['sila'] . '", `lovk` = "' . $pers['lovk'] . '", `inta` = "' . $pers['inta'] . '", `vinos` = "' . $pers['vinos'] . '", `maxhp` = "' . $pers['maxhp'] . '" WHERE `id` = "' . $pers['id'] . '" LIMIT 1');
}
$udata = mysql_fetch_array(mysql_query('SELECT * FROM `deztow_realchars` WHERE `owner` = "' . $pers['id'] . '" LIMIT 1'));
if (isset($udata['id'])) {
$udata['sila'] = $pers['sila'];
$udata['lovk'] = $pers['lovk'];
$udata['inta'] = $pers['inta'];
$udata['vinos'] = $pers['vinos'];
$udata['maxhp'] = $pers['maxhp'];
$udata['money'] = $pers['money'];
$udata['level'] = $pers['level'];
$udata['exp'] = $pers['exp'];
$udata['nextup'] = $pers['nextup'];
$udata['align'] = $pers['align'];
$udata['stats'] = $pers['stats'];
$udata['master'] = $pers['master'];
$udata['intel'] = $pers['intel'];
$udata['noj'] = $pers['noj'];
$udata['mec'] = $pers['mec'];
$udata['topor'] = $pers['topor'];
$udata['dubina'] = $pers['dubina'];
$udata['mlight'] = $pers['mlight'];
$udata['mgray'] = $pers['mgray'];
$udata['mdark'] = $pers['mdark'];
mysql_query('UPDATE `deztow_realchars` SET `sila` = "' . $udata['sila'] . '", `lovk` = "' . $udata['lovk'] . '", `inta` = "' . $udata['inta'] . '", `vinos` = "' . $udata['vinos'] . '", `maxhp` = "' . $udata['maxhp'] . '", `money` = "' . $udata['money'] . '", `intel` = "' . $udata['intel'] . '", `level` = "' . $udata['level'] . '", `exp` = "' . $udata['exp'] . '", `nextup` = "' . $udata['nextup'] . '", `align` = "' . $udata['align'] . '", `stats` = "' . $udata['stats'] . '", `master` = "' . $udata['master'] . '", `noj` = "' . $udata['noj'] . '", `mec` = "' . $udata['mec'] . '", `topor` = "' . $udata['topor'] . '", `dubina` = "' . $udata['dubina'] . '", `mlight` = "' . $udata['mlight'] . '", `mgray` = "' . $udata['mgray'] . '", `mdark` = "' . $udata['mdark'] . '" WHERE `owner` = "' . $udata['id'] . '" LIMIT 1');
} else {
mysql_query('INSERT INTO `deztow_realchars` (`owner`, `sila`, `lovk`, `inta`, `vinos`, `maxhp`, `intel`, `level`, `money`, `exp`, `nextup`, `align`, `stats`, `master`, `noj`, `mec`, `topor`, `dubina`, `mlight`, `mgray`, `mdark`) VALUES ("' . $pers['id'] . '", "' . $pers['sila'] . '", "' . $pers['lovk'] . '", "' . $pers['inta'] . '", "' . $pers['vinos'] . '", "' . $pers['maxhp'] . '", "' . $pers['intel'] . '", "' . $pers['level'] . '", "' . $pers['money'] . '", "' . $pers['exp'] . '", "' . $pers['nextup'] . '", "' . $pers['align'] . '", "' . $pers['stats'] . '", "' . $pers['master'] . '", "' . $pers['noj'] . '", "' . $pers['mec'] . '", "' . $pers['topor'] . '", "' . $pers['dubina'] . '", "' . $pers['mlight'] . '", "' . $pers['mgray'] . '", "' . $pers['mdark'] . '")');
}
$tec = mysql_fetch_array(mysql_query("SELECT `id`, `owner`, `name`, `sila`, `lovk`, `inta`, `vinos`, `intel`, `mudra`, `def` FROM `deztow_charstams` WHERE `owner` = '{$row['owner']}' AND `def` = '1' LIMIT 1"));
$usk = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $row[0] . "' LIMIT 1"));
if (isset($tec['id'])) {
mysql_query("UPDATE `users` SET `sila` = '" . $tec['sila'] . "', `lovk` = '" . $tec['lovk'] . "', `inta` = '" . $tec['inta'] . "', `vinos` = '" . $tec['vinos'] . "', `intel` = '" . $tec['intel'] . "', `stats` = 0, `noj` = 0, `mec` = 0, `topor` = 0, `dubina` = 0, `mfire` = 0, `mwater` = 0, `mair` = 0, `mearth` = 0, `mlight` = 0, `mgray` = 0, `mdark` = 0, `master` = '8', `maxhp` = '" . ($tec['vinos'] * 6) . "', `hp` = '" . ($tec['vinos'] * 6) . "', `level` = 7, `nextup` = 999999999 WHERE `id` = '" . $usk['id'] . "' LIMIT 1");
} else {
mysql_query("UPDATE `users` SET `sila` = '3', `lovk` = '3', `inta` = '3', `vinos` = '10', `intel` = '0', `stats` = 64, `noj` = 0, `mec` = 0, `topor` = 0, `dubina` = 0, `mfire` = 0, `mwater` = 0, `mair` = 0, `mearth` = 0, `mlight` = 0, `mgray` = 0, `mdark` = 0, `master` = '8', `maxhp` = '60', `hp` = '60', `level` = 7, `nextup` = 999999999 WHERE `id` = '" . $usk['id'] . "' LIMIT 1");
}
$rum = rand($minroom, $maxroom);
$urs[$row['owner']] = $rum;
$i++;
if ($i > 1) {
$lors .= ", ";
}
$lors .= nick::id($row['owner'])->full(1);
}
// Боты: Архивариус и два помощника.
undressall(233);
undressall(234);
undressall(235);
mysql_query("DELETE FROM `inventory` WHERE `owner` = 233");
mysql_query("DELETE FROM `inventory` WHERE `owner` = 234");
mysql_query("DELETE FROM `inventory` WHERE `owner` = 235");
$rums = rand($minroom, $maxroom);
mysql_query("UPDATE `users` SET `in_tower` = 1, `chattime` = '999999999999', `room` = '" . $rums . "' WHERE `id` = '233' LIMIT 1");
mysql_query("UPDATE `users` SET `in_tower` = 1, `chattime` = '999999999999', `room` = '" . $rums . "' WHERE `id` = '234' LIMIT 1");
mysql_query("UPDATE `users` SET `in_tower` = 1, `chattime` = '999999999999', `room` = '" . $rums . "' WHERE `id` = '235' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '" . $rums . "', `date` = '999999999999' WHERE `id` = '233' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '" . $rums . "', `date` = '999999999999' WHERE `id` = '234' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '" . $rums . "', `date` = '999999999999' WHERE `id` = '235' LIMIT 1");
echo mysql_error();
$i++;
$lors .= ", " . nick::id(233)->full(1);
$lors .= ", " . nick::id(234)->full(1);
$lors .= ", " . nick::id(235)->full(1);
$lors .= ltrim(",", $lors);
mysql_query("TRUNCATE TABLE `deztow_items`");
$shmots = ["1", "1", "92", "92", "93", "93", "19", "19", "20", "20", "20", "23", "23", "24", "14", "87", "87", "6", "6", "17", "17", "17", "17", "11", "11", "12", "12", "12", "28", "28", "43", "43", "36", "36", "36", "37", "37", "37", "38", "38", "38", "50", "50", "57", "52", "52", "51", "51", "48", "48", "47", "47", "49", "49", "59", "59", "60", "60", "61", "61", "63", "64", "64", "65", "65", "66", "66", "68", "68", "69", "69", "72", "72", "4", "5", "79", "79", "80", "76", "75", "75", "94", "94", "95", "95", "82", "91", "91", "34", "34", "86", "86", "86", "9", "9", "101", "101", "101", "101", "101", "97", "97", "97", "97", "100", "100", "100", "100", "171", "171", "171", "171", "103", "103", "103", "104", "105", "105", "106", "106", "107", "107", "108", "108", "109", "110", "111", "112", "112", "113", "113", "119", "364", "284", "284", "284", "284", "284", "285", "285", "285", "285", "286", "286", "286", "286"];
while ($sh = array_shift($shmots)) {
$shopid = mysql_fetch_array(mysql_query("SELECT `id`, `name`, `img` FROM `shop` WHERE `id` = '" . $sh . "' LIMIT 1"));
if (isset($shopid['id'])) {
mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $shopid['id'] . "', '" . $shopid['name'] . "', '" . $shopid['img'] . "', '" . rand($minroom, $maxroom) . "')");
}
}
$log = '<span class=date>' . date("d.m.y H:i") . '</span> Начало турнира. Участники : ' . $lors . '<br />';
$end = (time() + 21600);
mysql_query("INSERT `deztow_turnir` (`type`, `winner`, `coin`, `start_time`, `log`, `endtime`, `active`) VALUES ('" . rand(1, 7) . "', '', '" . $stavka[0] . "', '" . time() . "', '" . $log . "', '" . $end . "', '1')");
foreach ($urs as $row => $rum) {
mysql_query("UPDATE `users` SET `in_tower` = 1, `room` = '" . $rum . "' WHERE `id` = '" . $row . "'");
mysql_query("UPDATE `online` SET `room` = '" . $rum . "' WHERE `id` = '" . $row . "' LIMIT 1");
}
}
mysql_query('LOCK TABLES `inventory` WRITE, `variables` WRITE, `deztow_turnir` WRITE, `deztow_stavka` WRITE, `effects` WRITE, `deztow_charstams` WRITE, `deztow_gamers_inv` WRITE, `deztow_items` WRITE, `deztow_trap` WRITE, `online` WRITE');
$turnirstart = mysql_fetch_array(mysql_query("SELECT `value`, `bs_art` FROM `variables` WHERE `var` = 'startbs' LIMIT 1"));
$turnirstart['value'] -= 900;
if (date("z-H-i") == date("z-H-i", $turnirstart['value']))
if ($turnirstart['bs_art'] == 0) {
file_get_contents(GAMEDOMAIN . '/chats.php?id=4');
} elseif ($turnirstart['bs_art'] == 1) {
file_get_contents(GAMEDOMAIN . '/chats.php?id=4');
}
$tr = mysql_fetch_array(mysql_query("SELECT `id`, `type`, `winner`, `coin`, `start_time`, `log`, `endtime`, `active`, `winnerlog`, `art` FROM `deztow_turnir` WHERE `active` = TRUE LIMIT 1"));
$turnirstart = mysql_fetch_array(mysql_query("SELECT `value`, `bs_art` FROM `variables` WHERE `var` = 'startbs' LIMIT 1"));
$dd = mysql_fetch_array(mysql_query("SELECT COUNT(`kredit`) FROM `deztow_stavka` WHERE `owner` != 1254"));
if ($dd[0] < 2 && $turnirstart[0] <= time()) {
if ($turnirstart['bs_art'] == 1) {
$bs_art = 0;
} elseif ($turnirstart['bs_art'] == 0) {
$bs_art = 0;
}
mysql_query('UPDATE `variables` SET `value` = "' . (time() + 60 * 60) . '", `bs_art` = "' . $bs_art . '" WHERE `var` = "startbs" LIMIT 1');
mysql_query("INSERT INTO `deztow_stavka` (`owner`, `kredit`, `time`) VALUES ('1254', '30', '" . time() . "')");
file_get_contents(GAMEDOMAIN . '/chats.php?id=5');
}
$tur_data = mysql_fetch_array(mysql_query("SELECT `id`, `type`, `winner`, `coin`, `start_time`, `log`, `endtime`, `active`, `winnerlog`, `art` FROM `deztow_turnir` WHERE `active` = '1' LIMIT 1"));
if ($tur_data['endtime'] < time() && $tur_data['id']) {
$list = mysql_query("SELECT * FROM `users` WHERE `in_tower` = 1");
while ($u = mysql_fetch_array($list)) {
undressall($u['id']);
$rep = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '" . $u['id'] . "' AND `bs` = 1");
while ($r = mysql_fetch_array($rep)) {
mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $r['prototype'] . "', '" . $r['name'] . "', '" . $r['img'] . "', '" . $u['room'] . "')");
}
mysql_query("DELETE FROM `inventory` WHERE `owner` = '" . $u['id'] . "' AND `bs` = 1");
$rep = mysql_query("SELECT `id_item`, `owner` FROM `deztow_gamers_inv` WHERE `owner` = '" . $u['id'] . "'");
while ($r = mysql_fetch_array($rep)) {
mysql_query("UPDATE `inventory` SET `owner` = '" . $u['id'] . "' WHERE `owner` = '0' AND `id` = '" . $r['id_item'] . "'");
}
$tec = mysql_fetch_array(mysql_query("SELECT `id`, `owner`, `name`, `sila`, `lovk`, `inta`, `vinos`, `intel`, `maxhp`, `money`, `exp`, `mudra`, `stats`, `nextup`, `level`, `align`, `master`, `noj`, `mec`, `topor`, `dubina`, `mlight`, `mgray`, `mdark` FROM `deztow_realchars` WHERE `owner` = '{$u['id']}' LIMIT 1"));
if (isset($tec['id'])) {
$u = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$u['id']}' LIMIT 1"));
$stats = $tec['stats'];
$master = $tec['master'];
mysql_query("UPDATE `users` SET `sila` = '" . $tec['sila'] . "', `lovk` = '" . $tec['lovk'] . "', `inta` = '" . $tec['inta'] . "', `vinos` = '" . $tec['vinos'] . "', `hp` = '" . ($tec['vinos'] * 6) . "', `maxhp` = '" . ($tec['vinos'] * 6) . "', `intel` = '" . $tec['intel'] . "', `stats` = '" . $tec['stats'] . "', `nextup` = '" . $tec['nextup'] . "', `level` = '" . $tec['level'] . "', `align` = '" . $tec['align'] . "', `noj` = '" . $tec['noj'] . "', `mec` = '" . $tec['mec'] . "', `topor` = '" . $tec['topor'] . "', `dubina` = '" . $tec['dubina'] . "', `mlight` = '" . $tec['mlight'] . "', `mgray` = '" . $tec['mgray'] . "', `mdark` = '" . $tec['mdark'] . "', `master` = '" . $tec['master'] . "' WHERE `id` = '" . $u['id'] . "' LIMIT 1");
mysql_query("DELETE FROM `deztow_realchars` WHERE `owner` = '{$u['id']}'");
$eff = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = '" . $u['id'] . "' AND (`type` = 1 `type` = 2 `type` = 3 `type` = 4 `type` = 11 OR `type` = 12 OR `type` = 13 OR `type` = 14 `type` = 21 `type` = 201 `type` = 202)"));
mysql_query("DELETE FROM `effects` WHERE `owner` = '" . $u['id'] . "' AND `type` != 1 AND `type` != 2 AND `type` != 3 AND `type` != 4 AND `type` != 5 AND `type` != 6 AND `type` != 11 AND `type` != 12 AND `type` != 13 AND `type` != 14");
if (isset($tec['id'])) {
mysql_query("UPDATE `users` SET `sila` = (`sila`-'" . $eff['sila'] . "'), `lovk` = (`lovk`-'" . $eff['lovk'] . "'), `inta` = (`inta`-'" . $eff['inta'] . "'), `maxhp` = (`maxhp`-'" . $eff['hp'] . "') WHERE `id` = '" . $eff['owner'] . "' LIMIT 1");
}
if ($u['id'] != 233 && $u['id'] != 234 && $u['id'] != 235) {
settravma($u['id'], 100, 86400, 1);
}
get_out($u['id']);
mysql_query("UPDATE `users` SET `in_tower` = 0, `room` = '31' WHERE `id` = '" . $u['id'] . "' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '31' WHERE `id` = '" . $u['id'] . "' LIMIT 1");
}
}
mysql_query('UPDATE `deztow_turnir` SET `winner` = \'NO!\', `winnerlog` = \'<b>Ничья</b>\', `endtime` = ' . time() . ', `active` = 0, `log` = CONCAT(`log`,\'' . "Турнир закончен по тайм-ауту. Победителя нет!<br />" . '\') WHERE `active` = TRUE LIMIT 1');
$turnirstart = mysql_fetch_array(mysql_query("SELECT `value`, `bs_art` FROM `variables` WHERE `var` = 'startbs' LIMIT 1"));
if ($turnirstart['bs_art'] == 1) {
$bs_art = 0;
} elseif ($turnirstart['bs_art'] == 0) {
$bs_art = 0; #1
}
$times = (time() + 7200);
mysql_query("UPDATE `variables` SET `value` = '" . $times . "', `bs_art` = '" . $bs_art . "' WHERE `var` = 'startbs' LIMIT 1");
mysql_query("TRUNCATE TABLE `deztow_stavka`");
mysql_query("TRUNCATE TABLE `deztow_gamers_inv`");
mysql_query("TRUNCATE TABLE `deztow_items`");
mysql_query("TRUNCATE TABLE `deztow_trap`");
}
mysql_query('UNLOCK TABLES');