• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

AAC Newly created players have -120 mana on database AND do not save

Jaki Maoh

Member
Joined
Sep 13, 2017
Messages
55
Reaction score
13
Hello community!

I do not know, for the life of me what I did that broke my znoteAAC (or phpMyAdmin):
when creating (and only when creating) a new character it is entered in the server database with negative -120 mana points and -120 max mana:
1.webp
In-game the player has tons of mana and mana max:
2.webp
Because of this, when he logs out, the server cannot save its status and he gets rolled back to the moment of it's creation, losing all progress.
Here's the error:
LUA:
Testa has logged out.
[Error - mysql_real_query] Query: UPDATE `players` SET `level` = 1,`group_id` = 1,`vocation` = 1,`health` = 150,`healthmax` = 150,`experience` = 0,`lookbody` = 20,`lookfeet` = 115,`lookhead` = 96,`looklegs` = 98,`looktype` = 128,`lookaddons` = 0,`maglevel` = 0,`mana` = 4294967176,`manamax`
Message: Out of range value for column 'mana' at row 1
[Error - mysql_real_query] Query: UPDATE `players` SET `level` = 1,`group_id` = 1,`vocation` = 1,`health` = 150,`healthmax` = 150,`experience` = 0,`lookbody` = 20,`lookfeet` = 115,`lookhead` = 96,`looklegs` = 98,`looktype` = 128,`lookaddons` = 0,`maglevel` = 0,`mana` = 4294967176,`manamax`
Message: Out of range value for column 'mana' at row 1
[Error - mysql_real_query] Query: UPDATE `players` SET `level` = 1,`group_id` = 1,`vocation` = 1,`health` = 150,`healthmax` = 150,`experience` = 0,`lookbody` = 20,`lookfeet` = 115,`lookhead` = 96,`looklegs` = 98,`looktype` = 128,`lookaddons` = 0,`maglevel` = 0,`mana` = 4294967176,`manamax`
Message: Out of range value for column 'mana' at row 1
Error while saving player: Testa

Anyone knows how this could happen?
*** the server never had this kind of behaviour before - always created characters without problems and their progress was always normal.
Thanks in Advance!
 
Solution
Yes but, but you must have changed $config['player']['create']['level'] to 1 recently. Looking at your failed queries, it shows vocation = 1. The default value for $config['vocations_gain'][1]['mp'] is 30 (on my copy at least). If you manually compute the mana, you'll have:
Code:
FINALMANA = BASEMANA + GAINMP * (CREATELEVEL - BASELEVEL)
          = 90       + 30     * (1           - 8        )
          = 90       - 30     * 7
          = 90       - 210
          = -120

Which matches the value on your screenshot. You could solve this by using $mana = max($mana, 0) or by adjusting the base level, base health, base mana, etc... The whole problem is that CREATELEVEL is less than BASELEVEL and it...
So you said you're using ZnoteAAC. I was taking a look how it inserts player data and found this:
PHP:
    $cnf = fullConfig();

    $vocation = (int)$character_data['vocation'];
    $playercnf = $cnf['player'];
    $base = $playercnf['base'];
    $create = $playercnf['create'];
    $skills = $create['skills'][$vocation];

    $outfit = ($character_data['sex'] == 1) ? $create['male_outfit'] : $create['female_outfit'];

    $leveldiff = $create['level'] - $base['level'];

    $gains = $cnf['vocations_gain'][$vocation];

    $health    = $base['health'] + ( $gains['hp']  * $leveldiff );
    $mana    = $base['mana']   + ( $gains['mp']  * $leveldiff );
    $cap    = $base['cap']    + ( $gains['cap'] * $leveldiff );

Since the mana is negative and the character level is 1, I'd assume there is something wrong with $base['mana'], $gains['mp'], or $leveldiff, but since the health seems to be correct, I'd assume is one of the others.

It looks like they're defined in config.php under $config['vocations_gain'] and $config['player']. If for whatever reason you increased the mana gain of whatever vocation that is, it's probable that you'll need to increase the base mana to compensate, if it's starting at level 1.
 
So you said you're using ZnoteAAC. I was taking a look how it inserts player data and found this:
PHP:
    $cnf = fullConfig();

    $vocation = (int)$character_data['vocation'];
    $playercnf = $cnf['player'];
    $base = $playercnf['base'];
    $create = $playercnf['create'];
    $skills = $create['skills'][$vocation];

    $outfit = ($character_data['sex'] == 1) ? $create['male_outfit'] : $create['female_outfit'];

    $leveldiff = $create['level'] - $base['level'];

    $gains = $cnf['vocations_gain'][$vocation];

    $health    = $base['health'] + ( $gains['hp']  * $leveldiff );
    $mana    = $base['mana']   + ( $gains['mp']  * $leveldiff );
    $cap    = $base['cap']    + ( $gains['cap'] * $leveldiff );

