Znote - Create Character No Rook

Discussion in 'Support' started by Zaggyzigzig, Feb 2, 2015.

  1. Zaggyzigzig

    Zaggyzigzig plx itens menz

    Joined:
    Aug 25, 2014
    Messages:
    389
    Likes Received:
    50
    Best Answers:
    0
    Hello, I have been trying to script in no rook for my server because we removed rook, I cannot seem to figure this out! I am trying to make it so players can choose a vocation, and also start in thais!

    Anyone out there understand Z-note? I can't get this..
    PHP:
    1. <?php require_once 'engine/init.php';
    2. protect_page();
    3. include 'layout/overall/header.php';
    4.  
    5. if (empty($_POST) === false) {
    6.     // $_POST['']
    7.     $required_fields = array('name', 'selected_town');
    8.     foreach($_POST as $key=>$value) {
    9.         if (empty($value) && in_array($key, $required_fields) === true) {
    10.             $errors[] = 'You need to fill in all fields.';
    11.             break 1;
    12.         }
    13.     }
    14.  
    15.     // check errors (= user exist, pass long enough
    16.     if (empty($errors) === true) {
    17.         if (!Token::isValid($_POST['token'])) {
    18.             $errors[] = 'Token is invalid.';
    19.         }
    20.         $_POST['name'] = validate_name($_POST['name']);
    21.         if ($_POST['name'] === false) {
    22.             $errors[] = 'Your name can not contain more than 2 words.';
    23.         } else {
    24.             if (user_character_exist($_POST['name']) === true) {
    25.                 $errors[] = 'Sorry, that character name already exist.';
    26.             }
    27.             if (!preg_match("/^[a-zA-Z_ ]+$/", $_POST['name'])) {
    28.                 $errors[] = 'Your name may only contain a-z, A-Z and spaces.';
    29.             }
    30.             if (strlen($_POST['name']) < $config['minL'] || strlen($_POST['name']) > $config['maxL']) {
    31.                 $errors[] = 'Your character name must be between 4 - 20 characters long.';
    32.             }
    33.             // name restriction
    34.             $resname = explode(" ", $_POST['name']);
    35.             foreach($resname as $res) {
    36.                 if(in_array(strtolower($res), $config['invalidNameTags'])) {
    37.                     $errors[] = 'Your name contains a restricted word.';
    38.                 }
    39.                 else if(strlen($res) == 1) {
    40.                     $errors[] = 'Too short words in your name.';
    41.                 }
    42.             }
    43.             // Validate vocation id
    44.             if (!in_array((int)$_POST['selected_vocation'], $config['available_vocations'])) {
    45.                 $errors[] = 'Permission Denied. Wrong vocation.';
    46.             }
    47.             // Validate town id
    48.             if (!in_array((int)$_POST['selected_town'], $config['available_towns'])) {
    49.                 $errors[] = 'Permission Denied. Wrong town.';
    50.             }
    51.             // Validate gender id
    52.             if (!in_array((int)$_POST['selected_gender'], array(0, 1))) {
    53.                 $errors[] = 'Permission Denied. Wrong gender.';
    54.             }
    55.             if (vocation_id_to_name($_POST['selected_vocation']) === false) {
    56.                 $errors[] = 'Failed to recognize that vocation, does it exist?';
    57.             }
    58.             if (town_id_to_name($_POST['selected_town']) === false) {
    59.                 $errors[] = 'Failed to recognize that town, does it exist?';
    60.             }
    61.             if (gender_exist($_POST['selected_gender']) === false) {
    62.                 $errors[] = 'Failed to recognize that gender, does it exist?';
    63.             }
    64.             // Char count
    65.             $char_count = user_character_list_count($session_user_id);
    66.             if ($char_count >= $config['max_characters']) {
    67.                 $errors[] = 'Your account is not allowed to have more than '. $config['max_characters'] .' characters.';
    68.             }
    69.             if (validate_ip(getIP()) === false && $config['validate_IP'] === true) {
    70.                 $errors[] = 'Failed to recognize your IP address. (Not a valid IPv4 address).';
    71.             }
    72.         }
    73.     }
    74. }
    75. ?>
    76.  
    77. <h1>Create Character</h1>
    78. <?php
    79. if (isset($_GET['success']) && empty($_GET['success'])) {
    80.     echo 'Congratulations!<br>Your character has been created!';
    81. } else {
    82.     if (empty($_POST) === false && empty($errors) === true) {
    83.         if ($config['log_ip']) {
    84.             znote_visitor_insert_detailed_data(2);
    85.         }
    86.         //Register
    87.         $character_data = array(
    88.             'name'        =>    format_character_name($_POST['name']),
    89.             'account_id'=>    $session_user_id,
    90.             'vocation'    =>    $_POST['selected_vocation'],
    91.             'town_id'    =>    $_POST['selected_town'],
    92.             'sex'        =>    $_POST['selected_gender'],
    93.             'lastip'    =>    ip2long(getIP()),
    94.             'created'    =>    time()
    95.         );
    96.  
    97.         user_create_character($character_data);
    98.         header('Location: createcharacter.php?success');
    99.         exit();
    100.         //End register
    101.  
    102.     } else if (empty($errors) === false){
    103.         echo '<font color="red"><b>';
    104.         echo output_errors($errors);
    105.         echo '</b></font>';
    106.     }
    107.     ?>
    108.     <form action="" method="post">
    109.         <ul>
    110.             <li>
    111.                 Name:<br>
    112.                 <input type="text" name="name">
    113.             </li>
    114.             <li>
    115.                 <!-- Available vocations to select from when creating character -->
    116.                 Vocation:<br>
    117.                 <select name="selected_vocation">
    118.                 <?php foreach ($config['available_vocations'] as $id) { ?>
    119.                 <option value="<?php echo $id; ?>"><?php echo vocation_id_to_name($id); ?></option>
    120.                 <?php } ?>
    121.                 </select>
    122.             </li>
    123.             <li>
    124.                 <!-- Available genders to select from when creating character -->
    125.                 Gender:<br>
    126.                 <select name="selected_gender">
    127.                 <option value="1">Male</option>
    128.                 <option value="0">Female</option>
    129.                 </select>
    130.             </li>
    131.             <li>
    132.                 <!-- Available towns to select from when creating character -->
    133.                 Town:<br>
    134.                 <select name="selected_town">
    135.                 <?php foreach ($config['available_towns'] as $tid) { ?>
    136.                 <option value="<?php echo $tid; ?>"><?php echo town_id_to_name($tid); ?></option>
    137.                 <?php } ?>
    138.                 </select>
    139.             </li>
    140.             <?php
    141.                 /* Form file */
    142.                 Token::create();
    143.             ?>
    144.             <li>
    145.                 <input type="submit" value="Create Character">
    146.             </li>
    147.         </ul>
    148.     </form>
    149.     <?php
    150. }
    151. include 'layout/overall/footer.php'; ?>
     
    Last edited: Feb 2, 2015
  2. Best Answer:
    Post #10 by Znote, Feb 2, 2015
  3. Breed

    Breed Active Member

    Joined:
    Jan 7, 2015
    Messages:
    517
    Likes Received:
    122
    Best Answers:
    0
    The information for the vocations is not in this file, it is in config.php starting on line 257
    PHP:
    1.  
    2. $config['vocations'] = array(
    3.         0 => 'No vocation',
    4.         1 => 'Sorcerer',
    5.         2 => 'Druid',
    6.         3 => 'Paladin',
    7.         4 => 'Knight',
    8.         5 => 'Master Sorcerer',
    9.         6 => 'Elder Druid',
    10.         7 => 'Royal Paladin',
    11.         8 => 'Elite Knight',
    12.     );
    13.  
    Just comment out 0 => 'No vocation', like i did below
    PHP:
    1.  
    2. $config['vocations'] = array(
    3.         //0 => 'No vocation',
    4.         1 => 'Sorcerer',
    5.         2 => 'Druid',
    6.         3 => 'Paladin',
    7.         4 => 'Knight',
    8.         5 => 'Master Sorcerer',
    9.         6 => 'Elder Druid',
    10.         7 => 'Royal Paladin',
    11.         8 => 'Elite Knight',
    12.     );
    13.  
     
    artofwork likes this.
  4. Zaggyzigzig

    Zaggyzigzig plx itens menz

    Joined:
    Aug 25, 2014
    Messages:
    389
    Likes Received:
    50
    Best Answers:
    0
    Ah thanks will give it a shot, Sorry about that last post falling asleep!
     
  5. Breed

    Breed Active Member

    Joined:
    Jan 7, 2015
    Messages:
    517
    Likes Received:
    122
    Best Answers:
    0
    I just gave you the solution.. you can't be that stupid.. if the people in need of support are our future then the whole world is doomed..
     
    poopsiedoodle likes this.
  6. Zaggyzigzig

    Zaggyzigzig plx itens menz

    Joined:
    Aug 25, 2014
    Messages:
    389
    Likes Received:
    50
    Best Answers:
    0

    What about the starting Location? Where could I find that =p?
     
  7. poopsiedoodle

    poopsiedoodle Gibe moni plos

    Joined:
    Nov 23, 2011
    Messages:
    2,398
    Likes Received:
    522
    Best Answers:
    0
    You change the starting position in config.lua, not in the aac (unless that's just for the IG account manager.)
     
  8. dominique120

    dominique120 Science & Reason Premium User

    Joined:
    Jun 16, 2013
    Messages:
    3,891
    Likes Received:
    1,020
    Best Answers:
    2
    I'm locking this thread till a moderator decides what to do with it.
     
    Zaggyzigzig likes this.
  9. Limos

    Limos Premium User

    Joined:
    Jun 7, 2010
    Messages:
    10,017
    Likes Received:
    2,954
    Best Answers:
    7
    Reopened, keep the posts about OT related problems and possible solutions for that.
     
    Zaggyzigzig likes this.
  10. Breed

    Breed Active Member

    Joined:
    Jan 7, 2015
    Messages:
    517
    Likes Received:
    122
    Best Answers:
    0
  11. Znote

    Znote <?php echo $title; ?> Staff Member Global Moderator Premium User

    Joined:
    Feb 14, 2008
    Messages:
    6,362
    Likes Received:
    1,058
    Best Answers:
    148
    Best Answer
    In Znote AAC, configure towns with correct ID according to your map editor. When people create a character for the town etc Thais, they will spawn in thais temple.
    You can see the position in Remere Map Editor by using the hotkey CTRL + T. If your map have no towns/temples configured, create some, and make sure Znote AAC config.php matches correctly.

    You can also create a starting position which is different than a town id, like rookgard on original tibia. (You don't start in rook temple but in tutorial isle). (At least before you did).

    Starting position:
    ZnoteAAC/config.php at 7649d9b731b585ce5655474e1ceddb16dde7d52d · Znote/ZnoteAAC · GitHub

    Configured towns:
    ZnoteAAC/config.php at 7649d9b731b585ce5655474e1ceddb16dde7d52d · Znote/ZnoteAAC · GitHub
     
    Last edited: Apr 6, 2017
    Kulavy, Limos and Zaggyzigzig like this.
  12. Koon

    Koon New Member

    Joined:
    May 7, 2016
    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Is it possible to make different starting position for each vocation? I mean building with rooms, each new character spawn in other room, depending on vocation.
    @Znote
     
  13. Znote

    Znote <?php echo $title; ?> Staff Member Global Moderator Premium User

    Joined:
    Feb 14, 2008
    Messages:
    6,362
    Likes Received:
    1,058
    Best Answers:
    148
    Yep.

    users.php line 1298:
    ZnoteAAC - engine/function/users.php#L1298

    Add this code:
    Code (PHP):
    1. switch ($vocation) {
    2.     case 1: // Sorcerer
    3.         $import_data['town_id'] = 3;
    4.         $import_data['posx'] = 100;
    5.         $import_data['posy'] = 200;
    6.         $import_data['posz'] = 7;
    7.     break;
    8.     case 2: // Druid
    9.         $import_data['town_id'] = 3;
    10.         $import_data['posx'] = 100;
    11.         $import_data['posy'] = 200;
    12.         $import_data['posz'] = 7;
    13.     break;
    14.     case 3: // Paladin
    15.         $import_data['town_id'] = 3;
    16.         $import_data['posx'] = 100;
    17.         $import_data['posy'] = 200;
    18.         $import_data['posz'] = 7;
    19.     break;
    20.     case 4: // Knight
    21.         $import_data['town_id'] = 3;
    22.         $import_data['posx'] = 100;
    23.         $import_data['posy'] = 200;
    24.         $import_data['posz'] = 7;
    25.     break;
    26. }
    Change positions, vocation IDs accordingly to your OTs.

    New characters should then spawn at this location. If not then check data/creaturescripts/scripts/login.php, as they might have some "first login - teleport to temple" code that you need to remove.
     

Share This Page

Loading...