$db->query('SELECT `name` FROM `items` WHERE `id` = ?'); $db->execute([$task['awarded_item']]); $task['item'] = $db->num_rows() ? $items->name($task['awarded_item']) . ' x' . $mtg->format($task['awarded_item_qty']) : 'None'; } else { $task['awarded_item'] = 0; $task['item'] = 'None'; } $repl = [$my['total_stats'], $my['strength'], $my['agility'], $my['guard'], $my['labour'], $my['iq'], $my['money'], $my['points'], $my['power'], $my['energy'], $my['nerve'], $my['health'], $my['exp'], $task['xp_awarded'], $set['main_currency_symbol'] . $mtg->format($task['money']), $mtg->format($task['points']) . ' point' . $mtg->s($task['points']), $task['item'], $mtg->time_format($task['time_hospital'] * 60), $mtg->time_format($task['time_jail'] * 60)]; $strs = ['text_start', 'text_success', 'text_failure', 'text_jail', 'text_reason_jail', 'text_hospital', 'text_reason_jail']; foreach ($strs as $str) { if (array_key_exists($str, $task)) { $task[$str] = str_replace($find, $repl, $task[$str]); } } $parser->parse(nl2br($mtg->format($task['text_start']))); echo '<p>', $parser->getAsHTML(), '</p>'; $process = '$formula = ' . str_replace($find, $repl, $task['formula']) . ';'; eval($process); $formula += mt_rand(0, 50); if ($formula >= 0 && $formula <= 10 && ($task['time_jail'] || $task['time_hospital'])) { if ($task['time_jail'] && $task['time_hospital']) { $rand = mt_rand(0, 1); $which = $rand == 1 ? 'hospital' : 'jail'; } else { $which = $task['jail_time'] ? 'jail' : 'hospital'; } $db->startTrans(); $db->query('UPDATE `users` SET `' . $which . '` = ?, `' . $which . '_reason` = ? WHERE id = ?'); $db->execute([$task['time_' . $which], $task['text_reason_' . $which], $id]); $col = $which == 'jail' ? 'jailed' : 'hospitalised'; $db->query('UPDATE `users_stats` SET `nerve` = `nerve` = ?, `tasks_' . $col . '` = `tasks_' . $col . '` + 1 WHERE `id` = ?');