Since the mana is negative and the character level is 1, I'd assume there is something wrong with $base['mana'], $gains['mp'], or $leveldiff, but since the health seems to be correct, I'd assume is one of the others.

It looks like they're defined in config.php under $config['vocations_gain'] and $config['player']. If for whatever reason you increased the mana gain of whatever vocation that is, it's probable that you'll need to increase the base mana to compensate, if it's starting at level 1.
Yes, the problem could be solved if I tamper with the initial mana in the file (already tested it):
PHP:
    // ---------------- \\
    // Create Character \\
    // ---------------- \\

    // Max characters on each account:
    $config['max_characters'] = 7;

    // Available character vocation users can choose (specify vocation ID).
    $config['available_vocations'] = array(1, 2, 3, 4);

    // Available towns (specify town ids, etc: (1, 2, 3); to display 3 town options (town id 1, 2 and 3).
    // Town IDs are the ones from $config['towns'] array
    $config['available_towns'] = array(1, 2, 3, 4);

    $config['player'] = array(
        'base' => array(
            'level' => 8,
            'health' => 185,
            'mana' => 90,
            'cap' => 470,
            'soul' => 100
        ),
        // Health, mana cap etc are calculated with $config['vocations_gain'] and 'base' values of $config['player']
        'create' => array(
            'level' => 1,
            'novocation' => array( // Vocation id 0 (No vocation) special settings
                'level' => 1,
                'forceTown' => true,
                'townId' => 1
            ),
            'skills' => array( // See $config['vocations'] for proper vocation names of these IDs
                // No vocation
                0 => array(
                    'magic' => 0,
                    'fist' => 10,
                    'club' => 10,
                    'axe' => 10,
                    'sword' => 10,
                    'dist' => 10,
                    'shield' => 10,
                    'fishing' => 10,
                ),
                // Sorcerer
                1 => array(
                    'magic' => 0,
                    'fist' => 10,
                    'club' => 10,
                    'axe' => 10,
                    'sword' => 10,
                    'dist' => 10,
                    'shield' => 10,
                    'fishing' => 10,
                ),
                // Druid
                2 => array(
                    'magic' => 0,
                    'fist' => 10,
                    'club' => 10,
                    'axe' => 10,
                    'sword' => 10,
                    'dist' => 10,
                    'shield' => 10,
                    'fishing' => 10,
                ),
                // Paladin
                3 => array(
                    'magic' => 0,
                    'fist' => 10,
                    'club' => 10,
                    'axe' => 10,
                    'sword' => 10,
                    'dist' => 10,
                    'shield' => 10,
                    'fishing' => 10,
                ),
                // Knight
                4 => array(
                    'magic' => 0,
                    'fist' => 10,
                    'club' => 10,
                    'axe' => 10,
                    'sword' => 10,
                    'dist' => 10,
                    'shield' => 10,
                    'fishing' => 10,
                ),
            ),
            'male_outfit' => array(
                'id' => 128,
                'head' => 78,
                'body' => 68,
                'legs' => 58,
                'feet' => 76
            ),
            'female_outfit' => array(
                'id' => 136,
                'head' => 78,
                'body' => 68,
                'legs' => 58,
                'feet' => 76
            )
        )
    );

    // Minimum allowed letters in character name. Ex: 4 letters: "Kare".
    $config['minL'] = 3;
    // Maximum allowed letters in character name. Ex: 20 letters: "Bobkareolesofiesberg"
    $config['maxL'] = 20;
    // Maximum allowed words in character name. Ex: 2 words = "Bob Kare", 3 words: "Bob Arne Kare" as maximum char name words.
    $config['maxW'] = 3;

    // -------------- \\
    // WEBSITE STUFF  \\
    // -------------- \\
The problem is I did only alter the config.php for cities and looktype colors a long time ago. Did not alter it recently at all, and the problem started a couple of days ago.
 
Yes but, but you must have changed $config['player']['create']['level'] to 1 recently. Looking at your failed queries, it shows vocation = 1. The default value for $config['vocations_gain'][1]['mp'] is 30 (on my copy at least). If you manually compute the mana, you'll have:
Code:
FINALMANA = BASEMANA + GAINMP * (CREATELEVEL - BASELEVEL)
          = 90       + 30     * (1           - 8        )
          = 90       - 30     * 7
          = 90       - 210
          = -120

Which matches the value on your screenshot. You could solve this by using $mana = max($mana, 0) or by adjusting the base level, base health, base mana, etc... The whole problem is that CREATELEVEL is less than BASELEVEL and it tries to extrapolate the mana formula backwards, but the domain is for level 8 forwards.
 
Solution
Back
Top