* Project name: Battles-Game */ require_once 'config.php'; /** * Класс-заглушка для работы глобальных переменных в функциях. * Возвращает массив данных таблицы users. */ if (isset($_SESSION['uid'])) { $user = (new users_row($_SESSION['uid']))->result(); } else { echo "Не могу проинициализировать игрока!"; } if (isset($user['id']) && $user['block'] == 1) { die('user blocked!'); } // ??? //define("HPADDICTIONEFFECT", 33); $ip = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP); if (isset($_GET['goto']) && isset($_GET['tStamp']) && isset($_GET['vcode']) && $_GET['vcode'] == md5(sha1($_GET['goto'] . $_GET['tStamp']))) { db::c()->query('UPDATE `users`,`online` SET `users`.`room` = ?i, `online`.`room` = ?i WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $_GET['goto'], $_GET['goto'], $_SESSION['uid']); $user['room'] = intval($_GET['goto']); } function createbot($bot, $login = "") { $rec = db::c()->query('SELECT `id`, `login`, `maxhp` FROM `users` WHERE `id` = "?s" LIMIT 1', $bot)->fetch_assoc(); if (isset($rec['id'])) { if ($login) { $rec['login'] = $login; } $botname = $rec['login']; db::c()->query('INSERT INTO `bots` (`name`, `prototype`, `hp`) VALUES ("?s", "?s", "?s")', $botname, $bot, $rec['maxhp']); $nid = db::c()->getLastInsertId(); return ["id" => $nid, "login" => $botname]; } else { return false; } } $var_map = [ 'cell_1' => 'Березовая роща', 'cell_2' => 'Березовая просека', 'cell_3' => 'Тёмный угол', 'cell_4' => 'Мрачная опушка', 'cell_5' => 'Тёмное урочище', 'cell_6' => 'Бурелом', 'cell_7' => 'Старая ива', 'cell_8' => 'Разнолесье', 'cell_9' => 'Сосновая тропа', 'cell_10' => 'Забытая дорога', 'cell_11' => 'Новая дорога', 'cell_12' => 'Мщаник', 'cell_13' => 'Ясная поляна', 'cell_14' => 'Заросший тракт', 'cell_15' => 'Смутный ельник', 'cell_16' => 'Сосновый бор', 'cell_17' => 'Тихоход', 'cell_18' => 'Сосновый гай', 'cell_19' => 'Смешаный лес', 'cell_20' => 'Темная поляна', 'cell_21' => 'Осенний угол', 'cell_22' => 'Грибное место', 'cell_23' => 'Опушка', 'cell_24' => 'Рыжий лес', 'cell_25' => 'Полесье', ]; function get_out($u) { $pers = db::c()->query('SELECT * FROM users WHERE id = ?i', $u)->fetch_assoc_array(); undressall($pers['id']); db::c()->query('UPDATE inventory SET owner = ?i WHERE owner = ?i', $pers['id'], $pers['id'] + _BOTSEPARATOR_); ### $row = db::c()->query('SELECT * FROM `effects` WHERE `owner` = ?i', $pers['id'] + _BOTSEPARATOR_); $travm = [11, 12, 13, 14]; while ($efs = $row->fetch_assoc()) { if (in_array($efs['type'], $travm)) { $pers['sila'] -= $efs['sila']; $pers['lovk'] -= $efs['lovk']; $pers['inta'] -= $efs['inta']; $pers['vinos'] -= $efs['vinos']; } else { $pers['sila'] += $efs['sila']; $pers['lovk'] += $efs['lovk']; $pers['inta'] += $efs['inta']; $pers['vinos'] += $efs['vinos']; $pers['maxhp'] += $efs['hp']; } $efs['owner'] = $_SESSION['uid']; //mysql_query('UPDATE `effects` SET `owner` = "' . $efs['owner'] . '" WHERE `id` = "' . $efs['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'); } ### } function takeshopitem($item, $table = "shop", $present = '', $onlyonetrip = '', $fields = 0, $uid = 0, $koll = 1, $podzem = 0) { global $user; $flds = []; $goden = ''; if (!$uid) { $uid = $user['id']; } $r = db::c()->query('SHOW FIELDS FROM ?f', $table); $r2 = db::c()->query('SHOW FIELDS FROM inventory'); while ($rec = $r2->fetch_assoc()) { $flds[$rec['Field']] = 1; } $rec1 = db::c()->query('SELECT * FROM ?f WHERE id = ?i', $table, $item)->fetch_assoc_array(); if ($rec1['koll']) { db::c()->query('UPDATE inventory SET koll = (koll + ?i), massa = (massa + ?i), cost = (cost + ?i) WHERE owner = ?i AND prototype = ?i', $koll, $rec1['massa'] * $koll, $rec1['cost'], $uid, $item); if (db::c()->getAffectedRows() > 0) { return ["img" => $rec1['img'], "name" => $rec1['name']]; } $rec1['koll'] = $koll; $rec1['massa'] *= $koll; } if ($rec1['onlyone']) { $i = db::c()->query('SELECT id FROM inventory WHERE owner = ?i AND prototype = ?i', $uid, $item)->fetch_row(); if ($i) { return ["error" => "У вас слишком много таких вещей."]; } } if ($present) { $rec1['present'] = $present; $rec1['cost'] = 0; $rec1['ecost'] = 0; } $sql = ""; while ($rec = $r->fetch_assoc()) { if (!$flds[$rec['Field']]) { continue; } if ($rec['Field'] == "dategoden") { $goden = $rec1[$rec['Field']]; } if ($rec['Field'] == "goden") { $goden = $rec1[$rec['Field']]; } if ($rec['Field'] == "id" || $rec['Field'] == "prototype" || $rec['Field'] == "dategoden") { continue; } $sql .= ", `$rec[Field]` = '" . $rec1[$rec['Field']] . "' "; } if ($podzem) { $rec1['podzem'] = $podzem; } if ($fields['goden']) { $goden = $fields["goden"]; } mysql_query("INSERT INTO `inventory` SET " . ($present ? "`present` = '$present'," : "") . ($rec1['podzem'] ? "`podzem` = '$rec1[podzem]'," : "") . " `owner` = '$uid', `otdel` = $rec1[razdel] , `prototype` = '$item' " . ($onlyonetrip ? ", `foronetrip` = 1" : "") . ($goden ? ", `dategoden` = '" . ($goden * 60 * 60 * 24 + time()) . "'" : "") . " $sql"); return ["img" => $rec1['img'], "name" => $rec1['name'], "id" => mysql_insert_id()]; } define('_BOTSEPARATOR_', 10000000); header("Cache-Control: no-cache"); function level_up($uid) { global $exptable; $us = db::c()->query('SELECT `id`, `login`, `level`, `money`, `exp`, `vinos`, `nextup`, `stats`, `master`, `maxhp`, `ip`, `in_tower` FROM `users` WHERE `id` =?i', $uid)->fetch_assoc(); if (isset($us['id']) && $us['exp'] >= $us['nextup'] && !$us['in_tower']) { if ($exptable[$us['nextup']][4] == 1) { addch("Персонаж {$us['login']} перешел на " . ($us['level'] + 1) . " уровень."); addchp('Внимание! Вы перешли на новый уровень. За это Вы получаете: ' . $exptable[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}'); } elseif ($exptable[$us['nextup']][4] == 0) { addchp('Внимание! Вы перешли на новый АП. За это Вы получаете: ' . $exptable[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}'); } $us['nextup'] = $exptable[$us['nextup']][5]; $us['stats'] += $exptable[$us['nextup']][0]; $us['master'] += $exptable[$us['nextup']][1]; $us['vinos'] += $exptable[$us['nextup']][2]; $us['maxhp'] += ($exptable[$us['nextup']][2] * 6); $us['money'] += $exptable[$us['nextup']][3]; db::c()->query('UPDATE `users` SET `nextup` = ?i, `stats` = ?i, `master` = ?i, `vinos` = ?i, `maxhp` = ?i, `money` = ?i, `level` = ?i WHERE `id` = ?i', $us['nextup'], $us['stats'], $us['master'], $us['vinos'], $us['maxhp'], $us['money'], $us['level'], $us['id']); } } ######## FIXME ВЕЧНЫЕ 12-ТКИ!!!!!!!!!!!! if (isset($_SESSION['uid'])) { $in_user = db::c()->query('SELECT `id`, `exp`, `nextup`, `level` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc(); } if (isset($in_user['id']) && ($in_user['exp'] >= $in_user['nextup']) && $in_user['level'] < 13) { level_up($in_user['id']); } ######## function savecavedata($cavedata, $caveleader, $floor) { $f1 = fopen("cavedata/$caveleader-$floor.dat", "wb+"); flock($f1, LOCK_EX); fwrite($f1, serialize($cavedata)); flock($f1, LOCK_UN); fclose($f1); } function topsethp() { global $user; if ($user['hp'] >= $user['maxhp'] || $user['battle']) { return "top.setHP($user[hp], $user[maxhp], 0)"; } $fulltime = timetoheals($user); $delay = round(1 / ($user['maxhp'] / $fulltime) * 1000); return "top.setHP($user[hp], $user[maxhp], $delay);"; } function nick($user) { if ($user['align'] > 0) { $al = $user['align']; } else { $al = 0; } if ($user['klan'] != '') { $cl = ''; } else { $cl = ''; } return '
' . $cl . '' . $user['login'] . ' [' . $user['level'] . '] Inf HP : ' . $user['hp'] . ' / ' . $user['maxhp'] . '
'; } function nick4($id, $st) { $user = db::c()->query('SELECT * FROM `users` WHERE `id` = ?i', $id)->fetch_assoc(); if ($user[0]) { $effect = db::c()->query('SELECT time FROM effects WHERE type = 1022 and owner = ?i', $id)->fetch_assoc_array(); if ($effect) { $user['level'] = '??'; $user['login'] = 'невидимка'; $user['align'] = '0'; $user['klan'] = ''; $user['id'] = ''; $user['hp'] = '??'; $user['maxhp'] = '??'; } return "" . $user['login'] . " [" . $user['hp'] . "/" . $user['maxhp'] . "]"; } return false; } function check_proc($u) { $r = 100; $usr = db::c()->query('SELECT `id`, `vip`, `vip_time` FROM `users` WHERE `id` = ?i', $u)->fetch_assoc_array(); if ($usr['vip_time'] > time()) { if ($usr['vip'] == 1) { $r += 10; } elseif ($usr['vip'] == 2) { $r += 15; } elseif ($usr['vip'] == 3) { $r += 20; } } $effes = db::c()->query('SELECT SUM(`proc_exp`) AS `sums` FROM `effects` WHERE proc_exp > 0 AND owner = ?i', $usr['id'])->fetch_assoc_array(); if ($effes['sums'] > 0) { $r += $effes['sums']; } return $r; } function ClanImage($clan_id) { $clanimg = db::c()->query('SELECT `short` FROM `clans` WHERE `id` = ?i ', $clan_id)->fetch_assoc(); if ($clanimg['short']) { return $clanimg['short']; } else { return "1x1"; } } function GiveExp($id, $exp) { db::c()->query('UPDATE users SET exp = exp + ?i WHERE id = ?i', $exp, $id); } function GiveRep($id, $rep) { db::c()->query('UPDATE users SET doblest = (doblest + ?i), rep_laba = (rep_laba + ?i) WHERE `id` = ?i', $rep, $rep, $id); } // полоска НР function setHP($hp, $maxhp) { if ($hp < $maxhp * 0.33) { $polosa = 'i/1red.gif'; } elseif ($hp < $maxhp * 0.66) { $polosa = 'i/1yellow.gif'; } else { $polosa = 'i/1green.gif'; } $polosa_width = (122 * ($hp / $maxhp)); $silver_polosa_width = (122 - 122 * ($hp / $maxhp)); return << Уровень жизни Уровень жизни $hp / $maxhp HTML; } /** * @param $current * @param $maximum */ function showProgressBar($current, $maximum, $line_color = 'limegreen', $bg_color = 'silver') { $bar = round($current / $maximum * 100); return <<
$current / $maximum
HTML; } function echoscroll($slot) { global $user; if ($user['battle']) { $script = 'fbattle'; } else { $script = 'main'; } $all_magic = 0; if ($user['battle'] > 0) { $bat = db::c()->query('SELECT `magic` FROM `battle` WHERE `id` = ?i', $user['battle'])->fetch_assoc(); $all_magic = unserialize($bat['magic']); } $dress = db::c()->query('SELECT `id`, `magic`, `name`, `img`, `duration`, `maxdur` FROM `inventory` WHERE `id` = ?i', $user[$slot])->fetch_assoc(); $need_charge = db::c()->query('SELECT `needcharge` FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc(); if (($user[$slot] > 0) && ($all_magic[$user['id']] < 1 || $need_charge['needcharge'] == 0)) { $row['id'] = $user[$slot]; if ($dress['magic']) { $magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc(); echo ""; } echo ''; } elseif (($user[$slot] > 0) && ($all_magic[$user['id']] >= 1) && $need_charge['needcharge'] > 0) { echo ""; } else { echo ""; } } // ссылка на магию function showhrefmagic($dress) { $user = db::c()->query('SELECT `battle` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc(); $magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $dress['includemagic'])->fetch_assoc(); $r = ''; $script = 'main'; if ($user['battle']) { $script = 'fbattle'; } $r .= ""; $r .= "На оружии выгравировано '{$dress['text']}'" : "") . "\">
"; return $r; } 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 show_eff_inf($u, $type) { $img = [ 1 => "travma.gif", 2 => "magic/sleep.gif", 3 => "magic/sleepf.gif", 4 => "magic/haos.gif", 5 => "magic/obezl.gif", 6 => "expx15.gif", 7 => "euphoria.png", 8 => "sleep_obj.gif", 10 => "magic/chains.gif", 11 => "travma.gif", 12 => "travma.gif", 13 => "travma.gif", 14 => "travma.gif", 20 => "check.gif", 21 => "magic/al_neut_power.gif", 22 => "magic/fist_def.gif", 201 => "magic/defence.gif", 202 => "magic/devastate.gif", 203 => "magic/spell_luck.gif", 215 => "magic/wis_air_def1.gif", 216 => "magic/wis_air_def2.gif", 217 => "magic/wis_air_def3.gif", 218 => "magic/wis_earth_def1.gif", 219 => "magic/wis_earth_def2.gif", 220 => "magic/wis_earth_def3.gif", 221 => "magic/wis_fire_def1.gif", 222 => "magic/wis_fire_def2.gif", 223 => "magic/wis_fire_def3.gif", 224 => "magic/wis_water_def1.gif", 225 => "magic/wis_water_def2.gif", 226 => "magic/wis_water_def3.gif", 227 => "magic/attack_defence.gif", 1022 => "sh/hidden.gif", ]; $r = ''; $and = ''; $adds = ''; if ($type == 1) { $and = " AND `type` != 1022"; } $effs = db::c()->query('SELECT * FROM `effects` WHERE `type` <> 20 AND `owner` = ?i' . $and, $u)->fetch_assoc(); /* FIXME Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 132644820 bytes) in /home/combats/web/combats.loc/public_html/functions.php on line 873 * Если на человеке стоит type=20 * */ $etype = $effs['type']; if ($type == 1) { while ($effs) { if ($etype == 11 || $etype == 12 || $etype == 13 || $etype == 14) { if ($etype == 11) { $adds = 'Легкая '; } elseif ($etype == 12) { $adds = 'Средняя '; } elseif ($etype == 13) { $adds = 'Тяжелая '; } elseif ($etype == 14) { $adds = 'Неизлечимая '; } else { $adds = ''; } } else { $adds = ''; } $r .= '
'; $r .= ''; $r .= '' . $adds . $effs['name'] . ''; if ($effs['sleep'] != 0) { $r .= '
Эффект заморожен
'; } else { $r .= '
' . timeOut($effs['time'] - time()) . '
'; } $r .= '
'; } } else { while ($effs) { $r .= '
'; $r .= ' '; $r .= '' . $adds . $effs['name'] . ''; if ($effs['sleep'] != 0) { $r .= '
Эффект заморожен
'; } else { $r .= '
' . timeOut($effs['time'] - time()) . '
'; } $r .= '
'; } } return $r; } function timetoheals($user) { $efs = db::c()->query('SELECT SUM(`speed`) AS `speed` FROM `effects` WHERE `owner` = ?i', $user['id'])->fetch_assoc_array(); $efs['speed'] += 0; if ($efs['speed'] > 0) { $fulltime = $efs['speed'] * 2000; } else { $fulltime = 2000; } return $fulltime; } /** * Функция отображения персонажа для других персонажей везде и для себя в бою. * * @param $id * @param int $battle - в бою ли персонаж * @param int $me - на себя ли я смотрю * * @return string */ function showinf_pers($id, $battle = 0, $me = 0) //FIXME 37 запросов! ТРИДЦАТЬ СЕМЬ! Чтобы отобразить предметы на персонаже. { global $rooms; $r = ''; $user = db::c()->query('SELECT * FROM `users` WHERE `id` = ?i', $id)->fetch_assoc(); function item($image, $bg_color = '#AAA', $border_color = '#EEE') { return ''; } if ($id > _BOTSEPARATOR_) { // Если ID большой, берём бота из базы ботов, подставляем имя и здоровье из прототипа в юзерах. $bots = db::c()->query('SELECT `name`, `hp` FROM `bots` WHERE `id` = ?i', $id)->fetch_assoc(); $user = db::c()->query('SELECT * FROM `users` WHERE `id` = (SELECT `prototype` FROM `bots` WHERE `bots`.`id` = ?i)', $id)->fetch_assoc(); $user['login'] = $bots['name']; $user['hp'] = $bots['hp']; } else { $invis = $user['invis']; } if ($invis && $user['id'] != $_SESSION['uid']) { $r = << невидимка

