Znote / ZnoteAAC

Developement repository for the Znote AAC project. A website portal to represent and manage your Open Tibia server.
MIT License
145 stars 127 forks source link

Character Position (characterprofile.php + config.php) #387

Open deviljin112 opened 4 years ago

deviljin112 commented 4 years ago

Characterprofile.php

<!-- Player Position -->
<?php if ($profile_data['group_id'] > 1): ?>
    <tr>
        <td>Position</td>
        <td><?php echo group_id_to_name($profile_data['group_id']); ?></td>
    </tr>
<?php endif; ?>

Prints out the character's position based on characters group_id in DB. Character is "GOD" in-game but profile states "Senior Tutor" because of comparison to config.php

    $config['ingame_positions'] = array(
        1 => 'Player',
        2 => 'Tutor',
        3 => 'Senior Tutor',
        4 => 'Gamemaster',
        5 => 'Community Manager',
        6 => 'God',
    );

Because TFS only has 3 rankings for in-game position (groups.xml) at least mine does, I cant actually set it to 6 to have it match the config.php.

TLDR; Account position's (account db => type) matches exactly to config.php but character db => group_id does not.

Znote commented 4 years ago

The problem here is that this system differs between TFS 0.2, TFS 0.3/4 and TFS 1.x. If we correct it for one version, it easily breaks for another.

You can read more about it in #70

We might need to setup the config differently based on TFS version.

deviljin112 commented 4 years ago

Temporary Solution

config.php line 726 add:

$config['TFS10_ingame_positions'] = array(
    1 => 'Player',
    2 => 'Gamemaster',
    3 => 'God',
);

general.php line 346 add:

function group_id_to_name_TFS10($id) {
    $positions = config('TFS10_ingame_positions');
    return ($positions[$id] >= 0) ? $positions[$id] : false;
}

characterprofile.php replace line 84 to line 90:

<!-- Player Position -->
<?php if ($profile_data['group_id'] > 1): ?>
        <?php if ($config['ServerEngine'] == 'TFS_10'): ?>
            <tr>
                <td>Position</td>
                <td><?php echo group_id_to_name_TFS10($profile_data['group_id']); ?></td>
            </tr>
        <?php else: ?>
            <tr>
                <td>Position</td>
                <td><?php echo group_id_to_name($profile_data['group_id']); ?></td>
            </tr>
        <?php endif; ?>
<?php endif; ?>

This may not be an ideal solution but it solves the above issue perfectly without affecting non TFS 1.x

EDIT: Only works with 1 character. I've read the post you sent above, and realised this would not be viable for multiple characters on one account with different ranks.