info['id'].'" LIMIT 100')); $pl1 = $pl1[0]; //Если уже более 5 квестов взяли if($d1>=$this->free_x) { $r = 0; } unset($d1,$pl1,$sp1); //Если квест уже взяли $qlst = mysql_fetch_array(mysql_query('SELECT `id`,`vals` FROM `actions` WHERE `uid` = "'.$u->info['id'].'" AND `vars` = "start_quest'.$pl['id'].'" ORDER BY `id` DESC LIMIT 1')); if(isset($qlst['id']) && $qlst['vals'] != 'win' && $qlst['vals'] != 'end' && $qlst['vals'] != 'bad') { $r = 0; } unset($qlst,$qlst2); $d = $this->expl($pl['tr_date']); //Завершить квесты [ 1,2,3,4,5 ... if(isset($d['tr_endq'])) { $i = 0; $e = explode(',',$d['tr_endq']); while($i0) { //$t .= '(Осталось: '.$u->timeOut($qlst['time']+($d['tr_zdr']*60*60)-time()).' ч.)'; $r = 0; } unset($qlst); } //Переодичность квеста if(isset($d['tr_tm1'])) { $d['tr_tm1'] = str_replace('d',date('d'),$d['tr_tm1']); $d['tr_tm1'] = str_replace('m',date('m'),$d['tr_tm1']); $d['tr_tm1'] = str_replace('y',date('y'),$d['tr_tm1']); $d['tr_tm2'] = str_replace('d',date('d'),$d['tr_tm2']); $d['tr_tm2'] = str_replace('m',date('m'),$d['tr_tm2']); $d['tr_tm2'] = str_replace('y',date('y'),$d['tr_tm2']); //проверка интервалов } //Сколько раз можно пройти квест if(isset($d['tr_raz'])) { $qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "'.$u->info['id'].'" AND `vars` = "start_quest'.$pl['id'].'" LIMIT '.$d['tr_raz'],2); if($d['tr_raz']>0 && $d['tr_raz']-$qlst[0] <= 0) { $r = 0; } unset($qlst); } //Попыток пройти квест if(isset($d['tr_raz2'])) { $qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "'.$u->info['id'].'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` != "go" AND `vals` != "win" LIMIT '.$d['tr_raz2'],2); if($d['tr_raz2']-$qlst[0] <= 0) { $r = 0; } unset($qlst); } return $r; } public function onlyOnceQuest($quests, $uid) { // Отсеиваем одноразовые квесты $result = array(); $rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "'.$uid.'" LIMIT 1')); foreach($quests as $quest){ $ok=true; $t = $this->expl($quest['tr_date']); if(isset($t['only_once']) && $t['only_once']=="1" ){ $ins = mysql_fetch_array(mysql_query('SELECT COUNT(`id`) as sum FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$quest['id'].'" AND (`vals` = "go" OR `vals` = "end")')); } else { $ins = mysql_fetch_array(mysql_query('SELECT COUNT(`id`) as sum FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$quest['id'].'" AND `vals` = "go" ')); if($ins['sum']>0) $ins['sum']='delete'; } if($ins['sum'] == 'delete'){ $ok=false; }elseif(isset($ins) && $ins['sum'] >= 1 && $rep['rep'.$quest['city']] < 10000) { $ok=false; }elseif(isset($ins) && $ins['sum'] >= 2 && $rep['rep'.$quest['city']] <= 24999 && $rep['rep'.$quest['city']] >= 10000) { $ok=false; } else $result[] = $quest; unset($ins,$t,$ok); } return $result; } /* Взять квест */ public function startq($id, $val=NULL) { global $c,$u; $pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE (`city` = "" OR `city` = "'.$u->info['city'].'") AND `delete` = "0" AND `min_lvl` <= '.$u->info['level'].' AND `max_lvl` >= '.$u->info['level'].' AND (`align` = "0" OR `align` = "'.floor($u->info['align']).'") AND `id` = "'.mysql_real_escape_string($id).'" LIMIT 1')); if(isset($pl['id'])) { $u->addAction(time(),'start_quest'.$pl['id'],'go', NULL, $val); $u->error = 'Вы успешно получили задание "'.$pl['name'].'"'; }else{ $u->error = 'Не удалось получить данное задание'; } } /* Взять квест в пещере */ public function startq_dn($id, $val=NULL) { global $c,$u; $pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `delete` = "0" AND `min_lvl` <= '.$u->info['level'].' AND `max_lvl` >= '.$u->info['level'].' AND (`align` = "0" OR `align` = "'.floor($u->info['align']).'") AND `id` = "'.mysql_real_escape_string($id).'" LIMIT 1')); if(isset($pl['id'])) { if($val==NULL) $u->addAction(time(),'start_quest'.$pl['id'],'go'); else $u->addAction(time(),'start_quest'.$pl['id'],'go', $u->info['id'], $val); $u->error = 'Вы успешно получили задание "'.$pl['name'].'"'; }else{ $u->error = 'Не удалось получить данное задание'; } } /* Отказаться от квеста */ public function endq($id,$tp) { global $u,$c; $pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `delete` = "0" AND `min_lvl` <= '.$u->info['level'].' AND `max_lvl` >= '.$u->info['level'].' AND (`align` = "0" OR `align` = "'.floor($u->info['align']).'") AND `id` = "'.mysql_real_escape_string($id).'" LIMIT 1')); $qlst = mysql_fetch_array(mysql_query('SELECT `id` FROM `actions` WHERE `uid` = "'.$u->info['id'].'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` = "go" ORDER BY `id` DESC LIMIT 1')); if(isset($qlst['id'])) { if($tp=='end') { mysql_query('UPDATE `actions` SET `vals` = "end" WHERE `id` = "'.$qlst['id'].'" LIMIT 1'); $u->error = 'Вы успешно отказались от задания "'.$pl['name'].'"'; }elseif($tp=='win') { mysql_query('UPDATE `actions` SET `vals` = "win" ,`time` = "'.time().'" WHERE `id` = "'.$qlst['id'].'" LIMIT 1'); } }else{ $u->error = 'Не удалось отказаться от задания '; } } /* Инфо о квесте в пещерах */ public function infoDng($pl) { $r = ''; global $c,$u; $r = 0; $t = ''; $xrz = 0; $qst = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "'.$u->info['id'].'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` = "go" LIMIT 1')); //Условия задания которые должны удовлетворять текущим характеристикам $d = $this->expl($pl['tr_date']); //Действия квеста $d = $this->expl($pl['act_date']); //Поговорить с NPS if(isset($d['dlg_nps'])) { $i7 = 0; $x3 = explode(',',$d['dlg_nps']); while($i7 < count($x3)) { $x4 = explode('=',$x3[$i7]); if($x4[0] > 0) { $r++; } $i7++; } unset($x1,$x3,$x4,$i7); } //Убить игроков if(isset($d['kill_user'])) { $x = 0; $r += $d['kill_user']; unset($x); } //Убить ботов if(isset($d['kill_bot'])){ $x = ''; $ex = explode(',',$d['kill_bot']); $i = 0; while($itestAction('`uid` = "'.$u->info['id'].'" AND `time` > '.$qst['time'].' AND `vars` = "win_bot_'.$ex2[0].'" LIMIT '.$ex2[1],2); $x2 = 0+$x2[0]; } if(isset($d['all_kill']) && $d['all_kill']>0){ $r = $d['all_kill']; } else { $r += $ex2[1]; } $xrz += $x2; } $i++; } unset($x,$ex,$x2,$bot2,$ex2); } //Собрать ресурсы 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 COUNT(*) FROM `items_users` WHERE `item_id` = "'.mysql_real_escape_string($ex2[0]).'" AND `uid` = "'.$u->info['id'].'" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1')); $x2[0] = (int)$x2[0]; if( $x2[0] >= $ex2[1] ) { if( $x2[0] <= ($ex2[1] + round($ex2[1]*0.15)) ){ $x2[0] = $x2[0]; } else { $x2[0] = ($ex2[1] + round($ex2[1]*0.15)); } } $r += $ex2[1]; $xrz += $x2[0]; $i++; } } //Собрать трофеи if(isset($d['tkill_itm'])) { $ex = explode(',',$d['tkill_itm']); $i = 0; $x = ''; while($i < count($ex)) { $ex2 = explode('=',$ex[$i]); $x2 = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `maidin` = "'.$pl['city'].'" AND `item_id` = "'.mysql_real_escape_string($ex2[0]).'" AND `uid` = "'.$u->info['id'].'" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1')); $x2[0] = (int)$x2[0]; if( $x2[0] >= $ex2[1] ) { if( $x2[0] <= ($ex2[1] + round($ex2[1]*0.15)) ){ $x2[0] = $x2[0]; } else { $x2[0] = ($ex2[1] + round($ex2[1]*0.15)); } } $bot2 = mysql_fetch_array(mysql_query('SELECT `id`,`name`,`img` FROM `items_main` WHERE `id` = "'.mysql_real_escape_string($ex2[0]).'" LIMIT 1')); $r += $ex2[1]; $xrz += $x2[0]; $i++; } } if( $r < 1 ) { $r = '[0/1]'; }else{ if( $xrz < 0 ) { $xrz = 0; } if( $xrz > $r ) { $xrz = $r; } //$r = '['.$xrz.'/'.$r.']'; $r = '
'.$xrz.'/'.$r.'

'; } return $r; } /* Информация о квесте */ public function info($pl) { global $c,$u; $r = ''; $t = ''; $qst = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "'.$u->info['id'].'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` = "go" LIMIT 1')); //Условия задания которые должны удовлетворять текущим характеристикам $d = $this->expl($pl['tr_date']); //Завершить квесты [ 1,2,3,4,5 ... 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 .= '
'; unset($qn); } //Из ботов падают предметы [ idbot-itm1=%,itm2=%| if(isset($d['tr_botitm'])) { $t .= 'Из ботов выпадают предметы: