Файл: DARK WARS/dark_war/weapon_shop/take_off.php
Строк: 12
<?php
include_once '../start.php';
$doc = new document();
$doc->title('Покупка');
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
$doc->err('Ошибка, не выбрано оружие');
exit();
}
$id = (int)$_GET['id'];
$q = mysql_query("SELECT * FROM `dark_war_wshop_u` WHERE id='$id' AND `id_player` = '$player->id' LIMIT 1");
if (!mysql_num_rows($q)) {
$doc->err('У вас нет такого артефакиа');
exit();
}
$ar = mysql_fetch_assoc($q);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `dark_war_wshop_u` WHERE `id_player` = '{$player->id}' AND `type` = '$ar[type]' AND `active` = '1'"),0)<=0) {
$doc->err('У не установлена вещь');
} else {
$put = new put_artefact();
$put->off($ar['w'],$ar['h'],$player->id,0,$ar['type']);
mysql_query("UPDATE `dark_war_wshop_u` SET `active` = '0' WHERE `id` = '$id'");
$hp = $player->hp - $ar['heal'];
$mp = $player->mp - $ar['mana'];
if ($hp <= 0) {$hp = 10;}
if ($mp <= 0) {$mp = 10;}
mysql_query("UPDATE `dark_war_users` SET `dmg` = (`dmg` - '$ar[dmg]'),
`armor` = (`armor` - $ar[armor]), `armorp` = (`armorp` - $ar[armorp]),
`magicr` = (`magicr` - '$ar[magicr]'), `hp` = '$hp',
`hp_max` = (`hp_max` - '$ar[heal]'), `mp_max` = (`mp_max` - '$ar[mana]'),
`mp` = '$mp', `magicp` = (`magicp` - '$ar[magicp]') WHERE `id` = '{$player->id}'");
$doc->msg('Вы сняли артефакт');
}
$doc->ret('/dark_war/weapon_shop/my_artifacts.php', 'Мои артифакты');
?>