• 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 MyAAC 1.8.8 - quest with multiple storageValues

Gover

Well-Known Member
Joined
Sep 3, 2009
Messages
129
Reaction score
67
Hello,
Maybe someone know if it's possible in MyAAC to set a quest with multiple storageValues?
In "Settings" -> "Pages" -> "Characters Page" I can add new quests, but did not find a way to add few storage values for one quest.
Tried with comma, semicolon - nothing works. Maybe there is some trick to achieve this?
Paradox Tower Quest=1,2,3,4
Ornamented Shield Quest=5,6

Thanks in advance for help :)
Regards,
Gover
 
Hi,

No, it's with current implementation not possible.

Can't you just add the latest storage? I mean one that is added at the latest (probably this that adds the items to player from the box?

If not, then maybe I can think of something.
 
I did below to walkaround that. Any advice if it's a good way? maybe you would do in different way?

system/settings.php
PHP:
        'quests' => [
            'name' => 'Quests List',
            'type' => 'textarea',
            'desc' => 'Character Quests List. Format: NameOfQuest=StorageValue or NameOfQuest=StorageValue1,StorageValue2,StorageValue3',
            'default' => "Some Quest=123\nSome Quest Two=456\nMulti Reward Quest=789,790,791",
            'show_if' => [
                'characters_quests', '=', 'true'
            ],
            'callbacks' => [
                'get' => function ($value) {
                    $ret = [];
                    $quests = array_map('trim', preg_split('/\r\n|\r|\n/', trim($value)));

                    foreach ($quests as $quest) {
                        if (empty($quest)) {
                            continue;
                        }

                        $explode = explode('=', $quest);
                        // Support multiple storage values separated by commas
                        $storageValues = array_map('trim', explode(',', $explode[1]));
                        // If only one value, store as string for backward compatibility
                        // If multiple values, store as array
                        $ret[$explode[0]] = count($storageValues) === 1 ? $storageValues[0] : $storageValues;
                    }

                    return $ret;
                },
            ],
        ],

system/pages/characters.php
PHP:
    $quests_enabled = $config['characters']['quests'] && !empty($config['quests']);
    if($quests_enabled) {
        $quests = $config['quests'];
        $sql_query_in = '';
        $i = 0;
        $storage_ids = []; // Collect all storage IDs
        
        foreach($quests as $quest_name => $quest_storage)
        {
            // Handle both single value and array of values
            if(is_array($quest_storage)) {
                foreach($quest_storage as $storage_id) {
                    $storage_ids[] = $storage_id;
                }
            } else {
                $storage_ids[] = $quest_storage;
            }
        }
        
        // Build SQL IN clause
        foreach($storage_ids as $storage_id) {
            if($i != 0)
                $sql_query_in .= ', ';
            $sql_query_in .= $storage_id;
            $i++;
        }

        $storage_sql = $db->query('SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = '.$player->getId().' AND `key` IN (' . $sql_query_in . ')');
        $player_storage = array();
        foreach($storage_sql as $storage)
            $player_storage[$storage['key']] = $storage['value'];

        // Check quest completion status
        foreach($quests as $quest_name => &$quest_storage) {
            if(is_array($quest_storage)) {
                // For multiple storage values, check if ALL of them are completed
                $completed = true;
                foreach($quest_storage as $storage_id) {
                    if(!isset($player_storage[$storage_id]) || $player_storage[$storage_id] <= 0) {
                        $completed = false;
                        break;
                    }
                }
                $quest_storage = $completed;
            } else {
                // Single storage value
                $quest_storage = isset($player_storage[$quest_storage]) && $player_storage[$quest_storage] > 0;
            }
        }
        unset($quest_storage);
    }
Thanks in advance for help.

Regards,
Gover
 
Back
Top