Файл: DARK WARS/dark_war/magic_shop/take.php
Строк: 16
<?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_mshop_u` WHERE id='$id' AND `id_player` = '{$player->id}' LIMIT 1");
if (!mysql_num_rows($q)) {
$doc->err('Запрос к не существующему элементу');
exit();
}
$ar = mysql_fetch_assoc($q);
$hp = $player->hp + $ar['hp'];
$mp = $player->mp + $ar['mp'];
$energy = $player->energy + $ar['energy'];
if($_GET['id'] AND $_GET['SELL']){
mysql_query("DELETE FROM `dark_war_mshop_u` WHERE `id` = '$id' AND `id_player` = '$player->id' LIMIT 1");
$g = $player->gold + $ar['gold'];
mysql_query("UPDATE `dark_war_users` SET `gold` = '$g' WHERE `id` = '$player->id'");
$doc->msg('Вы продали элексир за ' . $ar['gold'] . ' золота');
unset($g);
}
else{
if ($hp > $player->hp_max) {$hp = $player->hp_max;}
if ($mp > $player->mp_max) {$mp = $player->mp_max;}
if ($energy > 100) {$energy = 100;}
mysql_query("UPDATE `dark_war_users` SET `hp` = '$hp', `mp` = '$mp', `energy` = '$energy' WHERE `id` = '$player->id'");
mysql_query("DELETE FROM `dark_war_mshop_u` WHERE `id` = '$id' AND `id_player` = '$player->id' LIMIT 1");
$doc->msg('Вы использовали элемент');
}
$doc->ret('my_magic.php', 'Вещи магии'); // выводит ссылки шаги на зад
?>