<?
	if($quest_max>=$quest){
	$nquest = mysql_query("SELECT * FROM `quest` WHERE `rasa`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($rasa)))))))."' AND `num`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($quest)))))))."'");
	$scquest = mysql_fetch_array($nquest);
	//Задание №1
	if($scquest['num']==1 AND $hero!='')$okquest=1;
	//Задание №2
	if($scquest['num']==2)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `army` WHERE `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==2 AND $count!=0)$okquest=1;
	//Задание №3
	if($scquest['num']==3)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `army` WHERE `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."' AND `u1`!=0 AND `u8`!=0;"), 0);
	if($scquest['num']==3 AND $count!=0)$okquest=1;
	//Задание №4
	if($scquest['num']==4)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `planet_loc` WHERE `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."' AND `rab`!=0;"), 0);
	if($scquest['num']==4 AND $count!=0)$okquest=1;
	//Задание №5
	if($scquest['num']==5 AND $lvl_hero>=2)$okquest=1;
	//Задание №6
	if($scquest['num']==6)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `sosed` WHERE `uid1`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==6 AND $count!=0)$okquest=1;
	//Задание №7
	if($scquest['num']==7)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b2`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==7 AND $lvl_hero>=3 AND $count!=0)$okquest=1;
	//Задание №8
	if($scquest['num']==8)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b3`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==8 AND $lvl_hero>=4 AND $count!=0)$okquest=1;
	//Задание №9
	if($scquest['num']==9)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `planet` WHERE `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."' AND `nalog`>='".($newtime+86400)."';"), 0);
	if($scquest['num']==9 AND $lvl_hero>=5 AND $count!=0)$okquest=1;
	//Задание №10
	if($scquest['num']==10)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b4`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==10)$countrazv = mysql_result(mysql_query("SELECT COUNT(*) FROM `planet` WHERE `razv`>=26 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_i)))))))."';"), 0);
	if($scquest['num']==10 AND $lvl_hero>=6 AND $count!=0 AND $countrazv!=0)$okquest=1;
	//Задание №11
	if($scquest['num']==11 AND $rasa==1 OR $rasa==2)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `science` WHERE `s6`>=2 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==11 AND $rasa==3)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `science` WHERE `s7`>=2 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==11 AND $lvl_hero>=7 AND $count!=0)$okquest=1;
	//Задание №12
	if($scquest['num']==12 AND $rasa==1)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `science` WHERE `s4`>=2 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==12 AND $rasa==2)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `science` WHERE `s3`>=2 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==12 AND $rasa==3)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `science` WHERE `s2`>=2 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==12 AND $lvl_hero>=8 AND $count!=0)$okquest=1;
	//Задание №13
	if($scquest['num']==13)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `science` WHERE `s5`>=2 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==13 AND $lvl_hero>=9 AND $count!=0)$okquest=1;
	//Задание №14
	if($scquest['num']==14)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `sosed` WHERE `uid1`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."' AND `war`=1;"), 0);
	if($scquest['num']==14 AND $count!=0)$okquest=1;
	//Задание №15
	if($scquest['num']==15)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b5`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==15 AND $lvl_hero>=10 AND $count!=0)$okquest=1;
	//Задание №16
	if($scquest['num']==16)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b6`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==16 AND $lvl_hero>=11 AND $count!=0)$okquest=1;
	//Задание №17
	if($scquest['num']==17)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b7`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==17 AND $lvl_hero>=12 AND $count!=0)$okquest=1;
	//Задание №18
	if($scquest['num']==18)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b8`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==18 AND $lvl_hero>=13 AND $count!=0)$okquest=1;
	//Задание №19
	if($scquest['num']==19)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b9`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==19 AND $lvl_hero>=14 AND $count!=0)$okquest=1;
	//Задание №20
	if($scquest['num']==20)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `science` WHERE `s1`>=2 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==20 AND $lvl_hero>=15 AND $count!=0)$okquest=1;
	//Задание №21
	if($scquest['num']==21 AND ($rasa==1 OR $rasa==2))$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b10`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==21 AND $rasa==3)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b11`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==21 AND $lvl_hero>=16 AND $count!=0)$okquest=1;
	//Задание №22
	if($scquest['num']==22 AND $rasa==1 OR $rasa==2)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b11`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==22 AND $lvl_hero>=17 AND $count!=0 AND ($rasa==1 OR $rasa==2))$okquest=1;
	if($scquest['num']==22 AND $lvl_hero>=17 AND $rasa==3)$okquest=1;
	//Задание №23
	if($scquest['num']==23 AND $rasa==3)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b10`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==23 AND $lvl_hero>=18 AND ($rasa==1 OR $rasa==2))$okquest=1;
	if($scquest['num']==23 AND $lvl_hero>=18 AND $count!=0 AND $rasa==3)$okquest=1;
	//Задание №24
	if($scquest['num']==24)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `building` WHERE `b12`=1 AND `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==24 AND $lvl_hero>=19 AND $count!=0)$okquest=1;
	//Задание №25
	if($scquest['num']==25)$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `fractions_users` WHERE `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."';"), 0);
	if($scquest['num']==25 AND $lvl_hero>=20 AND $count!=0)$okquest=1;
	
	if($quest<=$sc_quest)$scquest['price']=0;
	if($quest>$sc_quest)$plus_sc=1;
	if($quest<=$sc_quest)$plus_sc=0;
	if($quest_set==0){
	echo '<div class="razd"></div>';
	echo '<center><div class="blok2"><img src="images/quest.gif" alt="image" /> <a href="game/quest.php"><b>Задание</b></a> <b>№'.check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($quest))))))).'</b><a href="game/quest.php?act=set"> <img src="images/icon/abort.png" width="15px"  alt="image" /></a></div></center>';
	echo '<div class="razd"></div>';
	if($okquest!=1)echo '<div class="window">'.check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($scquest['text']))))))).'</div>';
	}
	if($okquest==1){
	echo '<div class="blok">'.check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($scquest['text']))))))).'</div><div class="ch" align="center">Задание №'.check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($quest))))))).' выполнено!';
	if($quest>$sc_quest)echo '<br/><img src="images/images_main/plasma.png" width="25px" alt="image" /> + '.check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($scquest['price']))))))).' Плазмы';
	echo '</div>';
	mysql_query("UPDATE `users` SET `quest`=quest+1, `sc_quest`=sc_quest+'".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($plus_sc)))))))."', `sc`=sc+'".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($scquest['price'])))))))."' WHERE `id`='" . check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id))))))) . "';");	
	}
	}
	if($quest_max<$quest AND $quest_set==0)echo '<div class="top"><img src="images/quest.gif" alt="image" /> Нет доступных заданий <a href="game/quest.php?act=set"> <img src="images/icon/abort.png" width="15px" alt="image" /></a></div>';
	
?>