<?
if(!defined('GAME')) {
	die();
}
/*
	Прием: Ставка на опережение
	Украдет все приемы
*/
$pvr = array();
if( isset($pr_tested_this) ) {
		$fx_priem = function(  $id , $at , $uid, $j_id ) {
		// -- начало приема
		global $u, $btl;	
		//
		//Параметры приема
		$pvr['used'] = 0;
		//		
		$uid1 = $btl->atacks[$id]['uid1'];
		$uid2 = $btl->atacks[$id]['uid2'];			
		if( $uid == $uid1 ) {
			$a = 1;
			$b = 2;
			$u1 = ${'uid1'};
			$u2 = ${'uid2'};
		}elseif( $uid == $uid2 ) {
			$a = 2;
			$b = 1;
			$u1 = ${'uid2'};
			$u2 = ${'uid1'};
		}
		if( isset($at['p'][$a]['priems']['kill'][$uid][$j_id]) ) {	
				mysql_query('UPDATE `eff_users` SET `delete` = "'.time().'" WHERE `id` = "'.$btl->stats[$btl->uids[$uid]]['u_priem'][$j_id][3].'" AND `uid` = "'.$uid.'" LIMIT 1');
				unset($btl->stats[$btl->uids[$uid]]['u_priem'][$j_id]);
		}
		//
		// -- конец приема
		return $at;
	};
	unset( $pr_used_this );
}elseif( isset($pr_used_this) /*&& isset($pr_moment) */) { 
	$fx_priem = function(  $id , $at , $uid, $j_id ) {
		// -- начало приема
		global $u, $btl, $priem;	
		//
		//Параметры приема
		$pvr['used'] = 0;
		//		
		$uid1 = $btl->atacks[$id]['uid1'];
		$uid2 = $btl->atacks[$id]['uid2'];			
		if( $uid == $uid1 ) {
			$a = 1;
			$b = 2;
			$u1 = ${'uid1'};
			$u2 = ${'uid2'};
		}elseif( $uid == $uid2 ) {
			$a = 2;
			$b = 1;
			$u1 = ${'uid2'};
			$u2 = ${'uid1'};
		}
		if( $a > 0 ) {

			if( $pvr['used'] == 0 && !isset($at['p'][$a]['priems']['kill'][$u1][$j_id]) ) {
				//
				$btl->priemAddLogFast( $u1, 0, "Ставка на опережение",
					'{tm1} '.$btl->addlt(1 , 17 , $btl->users[$btl->uids[$u1]]['sex'] , NULL).'',
				1, time() );					
				//
				
				mysql_query('UPDATE `eff_users` SET `delete` = "'.time().'" WHERE `id` = "'.$btl->stats[$btl->uids[$u1]]['u_priem'][$j_id][3].'" AND `uid` = "'.$u1.'" LIMIT 1');
				unset($btl->stats[$btl->uids[$u1]]['u_priem'][$j_id]);
				//
				$pvr['sp'] = mysql_query('SELECT * FROM `eff_users` WHERE `uid` = "'.$u2.'" AND `delete` = 0
				AND `v1` = "priem" AND `v2` != 201 AND `v2` != 238 AND `v2` != 139 AND `v2` != 211 AND `v2` != 233 AND `v2` != 223 AND `v2` != 222
				AND `v2` NOT IN ( SELECT `id` FROM `priems` WHERE `neg` > 0 )
				AND `name` NOT LIKE "%Магический барьер%"
				AND `name` NOT LIKE "%Силовое поле%"
				AND `name` NOT LIKE "%Туманный образ%"
				AND `name` NOT LIKE "%Каменный страж%"
				AND `v2` != 245
				AND `v2` != 248
				AND `v2` != 249
				AND `v2` != 254
				AND `v2` != 255
				AND `v2` != 260
				AND `v2` != 188
				AND `v2` != 285				
				AND `v2` != 29
				AND `v2` != 180
				AND `v2` != 332
				AND `v2` != 333
				AND `v2` != 334
				AND `v2` != 335
				AND `v2` != 283
				AND `v2` != 267
				AND `v2` != 32
				AND `v2` != 257
				AND `v2` != 30				
				AND `v2` != 251
				AND `v2` != 250
				AND `v2` != 252
				AND `v2` != 31			
				AND `v2` != 324				
				LIMIT 50');
				
				while($pvr['pl'] = mysql_fetch_array($pvr['sp'])) {
					$pvr['pl']['priem'] = mysql_fetch_array(mysql_query('SELECT * FROM `priems` WHERE `id` = "'.$pvr['pl']['v2'].'" LIMIT 1'));
					if( isset($pvr['pl']['priem']) ) {
						
						mysql_query('UPDATE `eff_users` SET `delete` = "'.time().'" WHERE `uid` = "'.$u1.'" AND `v2` = "'.$pvr['pl']['v2'].'" AND `delete` = "0" LIMIT 1');
						
						/*if ($pvr['pl']['timeUse']==77){
						mysql_query('UPDATE `eff_users` SET `uid` = "'.$u1.'" ,`timeUse` = "'.time().'" WHERE `id` = "'.$pvr['pl']['id'].'" LIMIT 1');
						}else{mysql_query('UPDATE `eff_users` SET `uid` = "'.$u1.'" WHERE `id` = "'.$pvr['pl']['id'].'" LIMIT 1');}*/
						
						
						$btl->delPriem($pvr['pl'],$btl->users[$btl->uids[$u2]],100,0,$pvr['pl']['name']);
						
						
						//$this->addPriem($u1,$pvr['pl']['priem']['id'],''.$pvr['pl']['priem']['data2'].'',''.$pvr['pl']['priem']['data3'].'',77,5,$u1,1,''.$pvr['pl']['priem']['name'].'',0,0,1);
						mysql_query('INSERT INTO `eff_users`(
						`id_eff`, 
						`uid`, 
						`name`, 
						`data`, 
						`overType`, 
						`timeUse`, 
						`timeAce`, 
						`user_use`, 
						`delete`, 
						`v1`, 
						`v2`, 
						`img2`, 
						`x`, 
						`hod`, 
						`bj`, 
						`sleeptime`, 
						`no_Ace`, 
						`file_finish`,
						`tr_life_user`, 
						`deactiveTime`, 
						`deactiveLast`, 
						`mark`, 
						`bs`) 
						VALUES (
						"'.$pvr['pl']['id_eff'].'",
						"'.$u1.'", 
						"'.$pvr['pl']['name'].'", 
						"'.$pvr['pl']['data'].'", 
						"'.$pvr['pl']['overType'].'",
						"'.$pvr['pl']['timeUse'].'", 
						"'.$pvr['pl']['timeAce'].'", 
						"'.$u1.'", 
						"'.$pvr['pl']['delete'].'", 
						"'.$pvr['pl']['v1'].'", 
						"'.$pvr['pl']['v2'].'", 
						"'.$pvr['pl']['img2'].'", 
						"'.$pvr['pl']['x'].'", 
						"'.$pvr['pl']['hod'].'", 
						"'.$pvr['pl']['bj'].'", 
						"'.$pvr['pl']['sleeptime'].'", 
						"'.$pvr['pl']['no_Ace'].'", 
						"'.$pvr['pl']['file_finish'].'", 
						"'.$pvr['pl']['tr_life_user'].'", 
						"'.$pvr['pl']['deactiveTime'].'", 
						"'.$pvr['pl']['deactiveLast'].'", 
						"'.$pvr['pl']['mark'].'", 
						"'.$pvr['pl']['bs'].'")
						');
						
						
						
						/*if ($pvr['pl']['timeUse']==77){
						mysql_query('UPDATE `eff_users` SET `timeUse` = "77",`delete` = "0" WHERE `id` = "'.$pvr['pl']['id'].'" LIMIT 1');
						}*/
					}
				}
				//
			}	
		}
		// -- конец приема
		return $at;
	};
	unset( $pr_used_this );
}else{
	//Действие при клике
	$this->addEffPr($pl,$id);
}
unset($pvr);
?>