• 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 SQL error player_storage in characterprofile

Methemia

Member
Joined
Feb 1, 2015
Messages
60
Reaction score
9
Code:
string(101) "SELECT SUM(`value`) AS `sum` FROM `player_storage` WHERE `key` LIKE '30___' AND `player_id`=(int)2721"
(query - SQL error)
Type: select_single (select single row from database)

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'int)2721' at line 1[/code}}]

archive: characterprofile.php
Tfs 1.3 znote acc

can you help me?
 
Solution
Change this line:
Code:
$achievementPoints = mysql_select_single("SELECT SUM(`value`) AS `sum` FROM `player_storage` WHERE `key` LIKE '30___' AND `player_id`=(int)$user_id");
To:
Code:
$user_id = (int) $user_id;
$achievementPoints = mysql_select_single("SELECT SUM(`value`) AS `sum` FROM `player_storage` WHERE `key` LIKE '30___' AND `player_id`=$user_id");
Change this line:
Code:
$achievementPoints = mysql_select_single("SELECT SUM(`value`) AS `sum` FROM `player_storage` WHERE `key` LIKE '30___' AND `player_id`=(int)$user_id");
To:
Code:
$user_id = (int) $user_id;
$achievementPoints = mysql_select_single("SELECT SUM(`value`) AS `sum` FROM `player_storage` WHERE `key` LIKE '30___' AND `player_id`=$user_id");
 
Solution
Sorry for revive this thread @slaw, @Znote
I have the same issue, I've configured it this way:

achievement.png


I use default TFS achievement lib (from main repository)
My config.php

PHP:
    // Achievements based on "https://github.com/otland/forgottenserver/blob/master/data/lib/core/achievements.lua" (TFS 1.x)
    $config['Ach'] = true;
    $config['achievements'] = array(
        35053 => array(
            'Marblelous', // name
            'You\'re an aspiring marble sculptor with promising skills - proven by the perfect little Tibiasula statue you shaped. One day you\'ll be really famous!', // description
            'points' => '3', // points
        ),
        35052 => array(
            'Marble Madness',
            'Your little statues of Tibiasula have become quite famous around Tibia and there\'s few people with similar skills when it comes to shaping marble.', // description
            'points' => '6',
            'secret' => true
        ),
        30152 => array(
            'Santa\'s Li\'l Helper',
            'Christmas is your favourite time of the year, and boy, do you love presents. Buy some nice things for your friends, hide them away until - well, until you decide to actually unwrap them rather yourself.',
            'points' => '2', // 1-3 points (1 star), 4-6 points (2 stars), 7-9 points(3 stars), 10 points => (4 stars)
            'secret' => true // show "secret" badge
        ),
    );

Achievement on characterprofile.php

PHP:
        <!-- Achievements start -->
        <?php if ($config['Ach']):
            $achievements = mysql_select_multi("
                SELECT `player_id`, `value`, `key`
                FROM `player_storage`
                WHERE `player_id`='$user_id'
                AND `key` LIKE '30___';
            ");
            $c_achs = $config['achievements'];
            $toggle = array(
                'show' => '<a href="#show">Show</a>',
                'hide' => '<a href="#hide">Hide</a>'
            );
            if ($achievements !== false): ?>
                <h3>Achievements: <label id="ac_label_hide" for="ac_toggle_hide"><?php echo $toggle['show']; ?></label></h3>
                <!-- <div id="accordion">
                    <h3>Show/hide player achievements</h3>
                    <div>

                    </div>
                </div><br> -->
                <input type="checkbox" id="ac_toggle_hide" name="ac_toggle_hide">
                <table class="achievements">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Description</th>
                            <th>Points</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach($achievements as $a): ?>
                            <tr>
                                <td><?php echo $c_achs[$a['key']][0]; ?></td>
                                <td><?php echo $c_achs[$a['key']][1]; ?></td>
                                <td><?php echo $a['value']; ?></td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
                <style type="text/css">
                    table.achievements,
                    #ac_toggle_hide {
                        display: none;
                    }
                    #ac_toggle_hide:checked + table.achievements {
                        display: table;
                    }
                </style>
                <script type="text/javascript">
                    document.getElementById("ac_label_hide").addEventListener("click", function(event){
                        event.preventDefault();
                        if (document.getElementById("ac_label_hide").innerHTML == "<?php echo str_replace('"', '\"', $toggle['show']); ?>") {
                            document.getElementById("ac_label_hide").innerHTML = "<?php echo str_replace('"', '\"', $toggle['hide']); ?>";
                            document.getElementById("ac_toggle_hide").checked = true;
                        } else {
                            document.getElementById("ac_label_hide").innerHTML = "<?php echo str_replace('"', '\"', $toggle['show']); ?>";
                            document.getElementById("ac_toggle_hide").checked = false;
                        }
                    });
                </script>
            <?php endif; ?>
        <?php endif; ?>

PHP:
            if ($config['Ach']) {
                $user_id = (int) $user_id;
                $achievementPoints = mysql_select_single("SELECT SUM(`value`) AS `sum` FROM `player_storage` WHERE `key` LIKE '30___' AND `player_id`={$user_id} LIMIT 1");
            }

I also have the doubt of where is PlayerStorageKeys.achievementsBase stored? To confirm if I should use 30XXX storage for the achievements.
 
Last edited:
Back
Top