и главное, что оно делает? зачем оно нужно?
This commit is contained in:
parent
afc15a384f
commit
da0aed9ffc
@ -1,29 +1,28 @@
|
||||
<?
|
||||
<?php
|
||||
|
||||
class Quests {
|
||||
public $free_x = 28, $data = array(), $error = '';
|
||||
class Quests
|
||||
{
|
||||
public $free_x = 28, $data = [], $error = '';
|
||||
|
||||
public function testGood($pl, $uid) {
|
||||
if(!is_array($pl)) {
|
||||
$pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `id` = "'.$pl.'" LIMIT 1'));
|
||||
}
|
||||
public function testGood($pl, $uid)
|
||||
{
|
||||
if (!is_array($pl)) $pl = db::c()->query('SELECT * FROM `quests` WHERE `id` = ?i', $pl)->fetch_assoc();
|
||||
|
||||
$r = 1;
|
||||
|
||||
$qlst = mysql_fetch_array(mysql_query('SELECT `id`, `vals` FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" LIMIT 1'));
|
||||
if(isset($qlst['id']) && $qlst['vals'] != 'win' && $qlst['vals'] != 'end' && $qlst['vals'] != 'bad') {
|
||||
$r = 2;
|
||||
}
|
||||
$qlst = db::c()->query('SELECT `vals` FROM `actions` WHERE `uid` = ?i AND `vars` = "?s"', $uid, 'start_quest'. $pl['id'])->fetch_assoc();
|
||||
if (db::c()->getAffectedRows() AND !in_array($qlst['vals'],['win','end','vals'])) $r = 2;
|
||||
|
||||
unset($qlst, $qlst2);
|
||||
|
||||
$d = $this->expl($pl['tr_date']);
|
||||
|
||||
if(isset($d['tr_endq'])) {
|
||||
if (isset($d['tr_endq'])) {
|
||||
$i = 0;
|
||||
$e = explode(',', $d['tr_endq']);
|
||||
while($i < count($e)) {
|
||||
$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'])) {
|
||||
while ($i < count($e)) {
|
||||
$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++;
|
||||
@ -31,15 +30,15 @@ class Quests {
|
||||
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'));
|
||||
if($qlst['time']+($d['tr_zdr']*60*60)-time() > 0) {
|
||||
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'));
|
||||
if ($qlst['time'] + ($d['tr_zdr'] * 60 * 60) - time() > 0) {
|
||||
$r = 4;
|
||||
}
|
||||
unset($qlst);
|
||||
}
|
||||
|
||||
if(isset($d['tr_tm1'])) {
|
||||
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']);
|
||||
@ -48,17 +47,17 @@ class Quests {
|
||||
$d['tr_tm2'] = str_replace('y', date('y'), $d['tr_tm2']);
|
||||
}
|
||||
|
||||
if(isset($d['tr_raz'])) {
|
||||
$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) {
|
||||
if (isset($d['tr_raz'])) {
|
||||
$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);
|
||||
if($d['tr_raz2']-$qlst[0] <= 0) {
|
||||
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);
|
||||
if ($d['tr_raz2'] - $qlst[0] <= 0) {
|
||||
$r = 6;
|
||||
}
|
||||
unset($qlst);
|
||||
@ -66,90 +65,80 @@ class Quests {
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function __clone() {
|
||||
public function __clone()
|
||||
{
|
||||
trigger_error('Дублирование не допускается.', E_USER_ERROR);
|
||||
}
|
||||
|
||||
public function startq($id, $val = NULL, $uid) {
|
||||
$pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `delete` = "0" AND `id` = "'.mysql_real_escape_string($id).'" LIMIT 1'));
|
||||
if(isset($pl['id'])) {
|
||||
$tms = (time()+60*60*$pl['time']);
|
||||
$this->addAction(time(), 'start_quest'.$pl['id'], 'go', $uid, $tms);
|
||||
$this->error = 'Вы успешно получили задание "'.$pl['name'].'"';
|
||||
public function startq($id, $uid)
|
||||
{
|
||||
$pl = db::c()->query('SELECT `id`,`name`,`time` FROM `quests` WHERE `delete` = 0 AND `id` = ?i', $id)->fetch_assoc();
|
||||
if (db::c()->getAffectedRows()) {
|
||||
$tms = (time() + 60 * 60 * $pl['time']);
|
||||
db::c()->query('INSERT INTO `actions` (`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES (?i,?i,"?s",?i,"?s","?s","?s","?s")',
|
||||
$uid, time(), 'capitalcity', 0, 'start_quest'. $id, $_SERVER['HTTP_X_REAL_IP'], 'go', $tms);
|
||||
return 'Вы успешно получили задание "' . $pl['name'] . '"';
|
||||
} else {
|
||||
$this->error = 'Не удалось получить данное задание ...';
|
||||
return 'Не удалось получить данное задание ...';
|
||||
}
|
||||
}
|
||||
|
||||
public function list_quest($pl, $u) {
|
||||
$r = ''; $t = ''; $nagr = ''; $tr = '';
|
||||
$qlst = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "'.$u.'" AND `vars` = "start_quest'.$pl['id'].'" ORDER BY `time` DESC LIMIT 1'));
|
||||
public function list_quest($pl, $u)
|
||||
{
|
||||
$r = '';
|
||||
$t = '';
|
||||
$nagr = '';
|
||||
$tr = '';
|
||||
$za = '';
|
||||
|
||||
$qlst = db::c()->query('SELECT `vals` FROM `actions` WHERE `uid` = ?i AND `vars` = "?s" ORDER BY `time` DESC', $u, 'start_quest'. $pl['id'])->fetch_assoc();
|
||||
$ds = $this->expl($pl['win_date']);
|
||||
if(isset($ds['add_cr'])) {
|
||||
$nagr .= 'Деньги : '.$ds['add_cr'].' кр. ';
|
||||
}
|
||||
if(isset($ds['add_point'])) {
|
||||
$nagr .= ' Репутация : '.$ds['add_point'].' ед. ';
|
||||
}
|
||||
if(isset($ds['add_exp'])) {
|
||||
$nagr .= ' Опыт : '.$ds['add_exp'].' ед. ';
|
||||
}
|
||||
if (isset($ds['add_cr'])) $nagr .= "Деньги: {$ds['add_cr']} кр. ";
|
||||
if (isset($ds['add_point'])) $nagr .= "Репутация: {$ds['add_point']} ед. ";
|
||||
if (isset($ds['add_exp'])) $nagr .= "Опыт: {$ds['add_exp']} ед. ";
|
||||
|
||||
$d = $this->expl($pl['act_date']);
|
||||
if(isset($d['heal'])) {
|
||||
$tr .= '<small>Вылечить <b>'.$d['heal'].'</b> игроков от травм.</small><br />';
|
||||
}
|
||||
if(isset($d['tr_win_haot'])) {
|
||||
$tr .= '<small>Выйграть <b>'.$d['tr_win_haot'].'</b> хаотических поединков.</small><br />';
|
||||
}
|
||||
if(isset($d['kill_clone'])) {
|
||||
$tr .= '<small>Выйграть <b>'.$d['kill_clone'].'</b> поединков против своего клона.</small><br />';
|
||||
}
|
||||
// if(isset($d['tr_win'])) {
|
||||
// $tr .= '<small>Выйграть <b>'.$d['tr_win'].'</b> физических поединков против игроков.</small><br />';
|
||||
// }
|
||||
if(isset($d['kill_bot'])) {
|
||||
|
||||
if (isset($d['heal'])) $tr .= "<small>Вылечить <b>{$d['heal']}</b> игроков от травм.</small><br>";
|
||||
if (isset($d['tr_win_haot'])) $tr .= "<small>Выиграть <b>{$d['tr_win_haot']}</b> хаотических поединков.</small><br>";
|
||||
if (isset($d['kill_clone'])) $tr .= "<small>Выиграть <b>{$d['kill_clone']}</b> поединков против своего клона.</small><br>";
|
||||
if(isset($d['tr_win'])) $tr .= "<small>Выйграть <b>{$d['tr_win']}</b> физических поединков против игроков.</small><br>";
|
||||
|
||||
if (isset($d['kill_bot'])) {
|
||||
$x = '';
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$i = 0;
|
||||
while($i < count($ex)) {
|
||||
while ($i < count($ex)) {
|
||||
$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'])) {
|
||||
$x .= ' • <b>'.$bot2['login'].'</b> '.$ex2[1].'<br />';
|
||||
}
|
||||
$bot2 = db::c()->query('SELECT `login` FROM `users` WHERE `id` = ?i', $ex2[0])->fetch_assoc();
|
||||
if (db::c()->getAffectedRows()) $x .= " • <b>{$bot2['login']}</b> {$ex2[1]}<br>";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if($x != '') {
|
||||
if (!empty($x)) {
|
||||
$x = trim($x, ', ');
|
||||
$tr .= '<small>Убить ботов: <br />'.$x.'</small>';
|
||||
$tr .= "<small>Убить ботов: <br>{$x}</small>";
|
||||
}
|
||||
}
|
||||
if($tr != '') {
|
||||
$ts = 'Требования :<br />'.$tr;
|
||||
}
|
||||
if (!empty($tr)) $ts = 'Требования :<br />' . $tr;
|
||||
|
||||
$za = '';
|
||||
if($qlst['time']+($pl['heal']*60*60)-time() > 0) {
|
||||
$tms = $this->timeOut($qlst['time']+($pl['heal']*60*60)-time());
|
||||
$za = '<b style=\'color: Red;\'>Задержка еще : '.$tms.'</b><br />';
|
||||
if ($qlst['time'] + ($pl['heal'] * 60 * 60) - time() > 0) {
|
||||
$tms = $this->timeOut($qlst['time'] + ($pl['heal'] * 60 * 60) - time());
|
||||
$za = "<b style='color: Red;'>Задержка еще: {$tms}</b><br />";
|
||||
}
|
||||
|
||||
$d = $this->expl($pl['tr_date']);
|
||||
$r .= '<div class="ctContainerA quest_target_item">';
|
||||
$r .= '<div class="ctTitle"><a class="action-start" href="?quid='.$pl['id'].'">я берусь</a>Задание "'.$pl['name'].'"</div>';
|
||||
$r .= '<div class="ctTitle"><a class="action-start" href="?quid=' . $pl['id'] . '">я берусь</a>Задание "' . $pl['name'] . '"</div>';
|
||||
|
||||
$r .= '<div><div>'.$pl['info'].'<hr style=\'width: 75%;\' /></div>
|
||||
$r .= '<div><div>' . $pl['info'] . '<hr style=\'width: 75%;\' /></div>
|
||||
<div>
|
||||
<div><span style=\'font-weight: bold;\'>Награда :</span> '.$nagr.'</div>
|
||||
<div><span style=\'font-weight: bold;\'>Награда :</span> ' . $nagr . '</div>
|
||||
</div>
|
||||
<div>
|
||||
<span style=\'font-weight: bold;\'>Время на выполнение:</span> '.$pl['time'].' ч.</span><br />
|
||||
'.$ts.$za.'
|
||||
<span style=\'font-weight: bold;\'>Время на выполнение:</span> ' . $pl['time'] . ' ч.</span><br />
|
||||
' . $ts . $za . '
|
||||
<div>
|
||||
Задание для ['.$pl['min_lvl'].'-'.$pl['max_lvl'].'] уровней, с задержкой '.$pl['heal'].' ч.
|
||||
Задание для [' . $pl['min_lvl'] . '-' . $pl['max_lvl'] . '] уровней, с задержкой ' . $pl['heal'] . ' ч.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -161,20 +150,22 @@ class Quests {
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function info($pl, $uid) {
|
||||
$r = ''; $t = '';
|
||||
$qst = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` = "go" LIMIT 1'));
|
||||
public function info($pl, $uid)
|
||||
{
|
||||
$r = '';
|
||||
$t = '';
|
||||
$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'])) {
|
||||
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'].'", ';
|
||||
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++;
|
||||
@ -184,27 +175,27 @@ class Quests {
|
||||
unset($qn);
|
||||
}
|
||||
|
||||
if(isset($d['tr_botitm'])) {
|
||||
if (isset($d['tr_botitm'])) {
|
||||
$t .= 'Из ботов выпадают предметы :<ul>';
|
||||
$e = explode('|', $d['tr_botitm']);
|
||||
$i = 0;
|
||||
while($i < count($e)) {
|
||||
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'].'" выпадает: ';
|
||||
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)) {
|
||||
$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'));
|
||||
$t .= '<img src="/i/sh/'.$qi['img'].'" style="max-height: 12px;"> '.$qi['name'].', ';
|
||||
$qi = mysql_fetch_array(mysql_query('SELECT `id`, `name`, `img` FROM `shop` WHERE `id` = "' . $e4[0] . '" LIMIT 1'));
|
||||
$t .= '<img src="/i/sh/' . $qi['img'] . '" style="max-height: 12px;"> ' . $qi['name'] . ', ';
|
||||
$j++;
|
||||
}
|
||||
$t = trim($t, ', ');
|
||||
@ -214,16 +205,16 @@ class Quests {
|
||||
unset($qn, $qi, $e2, $e3, $e4);
|
||||
}
|
||||
|
||||
if(isset($d['tr_winitm'])) {
|
||||
if (isset($d['tr_winitm'])) {
|
||||
$t .= 'После победы выпадают предметы :<br />';
|
||||
$e = explode('|', $d['tr_winitm']);
|
||||
$i = 0;
|
||||
while($i < count($e)) {
|
||||
while ($i < count($e)) {
|
||||
$j = 0;
|
||||
$e2 = explode('-', $e[$i]);
|
||||
$t .= ' • ';
|
||||
|
||||
if($e2[0] > 0) {
|
||||
if ($e2[0] > 0) {
|
||||
$t .= 'Из людей выпадает : ';
|
||||
} else {
|
||||
$t .= 'Из ботов выпадает : ';
|
||||
@ -231,10 +222,10 @@ class Quests {
|
||||
|
||||
$j = 0;
|
||||
$e3 = explode(',', $e2[1]);
|
||||
while($j < count($e3)) {
|
||||
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'));
|
||||
$t .= '<img src="/i/sh/'.$qi['img'].'" style="max-height: 12px;"> '.$qi['name'].', ';
|
||||
$qi = mysql_fetch_array(mysql_query('SELECT `id`, `name`, `img` FROM `shop` WHERE `id` = "' . $e4[0] . '" LIMIT 1'));
|
||||
$t .= '<img src="/i/sh/' . $qi['img'] . '" style="max-height: 12px;"> ' . $qi['name'] . ', ';
|
||||
$j++;
|
||||
}
|
||||
$t = trim($t, ', ');
|
||||
@ -244,243 +235,249 @@ class Quests {
|
||||
unset($qn, $qi, $e2, $e3, $e4);
|
||||
}
|
||||
|
||||
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" LIMIT 1'));
|
||||
$t .= 'Задержка между выполнением задания : '.$this->timeOut($d['tr_zdr']*60*60);
|
||||
if($qlst['time']+($d['tr_zdr']*60*60)-time() > 0) {
|
||||
$t .= '<small>(Осталось : '.$this->timeOut($qlst['time']+($d['tr_zdr']*60*60)-time()).' ч.)</small>';
|
||||
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" LIMIT 1'));
|
||||
$t .= 'Задержка между выполнением задания : ' . $this->timeOut($d['tr_zdr'] * 60 * 60);
|
||||
if ($qlst['time'] + ($d['tr_zdr'] * 60 * 60) - time() > 0) {
|
||||
$t .= '<small>(Осталось : ' . $this->timeOut($qlst['time'] + ($d['tr_zdr'] * 60 * 60) - time()) . ' ч.)</small>';
|
||||
}
|
||||
$t .= '<br />';
|
||||
unset($qlst);
|
||||
}
|
||||
|
||||
if(isset($d['tr_tm1'])) {
|
||||
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']);
|
||||
$t .= 'Период квеста : '.$d['tr_tm1'].' - '.$d['tr_tm2'].'<br />';
|
||||
$t .= 'Период квеста : ' . $d['tr_tm1'] . ' - ' . $d['tr_tm2'] . '<br />';
|
||||
}
|
||||
|
||||
if(isset($d['tr_raz'])) {
|
||||
if($d['tr_raz'] == -1) {
|
||||
if (isset($d['tr_raz'])) {
|
||||
if ($d['tr_raz'] == -1) {
|
||||
$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 />';
|
||||
$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);
|
||||
$t .= 'Осталось попыток выполнить задание : '.($d['tr_raz2']-$qlst[0]).'<br />';
|
||||
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);
|
||||
$t .= 'Осталось попыток выполнить задание : ' . ($d['tr_raz2'] - $qlst[0]) . '<br />';
|
||||
unset($qlst);
|
||||
}
|
||||
|
||||
$d = $this->expl($pl['act_date']);
|
||||
|
||||
if(isset($d['kill_bot'])) {
|
||||
if (isset($d['kill_bot'])) {
|
||||
$x = '';
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$i = 0;
|
||||
if(isset($d['all_kill']) && $d['all_kill'] > 0 ) {
|
||||
while($i < count($ex)) {
|
||||
if (isset($d['all_kill']) && $d['all_kill'] > 0) {
|
||||
while ($i < count($ex)) {
|
||||
$x2 = 0;
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
if(isset($qst['id'])) {
|
||||
$x2 = $this->testAction('`uid` = "'.$uid.'" AND `time` > '.$qst['time'].' AND `vars` = "win_bot_'.$ex2[0].'" LIMIT '.$ex2[1], 2);
|
||||
$x2 = (0+$x2[0]);
|
||||
if (isset($qst['id'])) {
|
||||
$x2 = $this->testAction('`uid` = "' . $uid . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
|
||||
$x2 = (0 + $x2[0]);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$ex2[0].'" LIMIT 1'));
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
|
||||
$bot2['id'] = $bot2['id'];
|
||||
if(isset($bot2['id'])){
|
||||
$x .= ' • <b>'.$bot2['login'].'</b> ['.$x2.'/'.$d['all_kill'].']<br />';
|
||||
if (isset($bot2['id'])) {
|
||||
$x .= ' • <b>' . $bot2['login'] . '</b> [' . $x2 . '/' . $d['all_kill'] . ']<br />';
|
||||
} else {
|
||||
$x .= ' • <b>'.$pl['name'].'</b> ['.$x2.'/'.$d['all_kill'].']<br />';
|
||||
$x .= ' • <b>' . $pl['name'] . '</b> [' . $x2 . '/' . $d['all_kill'] . ']<br />';
|
||||
}
|
||||
} else {
|
||||
while($i < count($ex)) {
|
||||
while ($i < count($ex)) {
|
||||
$x2 = 0;
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$ex2[0].'" LIMIT 1'));
|
||||
if(isset($bot2['id'])) {
|
||||
if(isset($qst['id'])) {
|
||||
$x2 = $this->testAction('`uid` = "'.$uid.'" AND `time` > '.$qst['time'].' AND `vars` = "win_bot_'.$ex2[0].'" LIMIT '.$ex2[1], 2);
|
||||
$x2 = (0+$x2[0]);
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
|
||||
if (isset($bot2['id'])) {
|
||||
if (isset($qst['id'])) {
|
||||
$x2 = $this->testAction('`uid` = "' . $uid . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
|
||||
$x2 = (0 + $x2[0]);
|
||||
}
|
||||
$x .= ' • <b>'.$bot2['login'].'</b> ['.$x2.'/'.$ex2[1].']<br />';
|
||||
$x .= ' • <b>' . $bot2['login'] . '</b> [' . $x2 . '/' . $ex2[1] . ']<br />';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
if($x != '') {
|
||||
if ($x != '') {
|
||||
$x = trim($x, ', ');
|
||||
$t .= 'Убить ботов: <br />'.$x.'';
|
||||
$t .= 'Убить ботов: <br />' . $x . '';
|
||||
}
|
||||
unset($x, $ex, $x2, $bot2, $ex2);
|
||||
}
|
||||
|
||||
if(isset($d['tr_win_haot'])) {
|
||||
$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 />';
|
||||
if (isset($d['tr_win_haot'])) {
|
||||
$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 />';
|
||||
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 />';
|
||||
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 />';
|
||||
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'])) {
|
||||
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'));
|
||||
$x .= ' • <b>'.$bot2['name'].'</b> ['.$x2[0].'/'.$ex2[1].']<br />';
|
||||
$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'));
|
||||
$x .= ' • <b>' . $bot2['name'] . '</b> [' . $x2[0] . '/' . $ex2[1] . ']<br />';
|
||||
$i++;
|
||||
}
|
||||
|
||||
if($x != '') {
|
||||
if ($x != '') {
|
||||
$x = trim($x, ', ');
|
||||
$t .= 'Собрать ресурсы : <br />'.$x.'';
|
||||
$t .= 'Собрать ресурсы : <br />' . $x . '';
|
||||
}
|
||||
}
|
||||
|
||||
if($t != '') {
|
||||
$r .= '<b>Условия задания :</b><br />'.$t.'<br />';
|
||||
if ($t != '') {
|
||||
$r .= '<b>Условия задания :</b><br />' . $t . '<br />';
|
||||
$t = '';
|
||||
}
|
||||
|
||||
$ds = $this->expl($pl['win_date']);
|
||||
if(isset($ds['add_cr'])) {
|
||||
$t .= 'Деньги : '.$ds['add_cr'].' кр.<br />';
|
||||
if (isset($ds['add_cr'])) {
|
||||
$t .= 'Деньги : ' . $ds['add_cr'] . ' кр.<br />';
|
||||
}
|
||||
|
||||
if(isset($ds['add_point'])) {
|
||||
$t .= 'Репутация : '.$ds['add_point'].' ед.<br />';
|
||||
if (isset($ds['add_point'])) {
|
||||
$t .= 'Репутация : ' . $ds['add_point'] . ' ед.<br />';
|
||||
}
|
||||
|
||||
if(isset($ds['add_exp'])) {
|
||||
$t .= 'Опыт : '.$ds['add_exp'].' ед.<br />';
|
||||
if (isset($ds['add_exp'])) {
|
||||
$t .= 'Опыт : ' . $ds['add_exp'] . ' ед.<br />';
|
||||
}
|
||||
|
||||
if($t != '') {
|
||||
$r = '<b>Награда:</b><br />'.$t.'<br />'.$r;
|
||||
if ($t != '') {
|
||||
$r = '<b>Награда:</b><br />' . $t . '<br />' . $r;
|
||||
$t = '';
|
||||
}
|
||||
|
||||
if($t != '') {
|
||||
$r = '<br /><b>Действия задания :</b><br />'.$t.'<br />'.$r;
|
||||
if ($t != '') {
|
||||
$r = '<br /><b>Действия задания :</b><br />' . $t . '<br />' . $r;
|
||||
$t = '';
|
||||
}
|
||||
|
||||
if($r == '') {
|
||||
if ($r == '') {
|
||||
$r = 'Дополнительная информация по заданию отсутствует';
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function endq($id, $tp, $user) {
|
||||
$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');
|
||||
public function endq($id, $tp, $user)
|
||||
{
|
||||
$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 = 'Не удалось отказаться от задания ...';
|
||||
}
|
||||
}
|
||||
|
||||
public function testAction($filter, $tp) {
|
||||
if($tp == 1) {
|
||||
$ins = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val` FROM `actions` WHERE '.$filter.''));
|
||||
} elseif($tp == 2) {
|
||||
$ins = mysql_fetch_array(mysql_query('SELECT COUNT(`id`) FROM `actions` WHERE '.$filter.''));
|
||||
public function testAction($filter, $tp)
|
||||
{
|
||||
if ($tp == 1) {
|
||||
$ins = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val` FROM `actions` WHERE ' . $filter . ''));
|
||||
} elseif ($tp == 2) {
|
||||
$ins = mysql_fetch_array(mysql_query('SELECT COUNT(`id`) FROM `actions` WHERE ' . $filter . ''));
|
||||
}
|
||||
return $ins;
|
||||
}
|
||||
|
||||
public function timeOut($ttm) {
|
||||
public function timeOut($ttm)
|
||||
{
|
||||
$out = '';
|
||||
$time_still = $ttm;
|
||||
$tmp = floor($time_still/2592000);
|
||||
$tmp = floor($time_still / 2592000);
|
||||
$id = 0;
|
||||
if($tmp > 0) {
|
||||
if ($tmp > 0) {
|
||||
$id++;
|
||||
if($id < 3) { $out .= $tmp." мес. "; }
|
||||
$time_still = $time_still-$tmp*2592000;
|
||||
if ($id < 3) {
|
||||
$out .= $tmp . " мес. ";
|
||||
}
|
||||
$tmp = floor($time_still/86400);
|
||||
if($tmp > 0) {
|
||||
$time_still = $time_still - $tmp * 2592000;
|
||||
}
|
||||
$tmp = floor($time_still / 86400);
|
||||
if ($tmp > 0) {
|
||||
$id++;
|
||||
if($id < 3) { $out .= $tmp." дн. "; }
|
||||
$time_still = $time_still-$tmp*86400;
|
||||
if ($id < 3) {
|
||||
$out .= $tmp . " дн. ";
|
||||
}
|
||||
$tmp = floor($time_still/3600);
|
||||
if($tmp > 0) {
|
||||
$time_still = $time_still - $tmp * 86400;
|
||||
}
|
||||
$tmp = floor($time_still / 3600);
|
||||
if ($tmp > 0) {
|
||||
$id++;
|
||||
if($id < 3) { $out .= $tmp." ч. "; }
|
||||
$time_still = $time_still-$tmp*3600;
|
||||
if ($id < 3) {
|
||||
$out .= $tmp . " ч. ";
|
||||
}
|
||||
$tmp = floor($time_still/60);
|
||||
if($tmp > 0) {
|
||||
$time_still = $time_still - $tmp * 3600;
|
||||
}
|
||||
$tmp = floor($time_still / 60);
|
||||
if ($tmp > 0) {
|
||||
$id++;
|
||||
if($id < 3) { $out .= $tmp." мин. "; }
|
||||
if ($id < 3) {
|
||||
$out .= $tmp . " мин. ";
|
||||
}
|
||||
if($out == '') {
|
||||
if($time_still < 0) {
|
||||
}
|
||||
if ($out == '') {
|
||||
if ($time_still < 0) {
|
||||
$time_still = 0;
|
||||
}
|
||||
$out = $time_still.' сек.';
|
||||
$out = $time_still . ' сек.';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function addAction($time, $vars, $vls, $uid, $val) {
|
||||
$ins = mysql_query('INSERT INTO `actions` (`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("'.$uid.'", "'.$time.'", "capitalcity", "0", "'.mysql_real_escape_string($vars).'", "'.mysql_real_escape_string($_SERVER['HTTP_X_REAL_IP']).'", "'.mysql_real_escape_string($vls).'", "'.$val.'")');
|
||||
if($ins) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function expl($d) {
|
||||
|
||||
public function expl($d)
|
||||
{
|
||||
$i = 0;
|
||||
$e = explode(':|:', $d);
|
||||
while($i < count($e)) {
|
||||
while ($i < count($e)) {
|
||||
$t = explode(':=:', $e[$i]);
|
||||
if(isset($t[0])) {
|
||||
if (isset($t[0])) {
|
||||
$dr[$t[0]] = $t[1];
|
||||
}
|
||||
$i++;
|
||||
@ -489,86 +486,98 @@ class Quests {
|
||||
return $dr;
|
||||
}
|
||||
|
||||
public function winqst($id, $user) {
|
||||
public function winqst($id, $user)
|
||||
{
|
||||
$bad = 0;
|
||||
$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'])) {
|
||||
$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; }
|
||||
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; }
|
||||
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; }
|
||||
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; }
|
||||
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'])) {
|
||||
if (isset($d['kill_bot'])) {
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$i = 0;
|
||||
while($i < count($ex)) {
|
||||
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);
|
||||
$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; }
|
||||
if ($x < $ex2[1]) {
|
||||
$bad = 1;
|
||||
}
|
||||
unset($x);
|
||||
}
|
||||
|
||||
if($bad == 0) {
|
||||
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');
|
||||
if(isset($nagr['add_cr'])) {
|
||||
$user['money'] += $nagr['add_cr']; $c .= $nagr['add_cr'].' кр. ';
|
||||
mysql_query('UPDATE `actions` SET `vals` = "win" WHERE `uid` = "' . $user['id'] . '" AND `vars` = "start_quest' . $id . '" LIMIT 1');
|
||||
if (isset($nagr['add_cr'])) {
|
||||
$user['money'] += $nagr['add_cr'];
|
||||
$c .= $nagr['add_cr'] . ' кр. ';
|
||||
}
|
||||
if(isset($nagr['add_point'])) {
|
||||
if (isset($nagr['add_point'])) {
|
||||
$user['doblest'] += $nagr['add_point'];
|
||||
if(isset($nagr['add_cr'])) {
|
||||
$c .= 'и '.$nagr['add_point'].' репутации ';
|
||||
if (isset($nagr['add_cr'])) {
|
||||
$c .= 'и ' . $nagr['add_point'] . ' репутации ';
|
||||
} else {
|
||||
$c .= $nagr['add_point'].' репутации ';
|
||||
$c .= $nagr['add_point'] . ' репутации ';
|
||||
}
|
||||
}
|
||||
if(isset($nagr['add_exp'])) {
|
||||
if (isset($nagr['add_exp'])) {
|
||||
$user['exp'] += $nagr['add_exp'];
|
||||
if(isset($nagr['add_cr']) || isset($nagr['add_point'])) {
|
||||
$c .= 'и '.$nagr['add_exp'].' опыта';
|
||||
if (isset($nagr['add_cr']) || isset($nagr['add_point'])) {
|
||||
$c .= 'и ' . $nagr['add_exp'] . ' опыта';
|
||||
} else {
|
||||
$c .= $nagr['add_exp'].' опыта';
|
||||
$c .= $nagr['add_exp'] . ' опыта';
|
||||
}
|
||||
}
|
||||
mysql_query('UPDATE `users` SET `money` = "'.$user['money'].'", `exp` = "'.$user['exp'].'", `doblest` = "'.$user['doblest'].'" WHERE `id` = "'.$user['id'].'" LIMIT 1');
|
||||
mysql_query('UPDATE `users` SET `money` = "' . $user['money'] . '", `exp` = "' . $user['exp'] . '", `doblest` = "' . $user['doblest'] . '" WHERE `id` = "' . $user['id'] . '" LIMIT 1');
|
||||
$this->error = 'Вы успешно сдали задание!';
|
||||
$text = '<font style="color: Red;">Внимание!</font> За успешно выполненное задание Вы получили : '.$c;
|
||||
$this->msg($text, '{[]}'.$user['login'].'{[]}', $user['room']);
|
||||
$text = '<font style="color: Red;">Внимание!</font> За успешно выполненное задание Вы получили : ' . $c;
|
||||
$this->msg($text, '{[]}' . $user['login'] . '{[]}', $user['room']);
|
||||
} else {
|
||||
$this->error = 'Не все условия задания были выполнены ...';
|
||||
}
|
||||
@ -577,10 +586,11 @@ class Quests {
|
||||
}
|
||||
}
|
||||
|
||||
public function msg($text, $who, $room) {
|
||||
public function msg($text, $who, $room)
|
||||
{
|
||||
$fp = fopen("/tmp/chat.txt", "a");
|
||||
flock($fp, LOCK_EX);
|
||||
fputs($fp, ":[".time()."]:[{$who}]:[".($text)."]:[".$room."]\r\n");
|
||||
fputs($fp, ":[" . time() . "]:[{$who}]:[" . ($text) . "]:[" . $room . "]\r\n");
|
||||
fflush($fp);
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
|
@ -21,7 +21,7 @@ if ($get == 'hps') {
|
||||
if (isset($_GET['quid'])) {
|
||||
$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($_GET['quid']) . '" LIMIT 1'));
|
||||
if (isset($pl['id']) && $q->testGood($pl, $user['id']) == 1) {
|
||||
echo $q->startq($pl['id'], null, $user['id']);
|
||||
echo $q->startq($pl['id'], $user['id']);
|
||||
} elseif ($q->testGood($pl, $user['id']) == 2) {
|
||||
$status = 'У вас уже есть такое задание ...';
|
||||
} elseif ($q->testGood($pl, $user['id']) == 3) {
|
||||
|
Loading…
Reference in New Issue
Block a user