• 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!

Znote - Create Character No Rook

Zaggyzigzig

plx itens menz
Joined
Aug 25, 2014
Messages
386
Reaction score
50
Location
Canada Ontario
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:
<?php require_once 'engine/init.php';
protect_page();
include 'layout/overall/header.php';

if (empty($_POST) === false) {
    // $_POST['']
    $required_fields = array('name', 'selected_town');
    foreach($_POST as $key=>$value) {
        if (empty($value) && in_array($key, $required_fields) === true) {
            $errors[] = 'You need to fill in all fields.';
            break 1;
        }
    }

    // check errors (= user exist, pass long enough
    if (empty($errors) === true) {
        if (!Token::isValid($_POST['token'])) {
            $errors[] = 'Token is invalid.';
        }
        $_POST['name'] = validate_name($_POST['name']);
        if ($_POST['name'] === false) {
            $errors[] = 'Your name can not contain more than 2 words.';
        } else {
            if (user_character_exist($_POST['name']) === true) {
                $errors[] = 'Sorry, that character name already exist.';
            }
            if (!preg_match("/^[a-zA-Z_ ]+$/", $_POST['name'])) {
                $errors[] = 'Your name may only contain a-z, A-Z and spaces.';
            }
            if (strlen($_POST['name']) < $config['minL'] || strlen($_POST['name']) > $config['maxL']) {
                $errors[] = 'Your character name must be between 4 - 20 characters long.';
            }
            // name restriction
            $resname = explode(" ", $_POST['name']);
            foreach($resname as $res) {
                if(in_array(strtolower($res), $config['invalidNameTags'])) {
                    $errors[] = 'Your name contains a restricted word.';
                }
                else if(strlen($res) == 1) {
                    $errors[] = 'Too short words in your name.';
                }
            }
            // Validate vocation id
            if (!in_array((int)$_POST['selected_vocation'], $config['available_vocations'])) {
                $errors[] = 'Permission Denied. Wrong vocation.';
            }
            // Validate town id
            if (!in_array((int)$_POST['selected_town'], $config['available_towns'])) {
                $errors[] = 'Permission Denied. Wrong town.';
            }
            // Validate gender id
            if (!in_array((int)$_POST['selected_gender'], array(0, 1))) {
                $errors[] = 'Permission Denied. Wrong gender.';
            }
            if (vocation_id_to_name($_POST['selected_vocation']) === false) {
                $errors[] = 'Failed to recognize that vocation, does it exist?';
            }
            if (town_id_to_name($_POST['selected_town']) === false) {
                $errors[] = 'Failed to recognize that town, does it exist?';
            }
            if (gender_exist($_POST['selected_gender']) === false) {
                $errors[] = 'Failed to recognize that gender, does it exist?';
            }
            // Char count
            $char_count = user_character_list_count($session_user_id);
            if ($char_count >= $config['max_characters']) {
                $errors[] = 'Your account is not allowed to have more than '. $config['max_characters'] .' characters.';
            }
            if (validate_ip(getIP()) === false && $config['validate_IP'] === true) {
                $errors[] = 'Failed to recognize your IP address. (Not a valid IPv4 address).';
            }
        }
    }
}
?>

<h1>Create Character</h1>
<?php
if (isset($_GET['success']) && empty($_GET['success'])) {
    echo 'Congratulations!<br>Your character has been created!';
} else {
    if (empty($_POST) === false && empty($errors) === true) {
        if ($config['log_ip']) {
            znote_visitor_insert_detailed_data(2);
        }
        //Register
        $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()
        );

        user_create_character($character_data);
        header('Location: createcharacter.php?success');
        exit();
        //End register

    } else if (empty($errors) === false){
        echo '<font color="red"><b>';
        echo output_errors($errors);
        echo '</b></font>';
    }
    ?>
    <form action="" method="post">
        <ul>
            <li>
                Name:<br>
                <input type="text" name="name">
            </li>
            <li>
                <!-- Available vocations to select from when creating character -->
                Vocation:<br>
                <select name="selected_vocation">
                <?php foreach ($config['available_vocations'] as $id) { ?>
                <option value="<?php echo $id; ?>"><?php echo vocation_id_to_name($id); ?></option>
                <?php } ?>
                </select>
            </li>
            <li>
                <!-- Available genders to select from when creating character -->
                Gender:<br>
                <select name="selected_gender">
                <option value="1">Male</option>
                <option value="0">Female</option>
                </select>
            </li>
            <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
                /* Form file */
                Token::create();
            ?>
            <li>
                <input type="submit" value="Create Character">
            </li>
        </ul>
    </form>
    <?php
}
include 'layout/overall/footer.php'; ?>
 
Last edited:
Solution
What about the starting Location? Where could I find that =p?

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...
The information for the vocations is not in this file, it is in config.php starting on line 257
PHP:
$config['vocations'] = array(
        0 => 'No vocation',
        1 => 'Sorcerer',
        2 => 'Druid',
        3 => 'Paladin',
        4 => 'Knight',
        5 => 'Master Sorcerer',
        6 => 'Elder Druid',
        7 => 'Royal Paladin',
        8 => 'Elite Knight',
    );
Just comment out 0 => 'No vocation', like i did below
PHP:
$config['vocations'] = array(
        //0 => 'No vocation',
        1 => 'Sorcerer',
        2 => 'Druid',
        3 => 'Paladin',
        4 => 'Knight',
        5 => 'Master Sorcerer',
        6 => 'Elder Druid',
        7 => 'Royal Paladin',
        8 => 'Elite Knight',
    );
 
The information for the vocations is not in this file, it is in config.php starting on line 257
PHP:
$config['vocations'] = array(
        0 => 'No vocation',
        1 => 'Sorcerer',
        2 => 'Druid',
        3 => 'Paladin',
        4 => 'Knight',
        5 => 'Master Sorcerer',
        6 => 'Elder Druid',
        7 => 'Royal Paladin',
        8 => 'Elite Knight',
    );
Just comment out 0 => 'No vocation', like i did below
PHP:
$config['vocations'] = array(
        //0 => 'No vocation',
        1 => 'Sorcerer',
        2 => 'Druid',
        3 => 'Paladin',
        4 => 'Knight',
        5 => 'Master Sorcerer',
        6 => 'Elder Druid',
        7 => 'Royal Paladin',
        8 => 'Elite Knight',
    );


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

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:
Solution
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

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
 
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

Yep.

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

Add this code:
PHP:
switch ($vocation) {
    case 1: // Sorcerer
        $import_data['town_id'] = 3;
        $import_data['posx'] = 100;
        $import_data['posy'] = 200;
        $import_data['posz'] = 7;
    break;
    case 2: // Druid
        $import_data['town_id'] = 3;
        $import_data['posx'] = 100;
        $import_data['posy'] = 200;
        $import_data['posz'] = 7;
    break;
    case 3: // Paladin
        $import_data['town_id'] = 3;
        $import_data['posx'] = 100;
        $import_data['posy'] = 200;
        $import_data['posz'] = 7;
    break;
    case 4: // Knight
        $import_data['town_id'] = 3;
        $import_data['posx'] = 100;
        $import_data['posy'] = 200;
        $import_data['posz'] = 7;
    break;
}

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.
 
Back
Top