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

AAC Znote acc script

qruczu

New Member
Joined
Jan 8, 2012
Messages
104
Reaction score
0
Hello, can anyone give me a hint on how to make a character in a character creation page if one of our characters we already have has storage x = 1 ?


Something like that:
HEROłu.png
 
Last edited:
Solution
This script only adds the player to the account asocciated with. The only parameters that receives are session_id (account_id) and some default configs such as towns and etc. So, first you need to generate a sql statement that returns the storage of the current players of the account, if its 1 then return a value of ... 1. So, when you're creating this character, this page will receive thevariable through parameter and you can add it as a validation in the form
if you can, I will be grateful
PHP:
<?php require_once 'engine/init.php';
protect_page();
include 'layout/overall/header.php';
?>

<div id="myaccount">
<?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']) !== false) {
                $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 ' . $config['minL'] . ' - ' . $config['maxL'] . ' characters long.';
            }
            // name restriction
            $resname = explode(" ", $_POST['name']);
            foreach($resname as $res) {
                if(in_array(strtolower($res), $config['invalidNameTags'])) {
                    $errors[] = 'Your username 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! Your character has been created. See you in-game!';
} 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'    =>    getIPLong(),
            '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(boy)</option>
                <option value="0">Female(girl)</option>
                </select>
            </li>
            <?php
            $available_towns = $config['available_towns'];
            if (count($available_towns) > 1):
                ?>
                <li>
                    <!-- Available towns to select from when creating character -->
                    Town:<br>
                    <select name="selected_town">
                        <?php
                        foreach ($available_towns as $tid):
                            ?>
                            <option value="<?php echo $tid; ?>"><?php echo town_id_to_name($tid); ?></option>
                            <?php
                        endforeach;
                        ?>
                    </select>
                </li>
                <?php
            else:
                ?>
                <input type="hidden" name="selected_town" value="<?php echo end($available_towns); ?>">
                <?php
            endif;

            /* Form file */
            Token::create();
            ?>
            <li>
                <input type="submit" value="Create Character">
            </li>
        </ul>
    </form>
    
    <?php
}   
    echo '<h1>Create Hero</h1>';
    
if (isset($_GET['success']) && empty($_GET['success'])) {
    echo 'Congratulations! Your character has been created. See you in-game!';
} 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'    =>    getIPLong(),
            '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>
                Character Quest Done:<br>
                <select name="selected_character">
                <?php foreach ($char_array as $value) {
                    // characters: [0] = name, [1] = level, [2] = vocation, [3] = town_id, [4] = lastlogin, [5] = online
                    echo '<tr>';
                    echo '<td><a href="characterprofile.php?name='. $value['name'] .'">'. $value['name'] .'</a></td><td>'. $value['level'] .'</td><td>'. $value['vocation'] .'</td><td>'. $value['town_id'] .'</td><td>'. $value['lastlogin'] .'</td><td>'. $value['online'] .'</td><td>'. hide_char_to_name(user_character_hide($value['name'])) .'</td>';
                    echo '</tr>';
                    $characters[] = $value['name'];
                
                ?>
                <option value="<?php echo $id; ?>"><?php echo vocation_id_to_name($id); ?></option>
                <?php } ?>
                </select>
            </li>
            
            
            <li>
                <!-- Available vocations to select from when creating character -->
                Vocation:<br>
                <select name="selected_vocation">
                <?php foreach ($config['available_vocation'] 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(boy)</option>
                <option value="0">Female(girl)</option>
                </select>
            </li>
            <?php
            $available_towns = $config['available_towns'];
            if (count($available_towns) > 1):
                ?>
                <li>
                    <!-- Available towns to select from when creating character -->
                    Town:<br>
                    <select name="selected_town">
                        <?php
                        foreach ($available_towns as $tid):
                            ?>
                            <option value="<?php echo $tid; ?>"><?php echo town_id_to_name($tid); ?></option>
                            <?php
                        endforeach;
                        ?>
                    </select>
                </li>
                <?php
            else:
                ?>
                <input type="hidden" name="selected_town" value="<?php echo end($available_towns); ?>">
                <?php
            endif;

            /* Form file */
            Token::create();
            ?>
            <li>
                <input type="submit" value="Create Character">
            </li>
        </ul>
    </form>
    </div>

    <?php
}
include 'layout/overall/footer.php'; ?>
 
This script only adds the player to the account asocciated with. The only parameters that receives are session_id (account_id) and some default configs such as towns and etc. So, first you need to generate a sql statement that returns the storage of the current players of the account, if its 1 then return a value of ... 1. So, when you're creating this character, this page will receive thevariable through parameter and you can add it as a validation in the form
 
Solution
Back
Top