$qlst=mysql_fetch_array(mysql_query('SELECT `id`, `vals` FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$e[$i].'" AND `vals` = "win" LIMIT 1'));
if(!isset($qlst['id'])){
$r=3;
}
$i++;
}
unset($qn,$qlst,$qlst2);
}
if(isset($d['tr_zdr'])){
$qlst=mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` != "go" ORDER BY `time` DESC LIMIT 1'));
$qlst=$this->testAction('SELECT `id` FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" LIMIT '.$d['tr_raz'],2);
if($d['tr_raz']>0&&$d['tr_raz']-$qlst[0]<=0){
$r=5;
}
unset($qlst);
}
if(isset($d['tr_raz2'])){
$qlst=$this->testAction('SELECT `id` FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` != "go" AND `vals` != "win" LIMIT '.$d['tr_raz2'],2);
$qlst=db::c()->query('SELECT `vals`, `time` FROM `actions` WHERE `uid` = ?i AND `vars` = "?s" ORDER BY `time` DESC',$u,'start_quest'.$pl['id'])->fetch_assoc();
$qst=mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` = "go" LIMIT 1'));
$d=$this->expl($pl['tr_date']);
if(isset($d['tr_endq'])){
$t.='Завершить квесты : ';
$i=0;
$e=explode(',',$d['tr_endq']);
while($i<=count($e)){
if($e[$i]>0){
$qn=mysql_fetch_array(mysql_query('SELECT `name` FROM `quests` WHERE `id` = "'.$e[$i].'" LIMIT 1'));
if(isset($qn['name'])){
$t.='"'.$qn['name'].'", ';
}
}
$i++;
}
$t=trim($t,', ');
$t.='<br />';
unset($qn);
}
if(isset($d['tr_botitm'])){
$t.='Из ботов выпадают предметы :<ul>';
$e=explode('|',$d['tr_botitm']);
$i=0;
while($i<count($e)){
$j=0;
$e2=explode('-',$e[$i]);
if($e2[0]>0){
$qn=mysql_fetch_array(mysql_query('SELECT `login` FROM `users` WHERE `id` = "'.$e2[0].'" LIMIT 1'));
$t.=' • Из "'.$qn['login'].'" выпадает: ';
}else{
$t.=' • Из любых ботов выпадает: ';
}
$j=0;
$e3=explode(',',$e2[1]);
while($j<count($e3)){
$e4=explode('=',$e3[$j]);
$qi=mysql_fetch_array(mysql_query('SELECT `id`, `name`, `img` FROM `shop` WHERE `id` = "'.$e4[0].'" LIMIT 1'));
$qlst=mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` != "go" LIMIT 1'));
$t.='Задержка между выполнением задания : '.$this->timeOut($d['tr_zdr']*60*60);
$t.='Сколько еще раз можно выполнить задание: <b><small>бесконечно</small></b><br>';
}else{
$qlst=$this->testAction('SELECT `id` FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" LIMIT '.$d['tr_raz'],2);
$t.='Сколько раз можно выполнить задание: '.($d['tr_raz']-$qlst[0]).'<br />';
}
unset($qlst);
}
if(isset($d['tr_raz2'])){
$qlst=$this->testAction('SELECT `id` FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` != "go" AND `vals` != "win" LIMIT '.$d['tr_raz2'],2);
$x=$this->testAction('`uid` = "'.$uid.'" AND `time` > "'.$qst['time'].'" AND `vars` = "win_haot" LIMIT 1',2);
$x=(0+$x[0]);
$t.='Победить в хаотических поединках : ['.$x.'/'.$d['tr_win_haot'].']<br />';
unset($x);
}
if(isset($d['kill_clone'])){
$x=$this->testAction('`uid` = "'.$uid.'" AND `time` > "'.$qst['time'].'" AND `vars` = "kill_clone" LIMIT 1',2);
$x=(0+$x[0]);
$t.='Победите в : ['.$x.'/'.$d['kill_clone'].'] физических боях с клоном.<br />';
unset($x);
}
if(isset($d['tr_win'])){
$x=$this->testAction('`uid` = "'.$uid.'" AND `time` > "'.$qst['time'].'" AND `vars` = "win_fiz" LIMIT 1',2);
$x=(0+$x[0]);
$t.='Победите в : ['.$x.'/'.$d['tr_win'].'] физических против игроков.<br />';
unset($x);
}
if(isset($d['heal'])){
$x=$this->testAction('`uid` = "'.$uid.'" AND `time` > "'.$qst['time'].'" AND `vars` LIKE "heal%" AND `vars` != "heal_'.$uid.'" LIMIT 1',2);
$x=(0+$x[0]);
$t.='Вылечите : ['.$x.'/'.$d['heal'].'] игроков от травм.<br />';
unset($x);
}
if(isset($d['tk_itm'])){
$ex=explode(',',$d['tk_itm']);
$i=0;
$x='';
while($i<count($ex)){
$ex2=explode('=',$ex[$i]);
$x2=mysql_fetch_array(mysql_query('SELECT `koll` FROM `inventory` WHERE `prototype` = "'.mysql_real_escape_string($ex2[0]).'" AND `owner` = "'.$uid.'" LIMIT 1'));
$bot2=mysql_fetch_array(mysql_query('SELECT `id`, `name`, `img` FROM `shop` WHERE `id` = "'.mysql_real_escape_string($ex2[0]).'" LIMIT 1'));
$pl=mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `delete` = "0" AND `min_lvl` <= "'.$user['level'].'" AND `max_lvl` >= "'.$user['level'].'" AND `id` = "'.mysql_real_escape_string($id).'" LIMIT 1'));
$qlst=mysql_fetch_array(mysql_query('SELECT `id` FROM `actions` WHERE `uid` = "'.$user['id'].'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` = "go" LIMIT 1'));
if(isset($qlst['id'])){
if($tp=='end'){
mysql_query('UPDATE `actions` SET `vals` = "end" WHERE `id` = "'.$qlst['id'].'" LIMIT 1');
$this->error='Вы успешно отказались от задания "'.$pl['name'].'"';
}elseif($tp=='win'){
mysql_query('UPDATE `actions` SET `vals` = "win" WHERE `id` = "'.$qlst['id'].'" LIMIT 1');
}
}else{
$this->error='Не удалось отказаться от задания ...';
$qlst=mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "'.$user['id'].'" AND `vars` = "start_quest'.$id.'" AND `vals` = "go" LIMIT 1'));
$qu=mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `id` = "'.$id.'" LIMIT 1'));
if(isset($qlst['id'])){
$d=$this->expl($qu['act_date']);
if(isset($d['heal'])){
$x=$this->testAction('`uid` = "'.$user['id'].'" AND `time` > "'.$qlst['time'].'" AND `vars` LIKE "heal%" AND `vars` != "heal_'.$user['id'].'" LIMIT 1',2);
$x=($x[0]+0);
if($x<$d['heal']){
$bad=1;
}
unset($x);
}
if(isset($d['tr_win'])){
$x=$this->testAction('`uid` = "'.$user['id'].'" AND `time` > "'.$qlst['time'].'" AND `vars` = "win_fiz" LIMIT 1',2);
$x=(0+$x[0]);
if($x<$d['tr_win']){
$bad=1;
}
unset($x);
}
if(isset($d['kill_clone'])){
$x=$this->testAction('`uid` = "'.$user['id'].'" AND `time` > "'.$qlst['time'].'" AND `vars` = "kill_clone" LIMIT 1',2);
$x=(0+$x[0]);
if($x<$d['kill_clone']){
$bad=1;
}
unset($x);
}
if(isset($d['tr_win_haot'])){
$x=$this->testAction('`uid` = "'.$user['id'].'" AND `time` > "'.$qlst['time'].'" AND `vars` = "win_haot" LIMIT 1',2);
$x=(0+$x[0]);
if($x<$d['tr_win_haot']){
$bad=1;
}
unset($x);
}
if(isset($d['kill_bot'])){
$ex=explode(',',$d['kill_bot']);
$i=0;
while($i<count($ex)){
$x=0;
$ex2=explode('=',$ex[$i]);
$bot2=mysql_fetch_array(mysql_query('SELECT `id`, `login` FROM `users` WHERE `id` = "'.$ex2[0].'" LIMIT 1'));
if(isset($bot2['id'])){
if(isset($qlst['id'])){
$x=$this->testAction('`uid` = "'.$user['id'].'" AND `time` > "'.$qlst['time'].'" AND `vars` = "win_bot_'.$ex2[0].'"',2);
$x=($x[0]+0);
}
}
$i++;
}
if($x<$ex2[1]){
$bad=1;
}
unset($x);
}
if($bad==0){
$nagr=$this->expl($qu['win_date']);
mysql_query('UPDATE `actions` SET `vals` = "win" WHERE `uid` = "'.$user['id'].'" AND `vars` = "start_quest'.$id.'" LIMIT 1');