$us=mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
$jert=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
if($jert['id']!=$user['id']){
addch("<img src=i/magic/attack.gif> <B>{$user['login']}</B>, применив магию нападения, внезапно ".$action." на "{$_POST['target']}"");
addchp('<font color=red>Внимание!</font> На вас '.$action.' <B>'.$user['login'].'</B>.<BR>\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ','{[]}'.nick::id($jert['id'])->short().'{[]}');
$arha=mysql_fetch_array(mysql_query('SELECT * FROM `bots` WHERE `prototype` = '.$jert['id'].' LIMIT 1;'));
$jert['battle']=$arha['battle'];
$jert['id']=$arha['id'];
$bot=1;
}
if($jert['battle']>0){
//вмешиваемся
$bd=mysql_fetch_array(mysql_query('SELECT * FROM `battle` WHERE `id` = '.$jert['battle'].' LIMIT 1;'));
$battle=unserialize($bd['teams']);
$ak=array_keys($battle[$jert['id']]);
$battle[$user['id']]=$battle[$ak[0]];
foreach($battle[$user['id']]as$k=>$v){
$battle[$user['id']][$k]=array(0,0,time());
$battle[$k][$user['id']]=array(0,0,time());
}
$t1=explode(";",$bd['t1']);
// проставляем кто-где
if(in_array($jert['id'],$t1)){
$ttt=2;
}else{
$ttt=1;
}
addch("<b>".nick::id($user['id'])->short()."</b> вмешался в <a href=logs.php?log=".$id." target=_blank>поединок »»</a>. ",$user['room']);
//mysql_query('UPDATE `logs` SET `log` = CONCAT(`log`,\'<span class=date>'.date("H:i").'</span> '.nick5($user['id'],"B".$ttt).' вмешался в поединок!<BR>\') WHERE `id` = '.$jert['battle'].'');
addlog($jert['battle'],'<span class=date>'.date("H:i").'</span> '.nick5($user['id'],"B".$ttt).' вмешался в поединок!<BR>');
mysql_query('UPDATE `battle` SET `teams` = \''.serialize($battle).'\', `t'.$ttt.'`=CONCAT(`t'.$ttt.'`,\';'.$user['id'].'\') WHERE `id` = '.$jert['battle'].' ;');
mysql_query("UPDATE users SET `battle` =".$jert['battle'].",`zayavka`=0,`hit`=0,`parry`=0,`krit`=0,`counter`=0,`hp2`=0 WHERE `id`= ".$user['id']);
mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$jert['id']} LIMIT 1;");
}else{
mysql_query("UPDATE `users` SET `battle` = {$id} WHERE `id` = {$jert['id']} LIMIT 1;");
}
// создаем лог
$rr="<b>".nick::id($user['id'])->full(1)."</b> и <b>".nick::id($jert['id'])->full(1)."</b>";
addch("<a href=logs.php?log=".$id." target=_blank>Бой</a> между <B><b>".nick::id($user['id'])->short()."</b> и <b>".nick::id($jert['id'])->short()."</b> начался. ",$user['room']);
//mysql_query("INSERT INTO `logs` (`id`,`log`) VALUES('{$id}',"Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." бросили вызов друг другу. <BR>");
mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$user['id']} OR `id` = {$jert['id']}");
if($us['login']=="Общий Враг"){
$jert['id']=3954;
}
$rr="<b>".nick::id($user['id'])->full(1)."</b> и <b>".nick::id($jert['id'])->full(1)."</b>";
addlog($id,"Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." бросили вызов друг другу. <BR>");