HTML; } else { $r .= '
'; if (!empty($user['align'])) { $r .= " "; } if ($user['block']) { $r .= "{$user['login']}"; } else { $r .= "$user[login] "; } if (!empty($user['klan'])) { $r .= " "; } $r .= '
'; $r .= showProgressBar($user['hp'], $user['maxhp']); $r .= ""; $r .= ''; $r .= '
'; $r .= '
'; if ($user['sergi'] > 0) { $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['sergi'])->fetch_assoc(); if ($dress['includemagicdex'] && ($battle && $me)) { $r .= showhrefmagic($dress); } else { $r .= '" . ((!empty($dress['text'])) ? "
{$dress['text']}" : "") . '" />'; } } else { #$r .= ''; $r .= item('i/1x1.gif'); } $r .= '
'; if ($user['kulon'] > 0) { $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['kulon'])->fetch_assoc(); if ($dress['includemagicdex'] && ($battle && $me)) { $r .= showhrefmagic($dress); } else { $r .= '" . ((!empty($dress['text'])) ? "
{$dress['text']}" : "") . '" />'; } } else { #$r .= ''; $r .= item('i/1x1.gif'); } $r .= '
'; if ($user['weap'] > 0) { $dress = db::c()->query('SELECT `minu`, `maxu`, `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['weap'])->fetch_assoc(); if ($dress['includemagicdex'] && ($battle && $me)) { $r .= showhrefmagic($dress); } else { $r .= '" . ((!empty($dress['text'])) ? "
{$dress['text']}" : "") . '" />'; } } else { #$r .= ''; $r .= item('i/1x1.gif'); } $r .= '
'; if ($user['bron'] > 0 || $user['rybax'] > 0 || $user['plaw'] > 0) { $d = ''; $title = ''; if ($user['plaw']) { $d = $user['plaw']; if ($user['bron']) { $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['bron'])->fetch_assoc(); $title .= '
--------------------
' . $dress['name'] . '' . ((!empty($dress['text'])) ? "
{$dress['text']}" : ""); } if ($user['rybax']) { $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['rybax'])->fetch_assoc(); $title .= '
--------------------
' . $dress['name'] . '' . ((!empty($dress['text'])) ? "
{$dress['text']}" : ""); } } elseif ($user['bron']) { $d = $user['bron']; if ($user['rybax']) { $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['rybax'])->fetch_assoc(); $title .= '
--------------------
' . $dress['name'] . '' . ((!empty($dress['text'])) ? "
{$dress['text']}" : ""); } } elseif ($user['rybax']) { $d = $user['rybax']; } $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $d)->fetch_assoc(); if ($dress['includemagicdex'] && $battle && $me) { $r .= showhrefmagic($dress); } else { $r .= '" . ((!empty($dress['text'])) ? "
{$dress['text']}" : "") . '" />'; } } else { #$r .= ''; $r .= item('i/1x1.gif'); } $r .= '
'; if ($user['helm'] > 0) { $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['helm'])->fetch_assoc(); if ($dress['includemagicdex'] && ($battle && $me)) { $r .= showhrefmagic($dress); } else { $r .= '" . ((!empty($dress['text'])) ? "
{$dress['text']}" : "") . '" />'; } } else { #$r .= ''; $r .= item('i/1x1.gif'); } $r .= '
'; if ($user['perchi'] > 0) { $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['perchi'])->fetch_assoc(); if ($dress['includemagicdex'] && ($battle && $me)) { $r .= showhrefmagic($dress); } else { $r .= '" . ((!empty($dress['text'])) ? "
{$dress['text']}" : "") . '" />'; } } else { #$r .= 'Пустой слот Перчатки'; $r .= item('i/1x1.gif'); } $r .= '
'; if ($user['shit'] > 0) { $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['shit'])->fetch_assoc(); if ($dress['includemagicdex'] && ($battle && $me)) { $r .= showhrefmagic($dress); } else { $r .= '" . ((!empty($dress['text'])) ? "
{$dress['text']}" : "") . '" />'; } } else { #$r .= ''; $r .= item('i/1x1.gif'); } $r .= '
'; if ($user['boots'] > 0) { $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['boots'])->fetch_assoc(); if ($dress['includemagicdex'] && ($battle && $me)) { $r .= showhrefmagic($dress); } else { $r .= '" . ((!empty($dress['text'])) ? "
{$dress['text']}" : "") . '" />'; } } else { #$r .= ''; $r .= item('i/1x1.gif'); } $data = db::c()->query('SELECT * FROM `online` WHERE `date` >= ?i AND `id` = ?i', time() - 60, $user['id'])->fetch_assoc(); $r .= '
'; $r .= '
'; // TODO Не забыть включить отображение всплывашки с названием предмета! if ($user['r1'] > 0) { $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['r1'])->fetch_assoc(); if ($dress['includemagicdex'] && ($battle && $me)) { $r .= showhrefmagic($dress); } else { #$r .= '" . ((!empty($dress['text'])) ? "
{$dress['text']}" : "") . '" />'; $r .= item('i/sh/' . $dress['img']) . " "; } } else { #$r .= ''; $r .= item('i/1x1.gif') . " "; } if ($user['r2'] > 0) { $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['r2'])->fetch_assoc(); if ($dress['includemagicdex'] && ($battle && $me)) { $r .= showhrefmagic($dress); } else { #$r .= '" . ((!empty($dress['text'])) ? "
{$dress['text']}" : "") . '" />'; $r .= item('i/sh/' . $dress['img']) . " "; } } else { #$r .= ''; $r .= item('i/1x1.gif') . " "; } if ($user['r3'] > 0) { $dress = db::c()->query('SELECT `name`, `img`, `duration`, `maxdur`, `ghp`, `text`, `includemagicdex` FROM `inventory` WHERE `id` = ?i', $user['r3'])->fetch_assoc(); if ($dress['includemagicdex'] && ($battle && $me)) { $r .= showhrefmagic($dress); } else { #$r .= '" . ((!empty($dress['text'])) ? "
{$dress['text']}" : "") . '" />'; $r .= item('i/sh/' . $dress['img']) . " "; } } else { #$r .= ''; $r .= item('i/1x1.gif') . " "; } $r .= '
'; $r .= '
'; if (!$battle) { $r .= ''; $r .= '
' . GAMEDOMAIN . '
'; if ($data['id'] != null && $user['id'] != 326) { if ($data['room'] > 500 && $data['room'] < 561) { $rrm = 'Башня смерти, участвует в турнире'; } else { $rrm = $rooms[$data['room']]; } $r .= '
Персонаж сейчас находится в игре."' . $rrm . '"
'; } else { $r .= '
Персонаж не в игре.
'; } if ($user['battle'] > 0 && $user['invis'] == 0) { $r .= '
Персонаж сейчас в поединке'; } $r .= ''; $r .= '
'; $r .= show_eff_inf($user['id'], 1); $r .= '
'; $r .= ''; $r .= 'Сила: ' . $user['sila'] . '
'; $r .= 'Ловкость: ' . $user['lovk'] . '
'; $r .= 'Интуиция: ' . $user['inta'] . '
'; $r .= 'Выносливость: ' . $user['vinos'] . '
'; $r .= 'Интеллект: ' . $user['intel'] . '
'; $r .= 'Мудрость: ' . $user['mudra'] . '
'; $r .= '

'; $r .= 'Уровень: ' . $user['level'] . '
'; $r .= 'Побед: ' . $user['win'] . '
'; $r .= 'Поражений: ' . $user['lose'] . '
'; $r .= 'Ничьих: ' . $user['nich'] . '
'; if ($user['klan']) { $clann = db::c()->query('SELECT `name`, `glava` FROM `clans` WHERE `id` = ?i', $user['klan'])->fetch_assoc(); $r .= $clann['name']; if ($clann['glava'] == $user['id']) { $r .= " - Глава клана
"; } elseif (!empty($user['status'])) { $r .= " - " . $user['status'] . "
"; } } if ($user['borntime']) { $date1 = explode(" ", $user['borntime']); $date2 = explode("-", $date1[0]); $date3 = "" . $date2[2] . "-" . $date2[1] . "-" . $date2[0] . ""; $r .= 'День рождения персонажа: ' . $date3 . '
'; } if ($user['palcom']) { $r .= "
{$user['palcom']}"; } $r .= '
'; } else { $r .= ''; $r .= 'Сила: ' . $user['sila'] . '
'; $r .= 'Ловкость: ' . $user['lovk'] . '
'; $r .= 'Интуиция: ' . $user['inta'] . '
'; $r .= 'Выносливость: ' . $user['vinos'] . '
'; $r .= 'Интеллект: ' . $user['intel'] . '
'; $r .= 'Мудрость: ' . $user['mudra'] . '
'; $r .= ''; } } return $r; } /** * Смотрим на себя в главном окне игры. * * @param int $pas */ function showpersout($pas = 0) //FIXME Сделать по человечески! { global $user; echo '
'; nick::id($user['id'])->full(); if ($user['block']) { echo "
Персонаж заблокирован!"; } ?> 3) && !$pas): ?>
0) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['sergi'])->fetch_assoc(); if ($dress['includemagicdex'] && !$pas) { echo showhrefmagic($dress); } else { echo ' 2 && !$pas) ? " style='background-image:url(i/blink.gif);' " : "") . ' src="i/sh/' . $dress['img'] . '" width=60 height=20 title="' . $dress['name'] . "
Прочность " . $dress['duration'] . "/" . $dress['maxdur'] . "" . "" . (($dress['ghp'] > 0) ? "
Уровень жизни " . plusorminus($dress['ghp']) : "") . (($dress['text'] != null) ? "
На серьгах выгравировано '{$dress['text']}'" : "") . (($dress['gsila'] != 0) ? "
Сила " . plusorminus($dress['gsila']) : "") . (($dress['glovk'] != 0) ? "
Ловкость " . plusorminus($dress['glovk']) : "") . (($dress['ginta'] != 0) ? "
Интуиция " . plusorminus($dress['ginta']) : "") . (($dress['gintel'] != 0) ? "
Интеллект " . plusorminus($dress['gintel']) : "") . (($dress['bron1'] != 0) ? "
Броня головы: " . plusorminus($dress['bron1']) : "") . (($dress['bron2'] != 0) ? "
Броня корпуса: " . plusorminus($dress['bron2']) : "") . (($dress['bron3'] != 0) ? "
Броня пояса: " . plusorminus($dress['bron3']) : "") . (($dress['bron4'] != 0) ? "
Броня ног: " . plusorminus($dress['bron4']) : "") . '" />'; } } else { echo ''; } ?>
0) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['kulon'])->fetch_assoc(); if ($dress['includemagicdex'] && !$pas) { echo showhrefmagic($dress); } else { echo ' 2 && !$pas) ? " style='background-image:url(i/blink.gif);' " : "") . ' src="i/sh/' . $dress['img'] . '" width=60 height=20 title="' . $dress['name'] . "
Прочность " . $dress['duration'] . "/" . $dress['maxdur'] . "" . "" . (($dress['ghp'] > 0) ? "
Уровень жизни " . plusorminus($dress['ghp']) : "") . (($dress['text'] != null) ? "
На ожерелье выгравировано '{$dress['text']}'" : "") . (($dress['gsila'] != 0) ? "
Сила " . plusorminus($dress['gsila']) : "") . (($dress['glovk'] != 0) ? "
Ловкость " . plusorminus($dress['glovk']) : "") . (($dress['ginta'] != 0) ? "
Интуиция " . plusorminus($dress['ginta']) : "") . (($dress['gintel'] != 0) ? "
Интеллект " . plusorminus($dress['gintel']) : "") . (($dress['bron1'] != 0) ? "
Броня головы: " . plusorminus($dress['bron1']) : "") . (($dress['bron2'] != 0) ? "
Броня корпуса: " . plusorminus($dress['bron2']) : "") . (($dress['bron3'] != 0) ? "
Броня пояса: " . plusorminus($dress['bron3']) : "") . (($dress['bron4'] != 0) ? "
Броня ног: " . plusorminus($dress['bron4']) : "") . '" />'; } } else { echo ''; } ?>
0) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['weap'])->fetch_assoc(); if ($dress['includemagicdex'] && !$pas) { echo showhrefmagic($dress); } else { echo ' 2 && !$pas) ? " style='background-image:url(i/blink.gif);' " : "") . ' src="i/sh/' . $dress['img'] . '" width=60 height=60 title="' . $dress['name'] . "
Прочность " . $dress['duration'] . "/" . $dress['maxdur'] . "" . "" . (($dress['ghp'] > 0) ? "
Уровень жизни " . plusorminus($dress['ghp']) : "") . (($dress['minu'] > 0) ? "
Урон {$dress['minu']}-{$dress['maxu']}" : "") . (($dress['text'] != null) ? "
На оружии выгравировано '{$dress['text']}'" : "") . (($dress['gsila'] != 0) ? "
Сила " . plusorminus($dress['gsila']) : "") . (($dress['glovk'] != 0) ? "
Ловкость " . plusorminus($dress['glovk']) : "") . (($dress['ginta'] != 0) ? "
Интуиция " . plusorminus($dress['ginta']) : "") . (($dress['gintel'] != 0) ? "
Интеллект " . plusorminus($dress['gintel']) : "") . (($dress['bron1'] != 0) ? "
Броня головы: " . plusorminus($dress['bron1']) : "") . (($dress['bron2'] != 0) ? "
Броня корпуса: " . plusorminus($dress['bron2']) : "") . (($dress['bron3'] != 0) ? "
Броня пояса: " . plusorminus($dress['bron3']) : "") . (($dress['bron4'] != 0) ? "
Броня ног: " . plusorminus($dress['bron4']) : "") . '" />'; } } else { echo ''; } ?>
0 || $user['rybax'] > 0 || $user['plaw'] > 0) { $title = ''; $d = ''; if ($user['plaw']) { $d = $user['plaw']; if ($user['bron']) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['bron'])->fetch_assoc(); $title .= '
--------------------
' . $dress['name'] . '
Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '' . (($dress['ghp'] > 0) ? '
Уровень жизни ' . plusorminus($dress['ghp']) : '') . (($dress['text'] != null) ? '
На одежде вышито ' . $dress['text'] . '' : '') . (($dress['gsila'] != 0) ? '
Сила ' . plusorminus($dress['gsila']) . '' : '') . (($dress['glovk'] != 0) ? '
Ловкость ' . plusorminus($dress['glovk']) . '' : '') . (($dress['ginta'] != 0) ? '
Интуиция ' . plusorminus($dress['ginta']) . '' : '') . (($dress['gintel'] != 0) ? '
Интеллект ' . plusorminus($dress['gintel']) . '' : '') . (($dress['bron1'] != 0) ? '
Броня головы: ' . plusorminus($dress['bron1']) . '' : '') . (($dress['bron2'] != 0) ? '
Броня корпуса: ' . plusorminus($dress['bron2']) . '' : '') . (($dress['bron3'] != 0) ? '
Броня пояса: ' . plusorminus($dress['bron3']) . '' : '') . (($dress['bron4'] != 0) ? '
Броня ног: ' . plusorminus($dress['bron4']) . '' : ''); } if ($user['rybax']) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['rybax'])->fetch_assoc(); $title .= '
--------------------
' . $dress['name'] . '
Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '' . (($dress['ghp'] > 0) ? '
Уровень жизни ' . plusorminus($dress['ghp']) : '') . (($dress['text'] != null) ? '
На одежде вышито ' . $dress['text'] . '' : '') . (($dress['gsila'] != 0) ? '
Сила ' . plusorminus($dress['gsila']) . '' : '') . (($dress['glovk'] != 0) ? '
Ловкость ' . plusorminus($dress['glovk']) . '' : '') . (($dress['ginta'] != 0) ? '
Интуиция ' . plusorminus($dress['ginta']) . '' : '') . (($dress['gintel'] != 0) ? '
Интеллект ' . plusorminus($dress['gintel']) . '' : '') . (($dress['bron1'] != 0) ? '
Броня головы: ' . plusorminus($dress['bron1']) . '' : '') . (($dress['bron2'] != 0) ? '
Броня корпуса: ' . plusorminus($dress['bron2']) . '' : '') . (($dress['bron3'] != 0) ? '
Броня пояса: ' . plusorminus($dress['bron3']) . '' : '') . (($dress['bron4'] != 0) ? '
Броня ног: ' . plusorminus($dress['bron4']) . '' : ''); } } elseif ($user['bron']) { $d = $user['bron']; if ($user['rybax']) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['rybax'])->fetch_assoc(); $title .= "
--------------------
$dress[name]
Прочность $dress[duration]/$dress[maxdur]" . (($dress['ghp'] > 0) ? "
Уровень жизни " . plusorminus($dress['ghp']) : "") . (($dress['text'] != null) ? "
На одежде вышито '{$dress['text']}'" : "") . (($dress['gsila'] != 0) ? "
Сила " . plusorminus($dress['gsila']) : "") . (($dress['glovk'] != 0) ? "
Ловкость " . plusorminus($dress['glovk']) : "") . (($dress['ginta'] != 0) ? "
Интуиция " . plusorminus($dress['ginta']) : "") . (($dress['gintel'] != 0) ? "
Интеллект " . plusorminus($dress['gintel']) : "") . (($dress['bron1'] != 0) ? "
Броня головы: " . plusorminus($dress['bron1']) : "") . (($dress['bron2'] != 0) ? "
Броня корпуса: " . plusorminus($dress['bron2']) : "") . (($dress['bron3'] != 0) ? "
Броня пояса: " . plusorminus($dress['bron3']) : "") . (($dress['bron4'] != 0) ? "
Броня ног: " . plusorminus($dress['bron4']) : "") . '"'; } } elseif ($user['rybax']) { $d = $user['rybax']; } $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $d)->fetch_assoc(); if ($dress['includemagicdex'] && !$pas) { echo showhrefmagic($dress); } else { echo ' 2 && !$pas) ? " style='background-image:url(i/blink.gif);' " : "") . ' src="i/sh/' . $dress['img'] . '" width=60 height=80 title="' . $dress['name'] . "
Прочность " . $dress['duration'] . "/" . $dress['maxdur'] . "" . "" . (($dress['ghp'] > 0) ? "
Уровень жизни " . plusorminus($dress['ghp']) : "") . (($dress['text'] != null) ? "
На одежде вышито '{$dress['text']}'" : "") . (($dress['gsila'] != 0) ? "
Сила " . plusorminus($dress['gsila']) : "") . (($dress['glovk'] != 0) ? "
Ловкость " . plusorminus($dress['glovk']) : "") . (($dress['ginta'] != 0) ? "
Интуиция " . plusorminus($dress['ginta']) : "") . (($dress['gintel'] != 0) ? "
Интеллект " . plusorminus($dress['gintel']) : "") . (($dress['bron1'] != 0) ? "
Броня головы: " . plusorminus($dress['bron1']) : "") . (($dress['bron2'] != 0) ? "
Броня корпуса: " . plusorminus($dress['bron2']) : "") . (($dress['bron3'] != 0) ? "
Броня пояса: " . plusorminus($dress['bron3']) : "") . (($dress['bron4'] != 0) ? "
Броня ног: " . plusorminus($dress['bron4']) : "") . $title . '" />'; } } else { echo ''; } ?>
0) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['r1'])->fetch_assoc(); if ($dress['includemagicdex'] && !$pas) { showhrefmagic($dress); } else { echo ' 2 && !$pas) ? " style='background-image:url(i/blink.gif);' " : "") . ' src="i/sh/' . $dress['img'] . '" width=20 height=20 title="' . $dress['name'] . "
Прочность " . $dress['duration'] . "/" . $dress['maxdur'] . "" . "" . (($dress['ghp'] > 0) ? "
Уровень жизни " . plusorminus($dress['ghp']) : "") . (($dress['text'] != null) ? "
На кольце выгравировано '{$dress['text']}'" : "") . (($dress['gsila'] != 0) ? "
Сила " . plusorminus($dress['gsila']) : "") . (($dress['glovk'] != 0) ? "
Ловкость " . plusorminus($dress['glovk']) : "") . (($dress['ginta'] != 0) ? "
Интуиция " . plusorminus($dress['ginta']) : "") . (($dress['gintel'] != 0) ? "
Интеллект " . plusorminus($dress['gintel']) : "") . (($dress['bron1'] != 0) ? "
Броня головы: " . plusorminus($dress['bron1']) : "") . (($dress['bron2'] != 0) ? "
Броня корпуса: " . plusorminus($dress['bron2']) : "") . (($dress['bron3'] != 0) ? "
Броня пояса: " . plusorminus($dress['bron3']) : "") . (($dress['bron4'] != 0) ? "
Броня ног: " . plusorminus($dress['bron4']) : "") . '" />'; } } else { echo ''; } ?>
0) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['r2'])->fetch_assoc(); if ($dress['includemagicdex'] && !$pas) { echo showhrefmagic($dress); } else { echo ' 2 && !$pas) ? " style='background-image:url(i/blink.gif);' " : "") . ' src="i/sh/' . $dress['img'] . '" width=20 height=20 title="' . $dress['name'] . "
Прочность " . $dress['duration'] . "/" . $dress['maxdur'] . "" . "" . (($dress['ghp'] > 0) ? "
Уровень жизни " . plusorminus($dress['ghp']) : "") . (($dress['text'] != null) ? "
На кольце выгравировано '{$dress['text']}'" : "") . (($dress['gsila'] != 0) ? "
Сила " . plusorminus($dress['gsila']) : "") . (($dress['glovk'] != 0) ? "
Ловкость " . plusorminus($dress['glovk']) : "") . (($dress['ginta'] != 0) ? "
Интуиция " . plusorminus($dress['ginta']) : "") . (($dress['gintel'] != 0) ? "
Интеллект " . plusorminus($dress['gintel']) : "") . (($dress['bron1'] != 0) ? "
Броня головы: " . plusorminus($dress['bron1']) : "") . (($dress['bron2'] != 0) ? "
Броня корпуса: " . plusorminus($dress['bron2']) : "") . (($dress['bron3'] != 0) ? "
Броня пояса: " . plusorminus($dress['bron3']) : "") . (($dress['bron4'] != 0) ? "
Броня ног: " . plusorminus($dress['bron4']) : "") . '" />'; } } else { echo ''; } ?>
0) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['r3'])->fetch_assoc(); if ($dress['includemagicdex'] && !$pas) { echo showhrefmagic($dress); } else { echo ' 2 && !$pas) ? " style='background-image:url(i/blink.gif);' " : "") . ' src="i/sh/' . $dress['img'] . '" width=20 height=20 title="' . $dress['name'] . "
Прочность " . $dress['duration'] . "/" . $dress['maxdur'] . "" . "" . (($dress['ghp'] > 0) ? "
Уровень жизни " . plusorminus($dress['ghp']) : "") . (($dress['text'] != null) ? "
На кольце выгравировано '{$dress['text']}'" : "") . (($dress['gsila'] != 0) ? "
Сила " . plusorminus($dress['gsila']) : "") . (($dress['glovk'] != 0) ? "
Ловкость " . plusorminus($dress['glovk']) : "") . (($dress['ginta'] != 0) ? "
Интуиция " . plusorminus($dress['ginta']) : "") . (($dress['gintel'] != 0) ? "
Интеллект " . plusorminus($dress['gintel']) : "") . (($dress['bron1'] != 0) ? "
Броня головы: " . plusorminus($dress['bron1']) : "") . (($dress['bron2'] != 0) ? "
Броня корпуса: " . plusorminus($dress['bron2']) : "") . (($dress['bron3'] != 0) ? "
Броня пояса: " . plusorminus($dress['bron3']) : "") . (($dress['bron4'] != 0) ? "
Броня ног: " . plusorminus($dress['bron4']) : "") . '" />'; } } else { echo ''; } ?>
<?= $user['login'] ?>
0) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['helm'])->fetch_assoc(); if ($dress['includemagicdex'] && !$pas) { echo showhrefmagic($dress); } else { echo ' 2 && !$pas) ? " style='background-image:url(i/blink.gif);' " : "") . ' src="i/sh/' . $dress['img'] . '" width=60 height=60 title="' . $dress['name'] . "
Прочность " . $dress['duration'] . "/" . $dress['maxdur'] . "" . "" . (($dress['ghp'] > 0) ? "
Уровень жизни " . plusorminus($dress['ghp']) : "") . (($dress['text'] != null) ? "
На шлеме выгравировано '{$dress['text']}'" : "") . (($dress['gsila'] != 0) ? "
Сила " . plusorminus($dress['gsila']) : "") . (($dress['glovk'] != 0) ? "
Ловкость " . plusorminus($dress['glovk']) : "") . (($dress['ginta'] != 0) ? "
Интуиция " . plusorminus($dress['ginta']) : "") . (($dress['gintel'] != 0) ? "
Интеллект " . plusorminus($dress['gintel']) : "") . (($dress['bron1'] != 0) ? "
Броня головы: " . plusorminus($dress['bron1']) : "") . (($dress['bron2'] != 0) ? "
Броня корпуса: " . plusorminus($dress['bron2']) : "") . (($dress['bron3'] != 0) ? "
Броня пояса: " . plusorminus($dress['bron3']) : "") . (($dress['bron4'] != 0) ? "
Броня ног: " . plusorminus($dress['bron4']) : "") . '" />'; } } else { echo ''; } ?>
0) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['perchi'])->fetch_assoc(); if ($dress['includemagicdex'] && !$pas) { echo showhrefmagic($dress); } else { echo ' 2 && !$pas) ? " style='background-image:url(i/blink.gif);' " : "") . ' src="i/sh/' . $dress['img'] . '" width=60 height=40 title="' . $dress['name'] . "
Прочность " . $dress['duration'] . "/" . $dress['maxdur'] . "" . "" . (($dress['ghp'] > 0) ? "
Уровень жизни " . plusorminus($dress['ghp']) : "") . (($dress['text'] != null) ? "
На перчатках выгравировано '{$dress['text']}'" : "") . (($dress['gsila'] != 0) ? "
Сила " . plusorminus($dress['gsila']) : "") . (($dress['glovk'] != 0) ? "
Ловкость " . plusorminus($dress['glovk']) : "") . (($dress['ginta'] != 0) ? "
Интуиция " . plusorminus($dress['ginta']) : "") . (($dress['gintel'] != 0) ? "
Интеллект " . plusorminus($dress['gintel']) : "") . '" />'; } } else { echo 'Пустой слот Перчатки'; } ?>
0) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['shit'])->fetch_assoc(); if ($dress['includemagicdex'] && !$pas) { echo showhrefmagic($dress); } else { echo ' 2 && !$pas) ? " style='background-image:url(i/blink.gif);' " : "") . ' src="i/sh/' . $dress['img'] . '" width=60 height=60 title="' . $dress['name'] . "
Прочность " . $dress['duration'] . "/" . $dress['maxdur'] . "" . "" . (($dress['ghp'] > 0) ? "
Уровень жизни " . plusorminus($dress['ghp']) : "") . (($dress['text'] != null) ? "
На щите выгравировано '{$dress['text']}'" : "") . (($dress['gsila'] != 0) ? "
Сила " . plusorminus($dress['gsila']) : "") . (($dress['glovk'] != 0) ? "
Ловкость " . plusorminus($dress['glovk']) : "") . (($dress['ginta'] != 0) ? "
Интуиция " . plusorminus($dress['ginta']) : "") . (($dress['gintel'] != 0) ? "
Интеллект " . plusorminus($dress['gintel']) : "") . (($dress['bron1'] != 0) ? "
Броня головы: " . plusorminus($dress['bron1']) : "") . (($dress['bron2'] != 0) ? "
Броня корпуса: " . plusorminus($dress['bron2']) : "") . (($dress['bron3'] != 0) ? "
Броня пояса: " . plusorminus($dress['bron3']) : "") . (($dress['bron4'] != 0) ? "
Броня ног: " . plusorminus($dress['bron4']) : "") . '" />'; } } else { echo ''; } ?>
0) { $dress = db::c()->query('SELECT * FROM `inventory` WHERE `id` = ?i', $user['boots'])->fetch_assoc(); if ($dress['includemagicdex'] && !$pas) { echo showhrefmagic($dress); } else { echo ' 2 && !$pas) ? " style='background-image:url(i/blink.gif);' " : "") . ' src="i/sh/' . $dress['img'] . '" width=60 height=40 title="' . $dress['name'] . "
Прочность " . $dress['duration'] . "/" . $dress['maxdur'] . "" . "" . (($dress['ghp'] > 0) ? "
Уровень жизни " . plusorminus($dress['ghp']) : "") . (($dress['text'] != null) ? "
На ботинках выгравировано '{$dress['text']}'" : "") . (($dress['gsila'] != 0) ? "
Сила " . plusorminus($dress['gsila']) : "") . (($dress['glovk'] != 0) ? "
Ловкость " . plusorminus($dress['glovk']) : "") . (($dress['ginta'] != 0) ? "
Интуиция " . plusorminus($dress['ginta']) : "") . (($dress['gintel'] != 0) ? "
Интеллект " . plusorminus($dress['gintel']) : "") . (($dress['bron1'] != 0) ? "
Броня головы: " . plusorminus($dress['bron1']) : "") . (($dress['bron2'] != 0) ? "
Броня корпуса: " . plusorminus($dress['bron2']) : "") . (($dress['bron3'] != 0) ? "
Броня пояса: " . plusorminus($dress['bron3']) : "") . (($dress['bron4'] != 0) ? "
Броня ног: " . plusorminus($dress['bron4']) : "") . '" />'; } } else { echo ''; } ?>
"; // } $dd = db::c()->query('SELECT `time`, `type` FROM `effects` WHERE `owner` = ?i', $user['id']); $param_bonus = []; array_fill_keys($param_bonus, 0); while ($row = $dd->fetch_assoc()) { if ($row['time'] < time()) { $row['time'] = time(); } if ($row['type'] == 21) { $param_bonus = []; $param_bonus['sila'] = $row['sila']; $param_bonus['lovk'] = $row['lovk']; $param_bonus['inta'] = $row['inta']; $param_bonus['vinos'] = $row['vinos']; } } ?>
У персонажа $trt травма.
Сила: (+" . $param_bonus['sila'] . ")"; } ?>
Ловкость: (+" . $param_bonus['lovk'] . ")"; } ?>
Интуиция: (+" . $param_bonus['inta'] . ")"; } ?>
Выносливость: (+" . $param_bonus['vinos'] . ")"; } ?>
Интеллект:
Мудрость:
0 || $user['master'] > 0): ?> + Способности
Опыт: ()
Уровень:
Побед:
Поражений:
Ничьих:
query('SELECT SUM(`ekr`) AS `bank_ekr`,SUM(`cr`) AS `bank_cr` FROM `bank` WHERE `id`= ?i', $user['id'])->fetch_assoc(); ?> Деньги: кр.
В банке: кр. / eкр.
"; } } else { ?> Сила:
Ловкость:
Интуиция:
Выносливость:
Интеллект:
Мудрость:
query('LOCK TABLES `actions` WRITE'); $ins = db::c()->query('INSERT INTO `actions` (`uid`,`time`,`city`,`room`,`vars`,`ip`,`vals`) VALUES (?i, ?i, "?s", ?i, "?s", "?s", "?s")', $uid, $time, "capitalcity", 0, $vars, $_SERVER['HTTP_X_REAL_IP'], $vls); db::c()->query('UNLOCK TABLES'); return $ins; } function plusorminus($n, $shownum = 1) { if (empty($shownum)) { if ($n >= 2) { return "++"; } if ($n > 0) { return "+"; } if ($n < 0) { return "-"; } } if ($n >= 0) { return "+$n"; } else { return $n; } } function undressall($id) { for ($i = 1; $i <= 26; $i++) { dropitemid($i, $id); } } function dropitemid($slot, $id) { switch ($slot) { case 1: $slot1 = 'sergi'; break; case 2: $slot1 = 'kulon'; break; case 3: $slot1 = 'weap'; break; case 4: $slot1 = 'bron'; break; case 5: $slot1 = 'r1'; break; case 6: $slot1 = 'r2'; break; case 7: $slot1 = 'r3'; break; case 8: $slot1 = 'helm'; break; case 9: $slot1 = 'perchi'; break; case 10: $slot1 = 'shit'; break; case 11: $slot1 = 'boots'; break; case 12: $slot1 = 'm1'; break; case 13: $slot1 = 'm2'; break; case 14: $slot1 = 'm3'; break; case 15: $slot1 = 'm4'; break; case 16: $slot1 = 'm5'; break; case 17: $slot1 = 'm6'; break; case 18: $slot1 = 'm7'; break; case 19: $slot1 = 'm8'; break; case 20: $slot1 = 'm9'; break; case 21: $slot1 = 'm10'; break; case 22: $slot1 = 'rybax'; break; case 23: $slot1 = 'plaw'; break; default: $slot1 = ''; break; } $checkid = db::c()->query('SELECT 1 FROM `users` WHERE `id` = ?i', $id); if ($checkid->getNumRows()) { if (mysql_query('UPDATE `users`, `inventory` SET `users`.`' . $slot1 . '` = 0, `inventory`.`dressed` = 0, `users`.`sila` = `users`.`sila` - `inventory`.`gsila`, `users`.`lovk` = `users`.`lovk` - `inventory`.`glovk`, `users`.`inta` = `users`.`inta` - `inventory`.`ginta`, `users`.`intel` = `users`.`intel` - `inventory`.`gintel`, `users`.`maxhp` = `users`.`maxhp` - `inventory`.`ghp`, `users`.`noj` = `users`.`noj` - `inventory`.`gnoj`, `users`.`topor` = `users`.`topor` - `inventory`.`gtopor`, `users`.`dubina` = `users`.`dubina` - `inventory`.`gdubina`, `users`.`mec` = `users`.`mec` - `inventory`.`gmech`, `users`.`mfire` = `users`.`mfire` - `inventory`.`gfire`, `users`.`mwater` = `users`.`mwater` - `inventory`.`gwater`, `users`.`mair` = `users`.`mair` - `inventory`.`gair`, `users`.`mearth` = `users`.`mearth` - `inventory`.`gearth`, `users`.`mlight` = `users`.`mlight` - `inventory`.`glight`, `users`.`mgray` = `users`.`mgray` - `inventory`.`ggray`, `users`.`mdark` = `users`.`mdark` - `inventory`.`gdark`, `users`.`fkrit` = `users`.`fkrit` - `inventory`.`mfkrit`, `users`.`fakrit` = `users`.`fakrit` - `inventory`.`mfakrit`, `users`.`fuvorot` = `users`.`fuvorot` - `inventory`.`mfuvorot`, `users`.`fauvorot` = `users`.`fauvorot` - `inventory`.`mfauvorot`, `users`.`ubron1` = `users`.`ubron1` - `inventory`.`bron1`, `users`.`ubron2` = `users`.`ubron2` - `inventory`.`bron2`, `users`.`ubron3` = `users`.`ubron3` - `inventory`.`bron3`, `users`.`ubron4` = `users`.`ubron4` - `inventory`.`bron4`, `users`.`uminu` = `users`.`uminu` - `inventory`.`minu`, `users`.`umaxu` = `users`.`umaxu` - `inventory`.`maxu` WHERE `inventory`.`id` = `users`.`' . $slot1 . '` AND `inventory`.`dressed` = 1 AND `inventory`.`owner` = "' . $id . '" AND `users`.`id` = "' . $id . '"')) { db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $id); $user[$slot1] = 0; } return true; } else { return false; } } // снять предмет function dropitem($slot) { global $user; $wear_arr = []; switch ($slot) { case 1: $slot1 = 'sergi'; break; case 2: $slot1 = 'kulon'; break; case 3: $slot1 = 'weap'; break; case 4: $slot1 = 'bron'; break; case 5: $slot1 = 'r1'; break; case 6: $slot1 = 'r2'; break; case 7: $slot1 = 'r3'; break; case 8: $slot1 = 'helm'; break; case 9: $slot1 = 'perchi'; break; case 10: $slot1 = 'shit'; break; case 11: $slot1 = 'boots'; break; case 12: $slot1 = 'm1'; break; case 13: $slot1 = 'm2'; break; case 14: $slot1 = 'm3'; break; case 15: $slot1 = 'm4'; break; case 16: $slot1 = 'm5'; break; case 17: $slot1 = 'm6'; break; case 18: $slot1 = 'm7'; break; case 19: $slot1 = 'm8'; break; case 20: $slot1 = 'm9'; break; case 21: $slot1 = 'm10'; break; case 22: $slot1 = 'rybax'; break; case 23: $slot1 = 'plaw'; break; default: $slot1 = ''; break; } { if (db::c()->query('UPDATE `users` as `u`, `inventory` as `i` SET `u`.?f = 0, `i`.`dressed` = 0, `u`.`sila` = `u`.`sila` - `i`.`gsila`, `u`.`lovk` = `u`.`lovk` - `i`.`glovk`, `u`.`inta` = `u`.`inta` - `i`.`ginta`, `u`.`intel` = `u`.`intel` - `i`.`gintel`, `u`.`maxhp` = `u`.`maxhp` - `i`.`ghp`, `u`.`noj` = `u`.`noj` - `i`.`gnoj`, `u`.`topor` = `u`.`topor` - `i`.`gtopor`, `u`.`dubina` = `u`.`dubina` - `i`.`gdubina`, `u`.`mec` = `u`.`mec` - `i`.`gmech`, `u`.`mfire` = `u`.`mfire` - `i`.`gfire`, `u`.`mwater` = `u`.`mwater` - `i`.`gwater`, `u`.`mair` = `u`.`mair` - `i`.`gair`, `u`.`mearth` = `u`.`mearth` - `i`.`gearth`, `u`.`mlight` = `u`.`mlight` - `i`.`glight`, `u`.`mgray` = `u`.`mgray` - `i`.`ggray`, `u`.`mdark` = `u`.`mdark` - `i`.`gdark`, `u`.`ubron1` = `u`.`ubron1` - `i`.`bron1`, `u`.`ubron2` = `u`.`ubron2` - `i`.`bron2`, `u`.`ubron3` = `u`.`ubron3` - `i`.`bron3`, `u`.`ubron4` = `u`.`ubron4` - `i`.`bron4`, `u`.`fkrit` = `u`.`fkrit` - `i`.`mfkrit`, `u`.`fakrit` = `u`.`fakrit` - `i`.`mfakrit`, `u`.`fuvorot` = `u`.`fuvorot` - `i`.`mfuvorot`, `u`.`fauvorot` = `u`.`fauvorot` - `i`.`mfauvorot`, `u`.`uminu` = `u`.`uminu` - `i`.`minu`, `u`.`umaxu` = `u`.`umaxu` - `i`.`maxu` WHERE `i`.`id` = `u`.?f AND `i`.`dressed` = 1 AND `i`.`owner` = ?i AND u.id = ?i', $slot1, $slot1, $user['id'], $user['id'])) { db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $user['id']); } $wear_raw = db::c()->query('SELECT * FROM `inventory` where `owner` = ?i AND `dressed` = 1', $user['id']); while ($wear_list = $wear_raw->fetch_assoc()) { $wear_arr[] = $wear_list['prototype']; } $item['id'] = $user[$slot1]; $get_pro = db::c()->query('SELECT * FROM `inventory` where `id` = ?i', $item['id'])->fetch_assoc(); ///////////////////// $sets_items = db::c()->query('SELECT * FROM `item_sets`'); //для каждого комплекта while ($items_in_set = $sets_items->fetch_assoc()) { $checker = 0; $temp_is = explode(",", $items_in_set['prot_id']); $set_id = $items_in_set['set_id']; //если прото в комплекте и не одет if (in_array($get_pro['prototype'], $temp_is) && (!in_array($get_pro['prototype'], $wear_arr))) { $checker = 1; //для каждого одетого предмета foreach ($temp_is as $check_proto) { if ($check_proto != $get_pro['prototype'] && !in_array($check_proto, $wear_arr)) { $checker = 0; } } } // if (($checker == 1) && (!in_array($get_pro['prototype'], $wear_arr))) { db::c()->query('UPDATE `users` as `u`, `item_sets` as `s` SET `u`.`uminu` = `u`.`uminu` - `s`.`minu`, `u`.`umaxu` = `u`.`umaxu` - `s`.`maxu`, `u`.`sila = `u`.`sila - `s`.`gsila`, `u`.`lovk = `u`.`lovk - `s`.`glovk`, `u`.`inta = `u`.`inta - `s`.`ginta`, `u`.`intel = `u`.`intel - `s`.`gintel`, `u`.`maxhp = `u`.`maxhp - `s`.`ghp`, `u`.`maxmana = `u`.`maxmana - `s`.`gmana`, `u`.`fkrit = `u`.`fkrit - `s`.`mfkrit`, `u`.`fakrit = `u`.`fakrit - `s`.`mfakrit`, `u`.`fuvorot = `u`.`fuvorot - `s`.`mfuvorot`, `u`.`fauvorot = `u`.`fauvorot - `s`.`mfauvorot`, `u`.`noj = `u`.`noj - `s`.`gnoj`, `u`.`topor = `u`.`topor - `s`.`gtopor`, `u`.`dubina = `u`.`dubina - `s`.`gdubina`, `u`.`mec = `u`.`mec - `s`.`gmech`, `u`.`ubron1 = `u`.`ubron1 - `s`.`bron1`, `u`.`ubron2 = `u`.`ubron2 - `s`.`bron2`, `u`.`ubron3 = `u`.`ubron3 - `s`.`bron3`, `u`.`ubron4 = `u`.`ubron4 - `s`.`bron4`, `u`.`mfire = `u`.`mfire - `s`.`gfire`, `u`.`mwater = `u`.`mwater - `s`.`gwater`, `u`.`mair = `u`.`mair - `s`.`gair`, `u`.`mearth = `u`.`mearth - `s`.`gearth`, `u`.`mlight = `u`.`mlight - `s`.`glight`, `u`.`mgray = `u`.`mgray - `s`.`ggray` WHERE `u`.`id` = ?i AND `s`.`set_id`= ?i', $user['id'], $set_id); } } return true; } } function ref_drop() { # global $user; //сможет держать function derj($id) { //global $user; $user = db::c()->query('SELECT `id`, `align` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc(); $ts = db::c()->query('SELECT `id`, `nalign` FROM `inventory` WHERE `id` = ?i', $id)->fetch_assoc(); $al = '(1 = 1)'; if ($ts['nalign'] == 1.1) { $al = '(1 = 2)'; } $dd = db::c()->query('SELECT `i`.`id` FROM `users` AS `u`, `inventory` AS `i` WHERE `i`.`needident` = 0 AND `i`.`id` = ?i AND `i`.`duration` < `i`.`maxdur` AND `i`.`owner` = ?i AND `u`.`sila` >= `i`.`nsila` AND `u`.`lovk` >= `i`.`nlovk` AND `u`.`inta` >= `i`.`ninta` AND `u`.`vinos` >= `i`.`nvinos` AND `u`.`intel` >= `i`.`nintel` AND `u`.`mudra` >= `i`.`nmudra` AND `u`.`level` >= `i`.`nlevel` AND ("?s" OR (?i = `i`.`nalign`) or (`i`.`nalign` = 0)) AND `u`.`noj` >= `i`.`nnoj` AND `u`.`topor` >= `i`.`ntopor` AND `u`.`dubina` >= `i`.`ndubina` AND `u`.`mec` >= `i`.`nmech` AND `u`.`mfire` >= `i`.`nfire` AND `u`.`mwater` >= `i`.`nwater` AND `u`.`mair` >= `i`.`nair` AND `u`.`mearth` >= `i`.`nearth` AND `u`.`mlight` >= `i`.`nlight` AND `u`.`mgray` >= `i`.`ngray` AND `u`.`mdark` >= `i`.`ndark` AND `i`.`setsale` = 0 AND `u`.`id` = ?i', $id, $user['id'], $al, $user['align'], $user['id']); return $dd->getNumRows() > 0; } $slot = ['sergi', 'kulon', 'weap', 'bron', 'r1', 'r2', 'r3', 'helm', 'perchi', 'shit', 'boots', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm10']; $user = db::c()->query('SELECT `sergi`,`kulon`,`weap`,`bron`,`r1`,`r2`,`r3`,`helm`,`perchi`,`shit`,`boots`,`m1`,`m2`,`m3`,`m4`,`m5`,`m6`,`m7`,`m8`,`m9`,`m10` FROM `users` WHERE id = ?i', $_SESSION['uid'])->fetch_assoc(); for ($i = 0; $i <= 20; $i++) { if ($user[$slot[$i]] && !derj($user[$slot[$i]])) { dropitem($i + 1); $user[$slot[$i]] = null; } } } // убить предмет function destructitem($id) { global $user; $slot1 = ''; $dress = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND `id` = ?i', $user['id'], $id)->fetch_assoc(); switch ($dress['type']) { case 1: $slot1 = 'sergi'; break; case 2: $slot1 = 'kulon'; break; case 3: $slot1 = 'weap'; break; case 4: $slot1 = 'bron'; break; case 5: $slot1 = 'r1'; break; case 6: $slot1 = 'r2'; break; case 7: $slot1 = 'r3'; break; case 8: $slot1 = 'helm'; break; case 9: $slot1 = 'perchi'; break; case 10: $slot1 = 'shit'; break; case 11: $slot1 = 'boots'; break; case 12: $slot1 = 'm1'; break; case 22: $slot1 = 'rybax'; break; case 23: $slot1 = 'plaw'; break; default: $slot1 = 'weap'; break; } if ($dress['type'] == 5) { if ($user['r1'] == $dress['id']) { $slot1 = 'r1'; } elseif ($user['r2'] == $dress['id']) { $slot1 = 'r2'; } elseif ($user['r3'] == $dress['id']) { $slot1 = 'r3'; } } elseif ($dress['type'] == 12) { if ($user['m1'] == $dress['id']) { $slot1 = 'm1'; } elseif ($user['m2'] == $dress['id']) { $slot1 = 'm2'; } elseif ($user['m3'] == $dress['id']) { $slot1 = 'm3'; } elseif ($user['m4'] == $dress['id']) { $slot1 = 'm4'; } elseif ($user['m5'] == $dress['id']) { $slot1 = 'm5'; } elseif ($user['m6'] == $dress['id']) { $slot1 = 'm6'; } elseif ($user['m7'] == $dress['id']) { $slot1 = 'm7'; } elseif ($user['m8'] == $dress['id']) { $slot1 = 'm8'; } elseif ($user['m9'] == $dress['id']) { $slot1 = 'm9'; } elseif ($user['m10'] == $dress['id']) { $slot1 = 'm10'; } } if ($dress['owner'] == $user['id']) { if ($dress['dressed'] == 1) { db::c()->query('UPDATE `users` SET ?f = 0 WHERE `id` = ?i', $slot1, $user['id']); } db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $id); } } // использовать магию function usemagic($id) { global $user; $row = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND id = ?i', $user['id'], $id)->fetch_assoc_array(); $bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', $user['battle'])->fetch_assoc_array(); $all_magic = unserialize($bat['magic']); $charge = 0; $magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $row['magic'])->fetch_assoc_array(); if ($magic['needcharge'] > 0) { $charge = $magic['needcharge']; } $incmagic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $row['includemagic'])->fetch_assoc_array(); if ($incmagic['needcharge'] > 0) { $charge = $incmagic['needcharge']; } if ((($all_magic[$user['id']] < 1) || ($charge == '0')) && (($user['sila'] >= $row['nsila']) && ($user['lovk'] >= $row['nlovk']) && ($user['inta'] >= $row['ninta']) && ($user['vinos'] >= $row['nvinos']) && ($user['intel'] >= $row['nintel']) && ($user['level'] >= $row['nlevel']) && (($user['align'] > 7 && $user['align'] < 8) || ((int)$user['align'] == (int)$row['nalign']) || ($row['nalign'] == 0)) && ($user['noj'] >= $row['nnoj']) && ($user['topor'] >= $row['ntopor']) && ($user['dubina'] >= $row['ndubina']) && ($user['mec'] >= $row['nmech']) && ($row['type'] < 13 || $row['type'] == 50) && ($user['mfire'] >= $row['nfire']) && ($user['mwater'] >= $row['nwater']) && ($user['mair'] >= $row['nair']) && ($user['mearth'] >= $row['nearth']) && ($user['mlight'] >= $row['nlight']) && ($user['mgray'] >= $row['ngray']) && ($user['mdark'] >= $row['ndark']) && ($row['needident'] == 0) ) || $row['magic'] == 48 || $row['magic'] == 50) { if (!$row['magic']) { $incmagic['name'] = $row['includemagicname']; $incmagic['cur'] = $row['includemagicdex']; $incmagic['max'] = $row['includemagicmax']; if ($incmagic['cur'] <= 0) { return false; } $magic['targeted'] = $incmagic['targeted']; echo ""; include("magic/" . $incmagic['file']); echo ""; } else { echo ""; include("magic/" . $magic['file']); echo ""; } if ($bat) { if ($row['maxdur'] <= ($row['duration'] + 1)) { destructitem($row['id']); } else { if (!$row['magic']) { db::c()->query('UPDATE `inventory` SET `includemagicdex` =`includemagicdex` - ?i WHERE id = ?i', $bat, $row['id']); } else { db::c()->query('UPDATE `inventory` SET duration = duration + ?i WHERE id = ?i', $bat, $row['id']); } } if (!$charge) { $charge = 0; } //ограничение по кол-ву за ход if ($user['battle'] > 0) { $bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', $user['battle'])->fetch_assoc_array(); } if ($bat['magic'] == '') { $all_magic = []; } else { $all_magic = unserialize($bat['magic']); } $all_magic[$user['id']] += $charge; db::c()->query('UPDATE `battle` SET `magic`= "?s" WHERE id = ?i', serialize($all_magic), $user['battle']); } } return false; } function addch($text, $room = 0) { global $user; if ($room == 0) { $room = $user['room']; } if ($fp = @fopen("tmp/chat.txt", "a")) { //открытие flock($fp, LOCK_EX); //БЛОКИРОВКА ФАЙЛА fputs($fp, ":[" . time() . "]:[!sys!!]:[" . ($text) . "]:[" . $room . "]\r\n"); //работа с файлом fflush($fp); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ flock($fp, LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ fclose($fp); //закрытие } } function addchp($text, $who, $room = 0) { global $user; if ($room == 0) { $room = $user['room']; } $fp = fopen("tmp/chat.txt", "a"); //открытие flock($fp, LOCK_EX); //БЛОКИРОВКА ФАЙЛА fputs($fp, ":[" . time() . "]:[{$who}]:[" . ($text) . "]:[" . $room . "]\r\n"); //работа с файлом fflush($fp); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ flock($fp, LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ fclose($fp); //закрытие } /** * @param $msg * * @throws \Krugozor\Database\Mysql\Exception * Отправка системного сообщения в чат. */ function AddChatSystem($msg) { if ($msg) { db::c()->query('INSERT INTO `chat` (`cid`,`msg`,`type`) VALUES (?i,"?s","?s")', 1, $msg, 'sys'); } } function err($t) { echo '' . $t . ''; return true; } // TODO: Переписать выдачу травм. // ставим травму //function settravma($id, $type, $time = 86400, $kill = false) //{ // $user = mysql_fetch_array(mysql_query("SELECT `align`, `level` FROM `users` WHERE `id` = '{$id}' LIMIT 1")); // if ((($user['align'] == 2 && mt_rand(1, 100) > 20) && !$kill) || ($user['level'] == 0)) { // return false; // } else { // $travmalist = ["разбитый нос", "сотрясение первой степени", "потрепанные уши", "прикушенный язык", "перелом переносицы", "растяжение ноги", "растяжение руки", "подбитый глаз", "синяк под глазом", "кровоточащее рассечение", "отбитая «пятая точка»", "заклинившая челюсть", "выбитый зуб «мудрости»", "косоглазие"]; // $travmalist2 = ["отбитые почки", "вывих «вырезано цензурой»", "сотрясение второй степени", "оторванное ухо", "вывих руки", "оторванные уши", "поврежденный позвоночник", "отбитые почки", "поврежденный копчик", "разрыв сухожилия", "перелом ребра", "перелом двух ребер", "вывих ноги", "сломанная челюсть"]; // $travmalist3 = ["пробитый череп", "разрыв селезенки", "смещение позвонков", "открытый перелом руки", "открытый перелом «вырезано цензурой»", "излом носоглотки", "непонятные, но множественные травмы", "сильное внутреннее кровотечение", "раздробленная коленная чашечка", "перелом шеи", "смещение позвонков", "открытый перелом ключицы", "перелом позвоночника", "вывих позвоночника", "сотрясение третьей степени"]; // $owntravma = mysql_fetch_array(mysql_query("SELECT `type`, `id`, `sila`, `lovk`, `inta`, `hp` FROM `effects` WHERE `owner` = " . $id . " AND (`type` = 11 OR `type` = 12 OR `type` = 13) ORDER BY `type` DESC LIMIT 1")); // if ($type != 0 && $type != 100) { // $owntravma['type'] = $type; // } elseif ($type != 0 && $type == 100 && $owntravma['type'] == 0) { // $type = mt_rand(1, 100); // if ($type < 10) { // $owntravma['type'] = 25; // } elseif ($type < 60) { // $owntravma['type'] = "set"; // } elseif ($type < 85) { // $owntravma['type'] = 11; // } else { // $owntravma['type'] = 12; // } // } elseif ($owntravma['type'] == 0) { // $tr = mt_rand(1, 3); // switch ($tr) { // case 1: // $owntravma['type'] = 0; // break; // case 2: // $owntravma['type'] = 11; // break; // case 3: // $owntravma['type'] = 12; // break; // } // } // // switch ($owntravma['type']) { // // case 20: // $st = mt_rand(0, 2); // $zz = mt_rand(1, 3); // $s = 0; // $l = 0; // $i = 0; // switch ($zz) { // case 1: // $s = ($user['level'] + $st) * 3; // break; // case 2: // $l = ($user['level'] + $st) * 3; // break; // case 3: // $i = ($user['level'] + $st) * 3; // break; // } // $trv = $travmalist3[mt_rand(0, count($travmalist3) - 1)]; // mysql_query("INSERT INTO `effects` (`owner`, `name`, `time`, `type`, `sila`, `lovk`, `inta`, `vinos`) VALUES ('" . $id . "', 'Травма "" . $trv . ""', " . (time() + $time) . ", '13', '" . $s . "', '" . $l . "', '" . $i . "', '0')"); // mysql_query("UPDATE `users` SET `sila` = (`sila`-'" . $s . "'), `lovk` = (`lovk`-'" . $l . "'), `inta` = (`inta`-'" . $i . "') WHERE `id` = '" . $id . "' LIMIT 1"); // return $trv; // break; // // default: // $st = mt_rand(0, 2); // $zz = mt_rand(1, 3); // $s = 0; // $l = 0; // $i = 0; // switch ($zz) { // case 1: // $s = $user['level'] + $st; // break; // case 2: // $l = $user['level'] + $st; // break; // case 3: // $i = $user['level'] + $st; // break; // } // $trv = $travmalist[mt_rand(0, count($travmalist) - 1)]; // $time = 60 * 60 * mt_rand(1, 5); // mysql_query("INSERT INTO `effects` (`owner`, `name`, `time`, `type`, `sila`, `lovk`, `inta`, `vinos`) VALUES ('" . $id . "', 'Травма "" . $trv . ""', " . (time() + $time) . ", '11', '" . $s . "', '" . $l . "', '" . $i . "', '0')"); // mysql_query("UPDATE `users` SET `sila` = (`sila`-'" . $s . "'), `lovk` = (`lovk`-'" . $l . "'), `inta` = (`inta`-'" . $i . "') WHERE `id` = '" . $id . "' LIMIT 1"); // return $trv; // break; // // case 11: // $zz = mt_rand(1, 3); // $s = 0; // $l = 0; // $i = 0; // switch ($zz) { // case 1: // $s = ($user['level']) * 2; // break; // case 2: // $l = ($user['level']) * 2; // break; // case 3: // $i = ($user['level']) * 2; // break; // } // $trv = $travmalist2[mt_rand(0, count($travmalist2) - 1)]; // $time = 60 * 60 * mt_rand(5, 15); // mysql_query("INSERT INTO `effects` (`owner`, `name`, `time`, `type`, `sila`, `lovk`, `inta`, `vinos`) VALUES ('" . $id . "', 'Травма "" . $trv . ""', " . (time() + $time) . ", '12', '" . $s . "', '" . $l . "', '" . $i . "', '0')"); // mysql_query("UPDATE `users` SET `sila` = (`sila`-'" . $s . "'), `lovk` = (`lovk`-'" . $l . "'), `inta` = (`inta`-'" . $i . "') WHERE `id` = '" . $id . "' LIMIT 1"); // return $trv; // break; // // case 12: // $zz = mt_rand(1, 3); // $s = 0; // $l = 0; // $i = 0; // switch ($zz) { // case 1: // $s = ($user['level']) * 3; // break; // case 2: // $l = ($user['level']) * 3; // break; // case 3: // $i = ($user['level']) * 3; // break; // } // $trv = $travmalist3[mt_rand(0, count($travmalist3) - 1)]; // $time = 60 * 60 * mt_rand(15, 24); // mysql_query("INSERT INTO `effects` (`owner`, `name`, `time`, `type`, `sila`, `lovk`, `inta`, `vinos`) VALUES ('" . $id . "', 'Травма "" . $trv . ""', " . (time() + $time) . ", '13', '" . $s . "', '" . $l . "', '" . $i . "', '0')"); // mysql_query("UPDATE `users` SET `sila` = (`sila`-'" . $s . "'), `lovk` = (`lovk`-'" . $l . "'), `inta` = (`inta`-'" . $i . "') WHERE `id` = '" . $id . "' LIMIT 1"); // return $trv; // break; // // case 13: // $zz = mt_rand(1, 3); // $s = 0; // $l = 0; // $i = 0; // switch ($zz) { // case 1: // $s = ($user['level']) * 3; // break; // case 2: // $l = ($user['level']) * 3; // break; // case 3: // $i = ($user['level']) * 3; // break; // } // $trv = $travmalist3[mt_rand(0, count($travmalist3) - 1)]; // $time = 60 * 60 * mt_rand(25, 26); // mysql_query("INSERT INTO `effects` (`owner`, `name`, `time`, `type`, `sila`, `lovk`, `inta`, `vinos`) VALUES ('" . $id . "', 'Травма "" . $trv . ""', " . (time() + $time) . ", '14', '" . $s . "', '" . $l . "', '" . $i . "', '0')"); // mysql_query("UPDATE `users` SET `sila` = (`sila`-'" . $s . "'), `lovk` = (`lovk`-'" . $l . "'), `inta` = (`inta`-'" . $i . "') WHERE `id` = '" . $id . "' LIMIT 1"); // return $trv; // break; // } // } //} // //function deltravma($id) //{ // $owntravmadb = db::c()->query('SELECT id FROM effects WHERE (`type` = 11 OR `type` = 12 OR `type` = 13 OR `type` = 14) AND id = ?i', $id); // while ($owntravma = $owntravmadb->fetch_assoc_array()) { // db::c()->query('DELETE FROM `effects` WHERE `id` = ?i', $owntravma['id']); // } //} /** * @param $name * @param $text * * @throws \Krugozor\Database\Mysql\Exception */ function telegraph($userId, $text) { db::c()->query('SELECT 1 FROM `users` WHERE `id` = ?i', $userId)->fetch_assoc(); if (db::c()->getAffectedRows()) { db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $userId, $text); } } function get_meshok() { global $user; $d = db::c()->query('SELECT SUM(`gmeshok`) AS `ves` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0 AND `gmeshok` > 0', $_SESSION['uid'])->fetch_assoc(); return ($user['sila'] * 4 + $d['ves']); } /** * Надеюсь временная заглушка, которая объединяет get_meshok() и другую выдачу одной строкой. * @return string */ function getItemsMassaInfo() { $i_row = db::c()->query('SELECT SUM(`massa`) AS `massa`, SUM(`gmeshok`) AS `massa_bonus` FROM `inventory` WHERE `setsale` = 0 AND `owner` = ?i', $_SESSION['uid'])->fetch_assoc(); $u_row = db::c()->query('SELECT `sila` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc(); if ($i_row['massa'] > $u_row['sila'] * 4 + $i_row['massa_bonus']) { return "" . $i_row['massa'] . "/" . ($u_row['sila'] * 4 + $i_row['massa_bonus']); } else { return $i_row['massa'] . "/" . ($u_row['sila'] * 4 + $i_row['massa_bonus']); } } function addlog($id, $log) { $fp = fopen("backup/logs/battle" . $id . ".txt", "a"); flock($fp, LOCK_EX); fputs($fp, $log); fflush($fp); flock($fp, LOCK_UN); fclose($fp); unset($id, $log); } function star_sign($month, $day) { if (empty($month) || empty($day)) { $month = (int)sprintf("%02d", mt_rand(1, 12)); $day = (int)sprintf("%02d", mt_rand(1, 29)); } $signs = ["10", "11", "12", "01", "02", "03", "04", "05", "06", "07", "08", "09"]; $signsstart = ['01' => 21, '02' => 20, '03' => 20, '04' => 20, '05' => 20, '06' => 20, '07' => 21, '08' => 22, '09' => 23, '10' => 23, '11' => 23, '12' => 23]; return $day < $signsstart[$month + 1] ? $signs[$month - 1] : $signs[$month % 12]; } function SolveExp($at_id, $def_id, $damage) { $mods = ['bloodb' => 1.2, 'btl_1' => 1, 'btl_2' => 0.5, 'btl_3' => 0.05]; $baseexp = ["0" => "2", "1" => "5", "2" => "10", "3" => "15", "4" => "30", "5" => "60", "6" => "90", "7" => "115", "8" => "300", "9" => "400", "10" => "500", "11" => "600", "12" => "700", "13" => "800", "14" => "900", "15" => "1000", "16" => "1100", "17" => "1200", "18" => "1300", "19" => "1400", "20" => "1500", "21" => "1600"]; $expmf = 0; $bot_active = false; $bot_def = false; if ($at_id > _BOTSEPARATOR_) { $bots = db::c()->query('SELECT * FROM bots WHERE id = ?i', $at_id)->fetch_assoc_array(); $at_id = $bots['prototype']; $bot_active = true; } $at = db::c()->query('SELECT `level` FROM `users` WHERE `id` = ?i', $at_id)->fetch_assoc(); $def = db::c()->query('SELECT `level` FROM `users` WHERE `id` = ?i', $def_id)->fetch_assoc(); $at_cost = db::c()->query('SELECT 1+IFNULL((SELECT SUM(`cost`) FROM `inventory` WHERE `owner` = `users`.`id` AND `dressed` = 1), 0), `align` FROM `users` WHERE `id` = ?i', $at_id)->fetch_assoc_array(); $def_cost = db::c()->query('SELECT 1+IFNULL((SELECT SUM(`cost`) FROM `inventory` WHERE `owner` = `users`.`id` AND `dressed` = 1), 0), `align` FROM `users` WHERE `id` = ?i', $def_id)->fetch_assoc_array(); if ($at_id > _BOTSEPARATOR_) { $table_name = 'bots'; } else { $table_name = 'users'; } $bat_raw = db::c()->query('SELECT battle FROM ?f WHERE id = ?i', $table_name, $at_id)->fetch_assoc_array(); $bat = $bat_raw['battle']; $bt = db::c()->query('SELECT `blood`,`type`,`t1`,`t2` FROM `battle` WHERE `id` = ?i', $bat)->fetch_assoc(); if ($def_id > _BOTSEPARATOR_) { $bots = db::c()->query('SELECT * FROM bots WHERE id = ?i', $def_id)->fetch_assoc_array(); $def_id = $bots['prototype']; $bot_def = true; } if ($bt['blood']) { $expmf = $mods['bloodb']; } $filebtl = '/tmp/' . $at_id . '.btl'; if ($bt['type'] == 1 && file_exists($filebtl)) { $btfl = fopen($filebtl, 'r'); $contents = fread($btfl, filesize($filebtl)); fclose($btfl); $cnt = substr_count($contents, $def_id); $exmod = 1; if ($cnt <= 1) { $exmod = $mods['btl_1']; } elseif ($cnt == 2) { $exmod = $mods['btl_2']; } elseif ($cnt > 2) { $exmod = $mods['btl_3']; } $expmf = $expmf * $exmod; } $standart = [ "0" => 1, "1" => 1, "2" => 15, "3" => 111, "4" => 265, "5" => 526, "6" => 882, "7" => 919, "8" => 919, "9" => 919, "10" => 919, "11" => 919, "12" => 919, "13" => 919, "14" => 919, "15" => 919, "16" => 919, "17" => 919, "18" => 919, "19" => 919, "20" => 919, "21" => 919, "22" => 919, "23" => 919, "24" => 919, "25" => 919]; $mfit = ($at_cost[0] / ($standart[$at['level']] / 3)); if ($mfit < 0.8) { $mfit = 0.8; } if ($mfit > 1.5) { $mfit = 1.5; } $pls = count(explode(";", $bt['t1'])) + count(explode(";", $bt['t2'])); if ($pls > 2) { $mfbot = $bot_active ? 0.3 : 1; $mfbot2 = $bot_def ? 0.7 : 1; } else { $mfbot = 1; $mfbot2 = 1; } if ($expmf == 0) { $expmf = 1; } return round((($baseexp[$def['level']]) * ($def_cost[0] / (($at_cost[0] + $def_cost[0]) / 2)) * ($damage / $def['maxhp']) * $expmf * $mfit * $mfbot * $mfbot2) / 3, 0); } /** * Функция записи в личное дело. * * @param string $message - текст записи. * @param int $user_id - ID пользователя которому добавляется запись. * @param int $type - тип записи: (1)обычная, (2)модераторская. * * @return bool */ function addToDelo($message, $user_id = 0, $type = 1) { if (empty($user_id)) { $user_id = $_SESSION['uid']; } db::c()->query('INSERT INTO `delo` (pers, text, type, date) VALUES (?i,"?s",?i,?i)', $user_id, $message, $type, time()); return true; } /** * Апаем стат или мастерство на единицу. * * @param $name - техническое имя параметра, как в базе. * @param null $param - выбор что повышать. * * @return void */ function addOnePoint($name, $param = null) { $allowed_stats = ['sila', 'lovk', 'inta', 'vinos', 'intel', 'mudra']; $allowed_mastery = ['noj', 'mec', 'dubina', 'topor', 'mfire', 'mwater', 'mair', 'mearth', 'mlight', 'mgray', 'mdark']; $naming = [ 'sila' => 'Сила', 'lovk' => 'Ловкость', 'inta' => 'Интуиция', 'vinos' => 'Выносливость', 'intel' => 'Интеллект', 'mudra' => 'Мудрость', 'noj' => 'Владение кинжалами', 'mec' => 'Владение мечами', 'dubina' => 'Владение дубинами', 'topor' => 'Владение топорами', 'mfire' => 'Магия огня', 'mwater' => 'Магия воды', 'mair' => 'Магия воздуха', 'mearth' => 'Магия земли', 'mlight' => 'Магия света', 'mgray' => 'Магия серости', 'mdark' => 'Магия тьмы', ]; if ($param == 'stat' && in_array($name, $allowed_stats)) { db::c()->query('UPDATE `users` SET ?f = ?f + 1, `stats` = `stats` - 1 WHERE `id` = ?i', $name, $name, $_SESSION['uid']); echo "Параметр {$naming[$name]} увеличен на 1 ед."; } elseif ($param == 'mastery' && in_array($name, $allowed_mastery)) { $mastery_level = db::c()->query('SELECT ?f FROM `users` WHERE `id` = ?i', $name, $_SESSION['uid'])->fetch_assoc(); if ($mastery_level[$name] < 10) { db::c()->query('UPDATE `users` SET ?f = ?f + 1, `master` = `master` - 1 WHERE `id` = ?i', $name, $name, $_SESSION['uid']); echo "Параметр {$naming[$name]} увеличен на 1 ед."; } else { echo "Ошибка: параметр достиг максимального значения!"; } } else { return null; } } function checkIntInRange($int, $min = 1, $max = PHP_INT_MAX) { return (int)filter_var($int, FILTER_VALIDATE_INT, ['options' => ['min_range' => $min, 'max_range' => $max]]); }