'0'){
die("");
}
$vipUsers = array(
'SaulDin',
'Дед Мазай',
'Лик Ужаса',
);
$errkom = '';
$varsitm = array(array(270, 1));
$varsitm2 = array(array(87, 1), array(88, 1), array(48, 1), array(49, 1), array(29, 1), array(66, 1), array(97, 1), array(67, 1), array(98, 1), array(115, 1));
function labaItemAdd($id, $type) {
global $user;
if($type == 1) {
$dress = mysql_fetch_array(mysql_query('SELECT * FROM `shop` WHERE `id` = "'.(int)$id.'" LIMIT 1'));
} else {
$dress = mysql_fetch_array(mysql_query('SELECT * FROM `ashop` WHERE `id` = "'.(int)$id.'" LIMIT 1'));
}
if(isset($dress['id'])) {
mysql_query("INSERT INTO `inventory` (`laba`, `prototype`,`owner`,`name`,`type`,`massa`,`cost`, `img`,`maxdur`,`isrep`,`gsila`,`glovk`,`ginta`,`gintel`,`ghp`,`gnoj`,`gtopor`,`gdubina`,`gmech`,`gfire`,`gwater`,`gair`,`gearth`,`glight`,`ggray`,`gdark`,`needident`,`nsila`,`nlovk`,`ninta`,`nintel`,`nmudra`,`nvinos`,`nnoj`,`ntopor`,`ndubina`,`nmech`,`nfire`,`nwater`,`nair`,`nearth`,`nlight`,`ngray`,`ndark`,`mfkrit`,`mfakrit`,`mfuvorot`,`mfauvorot`,`bron1`,`bron2`,`bron3`,`bron4`,`maxu`,`minu`,`magic`,`nlevel`,`nalign`,`dategoden`,`goden`,`otdel`,`gmp`,`gmeshok`,`encicl`,`artefact`,`koll`) VALUES ('$type', '{$dress['id']}','{$user['id']}','{$dress['name']}','{$dress['type']}',{$dress['massa']},{$dress['cost']},'{$dress['img']}',{$dress['maxdur']},{$dress['isrep']},'{$dress['gsila']}','{$dress['glovk']}','{$dress['ginta']}','{$dress['gintel']}','{$dress['ghp']}','{$dress['gnoj']}','{$dress['gtopor']}','{$dress['gdubina']}','{$dress['gmech']}','{$dress['gfire']}','{$dress['gwater']}','{$dress['gair']}','{$dress['gearth']}','{$dress['glight']}','{$dress['ggray']}','{$dress['gdark']}','{$dress['needident']}','{$dress['nsila']}','{$dress['nlovk']}','{$dress['ninta']}','{$dress['nintel']}','{$dress['nmudra']}','{$dress['nvinos']}','{$dress['nnoj']}','{$dress['ntopor']}','{$dress['ndubina']}','{$dress['nmech']}','{$dress['nfire']}','{$dress['nwater']}','{$dress['nair']}','{$dress['nearth']}','{$dress['nlight']}','{$dress['ngray']}','{$dress['ndark']}','{$dress['mfkrit']}','{$dress['mfakrit']}','{$dress['mfuvorot']}','{$dress['mfauvorot']}','{$dress['bron1']}','{$dress['bron2']}','{$dress['bron3']}','{$dress['bron4']}','{$dress['maxu']}','{$dress['minu']}','{$dress['magic']}','{$dress['nlevel']}','{$dress['nalign']}','".(($dress['goden'])?($dress['goden']*24*60*60+time()):"")."','{$dress['goden']}','{$dress['razdel']}','{$dress['gmp']}','{$dress['gmeshok']}','{$dress['encicl']}','{$dress['artefact']}','{$dress[koll]}')");
}
}
function money_add($sum) {
global $user;
$user['money'] += $sum;
mysql_query('UPDATE `users` SET `money` = "'.$user['money'].'" WHERE `id` = "'.$user['id'].'" LIMIT 1');
}
if($user['room'] == 1052) {
if($user['id'] == 10022) {
$lab = mysql_fetch_array(mysql_query('SELECT * FROM `laba_now` WHERE `id` = "'.$user['laba'].'" LIMIT 1'));
$map = mysql_fetch_array(mysql_query('SELECT `id`,`data`,`update` FROM `laba_map` WHERE `id` = "'.$user['laba'].'" LIMIT 1'));
} else {
$lab = mysql_fetch_array(mysql_query('SELECT * FROM `laba_now` WHERE `id` = "'.$user['laba'].'" LIMIT 1'));
$map = mysql_fetch_array(mysql_query('SELECT `id`,`data`,`update` FROM `laba_map` WHERE `id` = "'.$user['laba'].'" LIMIT 1'));
}
$dies = mysql_fetch_array(mysql_query('SELECT COUNT(`id`) FROM `laba_act` WHERE `uid` = "'.$user['id'].'" AND `lib` = "'.$user['laba'].'" AND `vars` = "dielaba" LIMIT 1'));
$dies = $dies[0];
$map_d = json_decode($map['data']);
$usersDng = showProgressBar($user['hp'], $user['maxhp']);
$errors = '';
$effed = '';
$mapsee = '';
$varos = array();
$varos['trap1'] = mysql_fetch_array(mysql_query('SELECT `id`, `vals`, `time` FROM `laba_act` WHERE `uid` = "'.$user['id'].'" AND `lib` = "'.$lab['id'].'" AND `time` > "'.time().'" ORDER BY `time` DESC LIMIT 1'));
$real_x = $user['x'];
$real_y = $user['y'];
if($real_y < 6) { $real_y = 6; }
if($real_x < 6) { $real_x = 6; }
if($real_y > count($map_d) - 7) {
$real_y = count($map_d) - 7;
}
if($real_x > count($map_d) - 7) {
$real_x = count($map_d) - 7;
}
$objs = array();
$sp = mysql_query('SELECT * FROM `laba_obj` WHERE `lib` = "'.$lab['id'].'" AND `x` > '.($real_x - 7).' AND `x` < '.($real_x + 7).' AND `y` > '.($real_y - 12).' AND `y` < '.($real_y + 12).' LIMIT 144');
while($pl = mysql_fetch_array($sp)) {
$objs[$pl['x']][$pl['y']] = $pl;
}
$i = 1;
$goodgoo = array(1 => 0, 2 => 0, 3 => 0, 4 => 0);
while($i <= 4) {
$goto = array('x' => $user['y'], 'y' => $user['x']);
if($i == 1) {
$goto['x']--;
} elseif($i == 2) {
$goto['y']--;
} elseif($i == 3) {
$goto['x']++;
} elseif($i == 4) {
$goto['y']++;
}
if($map_d[$goto['y']][$goto['x']] == 0 && $goto['x'] > 0 && $goto['x'] < count($map_d)-1 && $user['timeGo'] <= time()) {
$goodgoo[$i] = 1;
}
$i++;
}
if(isset($_GET['goto'])) {
$goto = array('x' => $user['y'], 'y' => $user['x']);
if($_GET['goto'] == 1 ) {
$goto['x']--;
} elseif($_GET['goto'] == 2) {
$goto['y']--;
} elseif($_GET['goto'] == 3) {
$goto['x']++;
} elseif($_GET['goto'] == 4) {
$goto['y']++;
}
if($goodgoo[$_GET['goto']] == 1 && $user['timeGo'] <= time()) {
$user['y'] = $goto['x'];
$user['x'] = $goto['y'];
$real_x = $user['x'];
$real_y = $user['y'];
$varos['timego'] = 0; #5
if(isset($varos['trap1']['id'])) {
$varos['timego'] += 3;
}
if($user['align'] == 2.99) { $varos['timego'] = 0; }
$user['timeGo'] = (time()+$varos['timego']);
$user['timeGoL'] = time();
if(!mysql_query('UPDATE `users` SET `x` = "'.$user['x'].'", `y` = "'.$user['y'].'", `timeGoL` = "'.$user['timeGoL'].'", `timeGo` = "'.$user['timeGo'].'" WHERE `id` = "'.$user['id'].'" LIMIT 1')) {
$errors = 'Ошибка перемещения!';
}
}
}
if($real_y < 6) { $real_y = 6; }
if($real_x < 6) { $real_x = 6; }
if($real_y > count($map_d) - 7) {
$real_y = count($map_d) - 7;
}
if($real_x > count($map_d) - 7) {
$real_x = count($map_d) - 7;
}
$tmdg = ($user['timeGo']-time());
$tmdgl = ($user['timeGo']-$user['timeGoL']);
$tmdgp = floor(100-$tmdg/$tmdgl*100);
if($tmdgp < 1) { $tmdgp = 1; } elseif($tmdgp > 100) { $tmdgp = 100; }
$tmdgm = 25*$tmdgl;
$tmdg = floor(40/100*$tmdgp);
if($tmdg < 1) {
$tmdg = 1;
} elseif($tmdg > 40) {
$tmdg = 40;
}
if(isset($_POST['exit'])) {
if($lab['users'] < 2) {
mysql_query('DELETE FROM `laba_now` WHERE `id` = "'.$lab['id'].'" LIMIT 1');
mysql_query('DELETE FROM `laba_map` WHERE `id` = "'.$lab['id'].'" LIMIT 1');
mysql_query('DELETE FROM `laba_obj` WHERE `lib` = "'.$lab['id'].'"');
mysql_query('DELETE FROM `laba_act` WHERE `lib` = "'.$lab['id'].'"');
mysql_query('DELETE FROM `laba_itm` WHERE `lib` = "'.$lab['id'].'"');
} else {
$lab['users']--;
mysql_query('UPDATE `laba_now` SET `users` = "'.$lab['users'].'" WHERE `id` = "'.$lab['id'].'" LIMIT 1');
}
$dresed = mysql_query('SELECT `id`, `type` FROM `inventory` WHERE `dressed` = 1 AND `laba` = 2 AND `owner` = "'.$user['id'].'"');
while($pl = mysql_fetch_array($dresed)) {
dropitemid($pl['type'], $user['id']);
}
mysql_query('DELETE FROM `inventory` WHERE `laba` > 0 AND `owner` = "'.$user['id'].'"');
mysql_query("UPDATE `users`, `online` SET `users`.`room` = '1051', `online`.`room` = '1051', `users`.`x` = '0', `users`.`y` = '0', `users`.`laba` = '0' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '".$user['id']."'");
mysql_query('UPDATE `qst_user` SET `val` = "0" WHERE `uid` = "'.$user['id'].'" AND `cancel` = "0" AND `finish` = "0"');
addActions(time(), 'go_labirint', (time()+60*60*6), $user['id']);
header('Location: lab_enter.php');
}
$itms = '';
if(isset($objs[$user['x']][$user['y']]['id'])) {
$var = array();
$mitm = $objs[$user['x']][$user['y']];
if($mitm['type'] == 2) {
if($mitm['use'] == 0) {
$btl_pix = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `battle` > 0 AND `laba` = "'.$lab['id'].'" AND `x` = "'.$user['x'].'" AND `y` = "'.$user['y'].'" LIMIT 1'));
if(!isset($btl_pix['id']) ) {
$bots = array(
0 => array(10025, 10026, 10027, 10028, 10031, 10032, 10033, 10034),
1 => array(10111, 10112, 10113, 10114, 10115, 10116),
2 => array(10111, 10112, 10113)
);
$bot_pix2 = $bots[$lab['type']];
$teams = array();
$where = ''; $bot_ids = '';
$i = 0;
$j = (1+rand(0, floor($user['level']/rand(3, 4))));
while($i < $j) {
$bot_pix = $bot_pix2[rand(0, count($bot_pix2)-1)];
$bot_pix = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$bot_pix.'" LIMIT 1'));
mysql_query("INSERT INTO `bots` (`name`, `prototype`, `battle`, `hp`) VALUES ('".$bot_pix['login']." (Бот #$i)', '".$bot_pix['id']."', '', '".$bot_pix['maxhp']."')");
$bot = mysql_insert_id();
$bot_ids .= $bot.';';
$teams[$user['id']][$bot] = array(0, 0, time());
$teams[$bot][$user['id']] = array(0, 0, time());
$where = ' `id` = '.$bot.' OR';
$i++;
}
$bot_ids = rtrim($bot_ids, ';');
$where = rtrim($where, ' OR');
if(!mysql_query("INSERT INTO `battle` (`teams`, `timeout`, `type`, `status`, `t1`, `t2`, `to1`, `to2`, `x`, `y`) VALUES ('".serialize($teams)."', '3', '1', '0', '".$user['id']."', '".$bot_ids."', '".time()."', '".time()."', '".$user['x']."', '".$user['y']."')")) { die('Error #2'); }
$id = mysql_insert_id();
$bts = explode(';', $bot_ids);
$is = 0;
while($is <= count($bts)) {
$nicks .= Nick::id($bts[$is])->full(1).', ';
$i_d .= $bts[$is].', ';
$is++;
}
$nicks = rtrim($nicks, ', ');
$who = '`id` IN ('.rtrim($i_d, ', ').')';
if($user1['invis'] == 1) {
$rr = "невидимка и ".$nicks."";
} else {
$rr = "".Nick::id($user['id'])->full(1)." и ".$nicks."";
}
if(!mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE ".$who."")) { die('Error #1'.$who); }
mysql_query("UPDATE `users` SET `battle` = {$id}, `zayavka` = 0 WHERE `id`= {$user['id']} LIMIT 1");
addlog($id, "Часы показывали ".date("Y.m.d H.i").", когда ".$rr." бросили вызов друг другу.
");
} else {
$bd = mysql_fetch_array(mysql_query('SELECT * FROM `battle` WHERE `id` = "'.$btl_pix['battle'].'" LIMIT 1'));
$botd = mysql_fetch_array(mysql_query('SELECT * FROM `bots` WHERE `battle` = "'.$bd['id'].'" LIMIT 1'));
$battle = unserialize($bd['teams']);
$ak = array_keys($battle[$botd['id']]);
$battle[$user['id']] = $battle[$ak[0]];
foreach($battle[$user['id']] as $k => $v) {
$battle[$user['id']][$k] = array(0, 0, time());
$battle[$k][$user['id']] = array(0, 0, time());
}
$t1 = explode(";", $bd['t1']);
$ttt = 1;
addlog($jert['battle'], ''.date("H:i").' '.Nick::id($user['id'])->short().' вмешался в поединок!
');
mysql_query('UPDATE `battle` SET `teams` = \''.serialize($battle).'\', `t'.$ttt.'` = CONCAT(`t'.$ttt.'`,\';'.$user['id'].'\') WHERE `id` = "'.$btl_pix['battle'].'" LIMIT 1');
mysql_query("UPDATE `users` SET `battle` = '".$bd['id']."', `zayavka` = 0 WHERE `id` = '".$user['id']."' LIMIT 1");
header("Location: fbattle.php");
}
die("");
}
} elseif($mitm['type'] == 1) {
if($mitm['use'] == 0) {
$itms .= '