battles/magic/usability_klan/close_battle.php
2020-08-27 15:17:02 +03:00

19 lines
1.3 KiB
PHP

<?php
$us = mysql_fetch_array(mysql_query("SELECT *, (SELECT `id` FROM `online` WHERE `date` >= ".(time()-60)." AND `id` = `users`.`id`) AS `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1"));
$vip = mysql_fetch_array(mysql_query('SELECT `id`, `klan`, `closebattle` FROM `abils_klan` WHERE `klan` = "'.$user['klan'].'" LIMIT 1'));
$battle = mysql_fetch_array(mysql_query('SELECT `id`, `open`, `close` FROM `battle` WHERE `id` = "'.$user['battle'].'" LIMIT 1'));
if($user['battle'] <= 0) {
echo 'Это боевая магия ...';
} elseif($battle['open'] == 0 || $battle['close'] == 1) {
echo 'Бой и так закрыт ...';
} elseif($vip['closebattle'] <= 0) {
echo 'Магия исчерпала себя ...';
} else {
$vip['closebattle'] -= 1;
if($user['invis'] == 1) { $lod = '<i><b>невидимка</b></i>'; } else { $lod = Nick::id($user['id'])->short(); }
addlog($battle['id'], '<span class=date>'.date("H:i").'</span> '.$lod.' закрыл поединок от внешних вмешательств!<BR>');
mysql_query('UPDATE `battle` SET `open` = 0 WHERE `id` = "'.$battle['id'].'" LIMIT 1');
mysql_query('UPDATE `abils_klan` SET `closebattle` = "'.$vip['closebattle'].'" WHERE `klan` = "'.$vip['klan'].'" LIMIT 1');
echo 'Ваш поединок, закрыт...';
}