• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Znote AAC: Remove Town choice when creating character

Jfrye

Mapper, trying to learn scripting
Joined
Jan 8, 2009
Messages
366
Solutions
5
Reaction score
86
Location
Mexico Missouri
As the title says, How can I remove the town selection from the Create Character page? When I tried to remove the code from config, it says
  • Permission Denied. Wrong town.
 
Wrong board. Please move thread, since I cant edit it.
An easy work around would be to add style="display: none;" to town select html element. And make just one town available at config.php.
Code:
      <li style="display: none;">
         <!-- Available towns to select from when creating character -->
         Town:<br>
         <select name="selected_town">
         <?php foreach ($config['available_towns'] as $tid) { ?>
         <option value="<?php echo $tid; ?>"><?php echo town_id_to_name($tid); ?></option>
         <?php } ?>
         </select>
       </li>
Else you would have to remove it. And also change this:
Code:
  $required_fields = array('name', 'selected_town');
Remove this
Code:
       // Validate town id
       if (!in_array((int)$_POST['selected_town'], $config['available_towns'])) {
         $errors[] = 'Permission Denied. Wrong town.';
       }
And hard code the town id here
Code:
     $character_data = array(
       'name'     =>   format_character_name($_POST['name']),
       'account_id'=>   $session_user_id,
       'vocation'   =>   $_POST['selected_vocation'],
       'town_id'   =>   $_POST['selected_town'],
       'sex'     =>   $_POST['selected_gender'],
       'lastip'   =>   ip2long(getIP()),
       'created'   =>   time()
     );
 
Town names and ID:
https://github.com/Znote/ZnoteAAC/blob/master/config.php#L319-L324
PHP:
    // Town ids and names: (In RME map editor, open map, click CTRL + T to view towns, their names and their IDs.
    // townID => 'townName' etc: ['3'=>'Thais']
    $config['towns'] = array(
        2 => 'Thyrfing',
        3 => 'Town 3',
    );

Allowed towns when creating a character:
https://github.com/Znote/ZnoteAAC/blob/master/config.php#L369-L370
PHP:
    // Available towns (specify town ids, etc: (0, 1, 2); to display 3 town options (town id 0, 1 and 2).
    $config['available_towns'] = array(2);

Just edit available_towns with the town ID you want players to be able to choose from.
Make sure those town_ids have a name in the above config ['towns'].

The town select field when creating character should automatically update with only the allowed towns. At least on the official versions of Znote AAC.
 
Last edited:
@Znote, I have that part working ok, but I want to remove the option for them to choose the town. Currently they have 1 town that they can choose, so really there is no need for the selection box to be there for my needs. When I remove the selection box, I get the error I posted above. I will try @Peonso suggestion when I get back to the computer in a few hours and post my findings.
 
@Znote, I have that part working ok, but I want to remove the option for them to choose the town. Currently they have 1 town that they can choose, so really there is no need for the selection box to be there for my needs. When I remove the selection box, I get the error I posted above. I will try @Peonso suggestion when I get back to the computer in a few hours and post my findings.

Don't use his solution, it is just extremely dirty. You can just do in createcharacter.php:

PHP:
$town = (count($config['available_towns']) > 1) ? $_POST['selected_town'] : end($config['available_towns']);
//Register
$character_data = array(
    'name'      =>  format_character_name($_POST['name']),
    'account_id'=>  $session_user_id,
    'vocation'  =>  $_POST['selected_vocation'],
    'town_id'   =>  $town,
    'sex'       =>  $_POST['selected_gender'],
    'lastip'    =>  ip2long(getIP()),
    'created'   =>  time()
);

<?php if (count($config['available_towns']) > 1): ?>
<li>
    <!-- Available towns to select from when creating character -->
    Town:<br>
    <select name="selected_town">
    <?php foreach ($config['available_towns'] as $tid) { ?>
    <option value="<?php echo $tid; ?>"><?php echo town_id_to_name($tid); ?></option>
    <?php } ?>
    </select>
</li>
<?php endif; ?>

Whole file: https://gist.github.com/cornex/3fdd02786b04feb01b75
 
Back
Top