* @copyright 2017 MyAAC * @version 0.2.2 * @link http://my-aac.org */ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Commands'; if($config['otserv_version'] == TFS_03): ?> List of all your commands, you can check in game, by writing - /commands.

command
Words:
Description:
query('SELECT ' . $db->fieldName('id') . ', ' . $db->fieldName('words') . ', ' . $db->fieldName('description') . ($canEdit ? ', ' . $db->fieldName('hidden') . ', ' . $db->fieldName('ordering') : '') . ' FROM ' . $db->tableName(TABLE_PREFIX . 'commands') . (!$canEdit ? ' WHERE ' . $db->fieldName('hidden') . ' != 1' : '') . ' ORDER BY ' . $db->fieldName('ordering')); $last = $commands->rowCount(); $i = 0; foreach($commands as $command): ?>
Words Description Options
Edit Delete Move up Move down
select(TABLE_PREFIX . 'commands', array('words' => $words)); if($query === false) { $query = $db->query( 'SELECT ' . $db->fieldName('ordering') . ' FROM ' . $db->tableName(TABLE_PREFIX . 'commands') . ' ORDER BY ' . $db->fieldName('ordering') . ' DESC LIMIT 1' ); $ordering = 0; if($query->rowCount() > 0) { $query = $query->fetch(); $ordering = $query['ordering'] + 1; } $db->insert(TABLE_PREFIX . 'commands', array('words' => $words, 'description' => $description, 'ordering' => $ordering)); } else $errors[] = 'Command with this words already exists.'; } else $errors[] = 'Please fill all inputs.'; return !count($errors); } static public function get($id) { global $db; return $db->select(TABLE_PREFIX . 'commands', array('id' => $id)); } static public function update($id, $words, $description) { global $db; $db->update(TABLE_PREFIX . 'commands', array('words' => $words, 'description' => $description), array('id' => $id)); } static public function delete($id, &$errors) { global $db; if(isset($id)) { if($db->select(TABLE_PREFIX . 'commands', array('id' => $id)) !== false) $db->delete(TABLE_PREFIX . 'commands', array('id' => $id)); else $errors[] = 'Command with id ' . $id . ' does not exists.'; } else $errors[] = 'id not set'; return !count($errors); } static public function toggleHidden($id, &$errors) { global $db; if(isset($id)) { $query = $db->select(TABLE_PREFIX . 'commands', array('id' => $id)); if($query !== false) $db->update(TABLE_PREFIX . 'commands', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id)); else $errors[] = 'Command with id ' . $id . ' does not exists.'; } else $errors[] = 'id not set'; return !count($errors); } static public function move($id, $i, &$errors) { global $db; $query = $db->select(TABLE_PREFIX . 'commands', array('id' => $id)); if($query !== false) { $ordering = $query['ordering'] + $i; $old_record = $db->select(TABLE_PREFIX . 'commands', array('ordering' => $ordering)); if($old_record !== false) $db->update(TABLE_PREFIX . 'commands', array('ordering' => $query['ordering']), array('ordering' => $ordering)); $db->update(TABLE_PREFIX . 'commands', array('ordering' => $ordering), array('id' => $id)); } else $errors[] = 'Command with id ' . $id . ' does not exists.'; return !count($errors); } } ?>