query('SELECT `id`, `name`, `cost`, `type`, `duration`, `maxdur`, `goden`, `dategoden`, `koll` FROM `inventory` WHERE `dressed` = 0 AND `id` = ?i AND `owner` = ?i', $sellItemId, $user['id'])->fetch_assoc(); $price = $dress['cost'] * 1; $kols = ''; if ($dress['koll']) { $price *= $dress['koll']; $kols = '(x' . $dress['koll'] . ')'; } destructitem($dress['id']); if ($dress['type'] == 12) { $allcost = round($price * (1 - $dress['duration'] / $dress['maxdur']), 2); } else { $allcost = round($price - $dress['duration'] * ($dress['cost'] / ($dress['maxdur'] * 10)), 2); } if ($dress['goden'] != 0) { $goden_max = $dress['goden'] * 24 * 60; $goden_left = ($dress['dategoden'] - time()) / 60; $per = $goden_left / $goden_max; $allcost = round(($allcost * $per), 2); } $user['money'] += $allcost; $deloText = "\"" . $user['login'] . "\" продал в магазин товар : \"" . $dress['name'] . "\" $kols id:(cap" . $dress['id'] . ") [" . $dress['duration'] . "/" . $dress['maxdur'] . "] за " . $allcost . " кр. "; db::c()->query('UPDATE `users` SET `money` = ?i WHERE `id` = ?i', $user['money'], $user['id']); db::c()->query('INSERT INTO `delo` (`pers`, `text`, `type`, `date`) VALUES (?i, "?s", 1, ?i)', $user['id'], $deloText, time()); $status = "Вы продали \"{$dress['name']}\" $kols за " . $allcost . " кр."; } if (!empty($_GET['buy'])) { $dress = db::c()->query('SELECT * FROM `shop` WHERE `id`=?i', $_GET['buy'])->fetch_assoc(); $itemWeight = db::c()->query('SELECT sum(`massa`) AS `m` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0', $_SESSION['uid'])->fetch_assoc(); if (($dress['massa'] + $itemWeight['m']) > (get_meshok())) $status = 'Недостаточно места в рюкзаке.'; elseif ($user['money'] >= $dress['cost'] AND ($dress['count'] > 0 OR $dress['count'] == -1)) { $newItem = [ 'prototype' => $dress['id'], 'owner' => $user['id'], 'name' => $dress['name'], //s 'type' => $dress['type'], 'massa' => $dress['massa'], 'cost' => $dress['cost'], 'img' => $dress['img'], //s 'maxdur' => $dress['maxdur'], 'isrep' => $dress['isrep'], 'gsila' => $dress['gsila'], 'glovk' => $dress['glovk'], 'ginta' => $dress['ginta'], 'gintel' => $dress['gintel'], 'ghp' => $dress['ghp'], 'gnoj' => $dress['gnoj'], 'gtopor' => $dress['gtopor'], 'gdubina' => $dress['gdubina'], 'gmech' => $dress['gmech'], 'gfire' => $dress['gfire'], 'gwater' => $dress['gwater'], 'gair' => $dress['gair'], 'gearth' => $dress['gearth'], 'glight' => $dress['glight'], 'ggray' => $dress['ggray'], 'gdark' => $dress['gdark'], 'needident' => $dress['needident'], 'nsila' => $dress['nsila'], 'nlovk' => $dress['nlovk'], 'ninta' => $dress['ninta'], 'nintel' => $dress['nintel'], 'nmudra' => $dress['nmudra'], 'nvinos' => $dress['nvinos'], 'nnoj' => $dress['nnoj'], 'ntopor' => $dress['ntopor'], 'ndubina' => $dress['ndubina'], 'nmech' => $dress['nmech'], 'bron1' => $dress['bron1'], 'bron2' => $dress['bron2'], 'bron3' => $dress['bron3'], 'bron4' => $dress['bron4'], 'minu' => $dress['minu'], 'maxu' => $dress['maxu'], 'magic' => $dress['magic'], 'nlevel' => $dress['nlevel'], 'nalign' => $dress['nalign'], 'dategoden' => $dress['dategoden'], 'goden' => $dress['goden'], 'gmp' => $dress['gmp'], 'artefact' => $dress['artefact'], 'koll' => $dress['koll'] ]; db::c()->query('INSERT INTO `inventory` SET ?A[?i,?i,"?s",?i,?i,?i,"?s",?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i]', $newItem); $inventoryItemId = db::c()->getLastInsertId(); if ($dress['count'] != -1) db::c()->query('UPDATE `shop` SET `count` = `count` - 1 WHERE `id` = ?i', $_GET['buy']); $status = "Вы купили \"{$dress['name']}\"."; db::c()->query('UPDATE `users` set `money` = ?i WHERE `id` = ?i', $dress['cost'], $_SESSION['uid']); $deloText = "{$user['login']} купил товар «{$dress['name']}» id:({$inventoryItemId}) в магазине за {$dress['cost']} кр."; addToDelo($deloText); } else { $status = "Недостаточно денег или нет вещей в наличии."; } } $shopCategoryType = empty($_POST['sale']) ?: $_POST['sale']; $shopCategoryTypeNumber = empty($_GET['otdel']) ?: $_GET['otdel']; switch ($shopCategoryTypeNumber) { default: $shopCategoryType = "Предметы в инвентаре"; $saleItems = true; break; case 1: $shopCategoryType = "Кастеты и ножи"; break; case 11: $shopCategoryType = "Топоры"; break; case 12: $shopCategoryType = "Дубины и булавы"; break; case 13: $shopCategoryType = "Мечи"; break; case 2: $shopCategoryType = "Сапоги"; break; case 21: $shopCategoryType = "Перчатки"; break; case 22: $shopCategoryType = "Легкая броня"; break; case 23: $shopCategoryType = "Тяжелая броня"; break; case 24: $shopCategoryType = "Шлемы"; break; case 3: $shopCategoryType = "Щиты"; break; case 4: $shopCategoryType = "Серьги"; break; case 41: $shopCategoryType = "Ожерелья"; break; case 42: $shopCategoryType = "Кольца"; break; case 5: $shopCategoryType = "Заклинания: нейтральные"; break; case 51: $shopCategoryType = "Заклинания: боевые и защитные"; break; case 6: $shopCategoryType = "Амуниция"; break; case 52: $shopCategoryType = "Руны"; break; } $shopItems = db::c()->query('SELECT `shop`.*, `magic`.`name` AS `magic_name`, `magic`.`chanse` AS `magic_chanse`, `magic`.`time` AS `magic_time`, `magic`.`file` AS `magic_file`, `magic`.`targeted` AS `magic_targeted`, `magic`.`needcharge` AS `magic_needcharge`, `magic`.`img` AS `magic_img` FROM `shop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `count` > 0 AND `cost` > 0 AND `razdel` = ?i ORDER by `nlevel` ASC, `id` ASC', $shopCategoryTypeNumber); $iteminfo = []; while ($row = $shopItems->fetch_assoc()) { $iteminfo[] = new ShopItem($row); } ?>
|
Масса всех ваших вещей: = getItemsMassaInfo() ?>
У вас в наличии: = $user['money'] ?> кр. Продать вещи
|