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()); echo "Вы продали \"{$dress['name']}\" $kols за " . $allcost . " кр."; } if (isset($_GET['set']) OR isset($_POST['set'])) { $set = empty($_GET['set']) ?: $_GET['set']; $set = empty($_POST['set']) ?: $_POST['set']; $count = isset($_GET['count']) && is_numeric($_GET['count']) ? $_GET['count'] : 0; $count = isset($_POST['count']) && is_numeric($_POST['count']) ? $_POST['count'] : 0; if ($count < 1) { $count = 0; $count_ok = 0; } else $count_ok = 1; $dress = db::c()->query('SELECT * FROM `shop` WHERE `id`=?i', $set)->fetch_assoc(); // db::c()->query(' // INSERT INTO `inventory` ( // name, maxdur, cost, img, goden, dategoden, massa, prototype, owner, // nlevel, nsila, nlovk, ninta, nvinos, nintel, nmudra, // nnoj, ntopor, ndubina, nmech, nalign, nfire, nwater, nair, nearth, nlight, ngray, ndark, // minu, maxu, // gsila, glovk, ginta, gintel, ghp, gfire, gwater, gair, gearth, glight, ggray, gdark, // mfkrit, mfakrit, mfuvorot, mfauvorot, // gnoj, gtopor, gdubina, gmech, // bron1, bron2, bron3, bron4, magic, needident, // gmp, gmeshok, artefact, encicl, koll) // SELECT // name, maxdur, cost, img, goden, dategoden, massa, id, ?i, // nlevel, nsila, nlovk, ninta, nvinos, nintel, nmudra, // nnoj, ntopor, ndubina, nmech, nalign, nfire, nwater, nair, nearth, nlight, ngray, ndark, // minu, maxu, // gsila, glovk, ginta, gintel, ghp, gfire, gwater, gair, gearth, glight, ggray, gdark, // mfkrit, mfakrit, mfuvorot, mfauvorot, // gnoj, gtopor, gdubina, gmech, // bron1, bron2, bron3, bron4, magic, needident, // gmp, gmeshok, artefact, encicl, koll // FROM shop WHERE id = inventory.prototype; // // ', $user['id']); if ($count_ok == 0) { err('Неправильно введено количество.'); } elseif (($dress['massa'] * $count + $itemWeight['m']) > (get_meshok())) { err('Недостаточно места в рюкзаке.'); } elseif ($count_ok == 1 && ($user['money'] >= ($dress['cost'] * $count)) && ($dress['count'] >= $count)) { $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'], 'otdel' => $dress['otdel'],//s 'gmp' => $dress['gmp'], 'gmeshok' => $dress['gmeshok'], 'encicl' => $dress['encicl'],//s 'artefact' => $dress['artefact'], 'koll' => $dress['koll'] ]; for ($k = 1; $k <= $_GET['count']; $k++) { 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,"?s",?i,?i,"?s",?i,?i]', $newItem); db::c()->query('UPDATE `shop` SET `count` = `count` - ?i WHERE `id` =?i', $count, $set); echo "Вы купили {$count} шт. \"{$dress['name']}\"."; $user['money'] -= $count * $dress['cost']; db::c()->query('UPDATE `users` set `money` = ?i WHERE `id` = ?i', $user['money'], $user['id']); $invdb = db::c()->query('SELECT `id` FROM `inventory` WHERE `name` = "?s" ORDER BY `id` DESC LIMIT ?i', $dress['name'], $count); if ($count == 1) { $dressinv = $invdb->fetch_assoc(); $dressid = "cap" . $dressinv['id']; $dresscount = " "; } else { $dressid = ""; while ($dressinv = $invdb->fetch_assoc()) { $dressid .= "cap" . $dressinv['id'] . ","; } $dresscount = "(x" . $count . ") "; } $allcost = $count * $dress['cost']; $deloText = "\"" . $user['login'] . "\" купил товар : \"" . $dress['name'] . "\" " . $dresscount . " id:(" . $dressid . ") [0/" . $dress['maxdur'] . "] за " . $allcost . " кр."; db::c()->query('INSERT INTO `delo` (`pers`, `text`, `type`, `date`) VALUES (?i, "?s", 1, ?i', $user['id'], $deloText, time()); } } else { echo "Недостаточно денег или нет вещей в наличии."; } } $itemWeight = db::c()->query('SELECT sum(`massa`) AS `m` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $user['id'])->fetch_assoc(); $shopItemType = empty($_POST['sale']) ?: $_POST['sale']; $shopItemTypeNumber = empty($_GET['otdel']) ?: $_GET['otdel']; switch ($shopItemTypeNumber) { default: $shopItemType = "кастеты,ножи"; $_GET['otdel'] = 1; break; case 1: $shopItemType = "кастеты,ножи"; break; case 11: $shopItemType = "топоры"; break; case 12: $shopItemType = "дубины,булавы"; break; case 13: $shopItemType = "мечи"; break; case 14: $shopItemType = "луки и арбалеты"; break; case 2: $shopItemType = "сапоги"; break; case 21: $shopItemType = "перчатки"; break; case 22: $shopItemType = "легкая броня"; break; case 23: $shopItemType = "тяжелая броня"; break; case 24: $shopItemType = "шлемы"; break; case 3: $shopItemType = "Щиты"; break; case 4: $shopItemType = "Ювелирные товары: серьги"; break; case 41: $shopItemType = "Ювелирные товары: ожерелья"; break; case 42: $shopItemType = "Ювелирные товары: кольца"; break; case 5: $shopItemType = "Заклинания: нейтральные"; break; case 51: $shopItemType = "Заклинания: боевые и защитные"; break; case 6: $shopItemType = "Амуниция"; break; case 52: $shopItemType = "Руны"; break; } ?>
|
Масса всех ваших вещей: = $itemWeight['m'] ?>/= get_meshok() ?>
У вас в наличии: = $user['money'] ?> кр.
|