• 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 characterprofile.php

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,541
Solutions
28
Reaction score
875
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi again, i need some help with something (maybe very simple). There's some way to show character residence (town) on characterprofile.php?

Here is my characterprofile.php
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
if ($config['log_ip']) {
        znote_visitor_insert_detailed_data(4);
}
if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
        $name = $_GET['name'];
       
        if (user_character_exist($name)) {
                $user_id = user_character_id($name);
                if ($config['TFSVersion'] == 'TFS_10') {
                        $profile_data = user_character_data($user_id, 'name', 'level', 'vocation', 'lastlogin');
                        $profile_data['online'] = user_is_online_10($user_id);
                } else $profile_data = user_character_data($user_id, 'name', 'level', 'vocation', 'lastlogin', 'online');
                $profile_znote_data = user_znote_character_data($user_id, 'created', 'hide_char', 'comment');
               
                $guild_exist = false;
                if (get_character_guild_rank($user_id) > 0) {
                        $guild_exist = true;
                        $guild = get_player_guild_data($user_id);
                        $guild_name = get_guild_name($guild['guild_id']);
                }
                ?>
               
                <!-- PROFILE MARKUP HERE-->
                <h1>Character Profile:</h1>
                        <?php ?>
                        <table>
                        <tr class="yellow"><th><center>Name:</th><th><?php echo $profile_data['name']; ?></center></th></tr>
                        <tr><td>Level:</td><td><?php echo $profile_data['level']; ?></td></tr>
                        <tr><td>Vocation:</td><td><?php echo vocation_id_to_name($profile_data['vocation']); ?></td></tr>
                        <tr><td>Guild:</td><td><?php
                                if ($guild_exist) {
                                ?>
                                <?php echo $guild['rank_name']; ?> of <a href="guilds.php?name=<?php echo $guild_name; ?>"><?php echo $guild_name; ?></a>
                                <?php
                                }
                                else {
                                echo 'None';
                                }
                                ?></td><tr>
                        <tr><td>Last Login:</td><td><?php if ($profile_data['lastlogin'] != 0) { echo getClock($profile_data['lastlogin'], true, false); } else { echo 'Never.'; }?></td></tr>
                        <tr><td>Status:</td><td><?php
                                                if ($config['TFSVersion'] == 'TFS_10') {
                                                        if ($profile_data['online']) {
                                                                echo '<font class="profile_font" name="profile_font_online" color="green"><b>ONLINE</b></font>';
                                                        } else {
                                                                echo '<font class="profile_font" name="profile_font_online" color="red"><b>OFFLINE</b></font>';
                                                        }
                                                } else {
                                                        if ($profile_data['online'] == 1) {
                                                                echo '<font class="profile_font" name="profile_font_online" color="green"><b>ONLINE</b></font>';
                                                        } else {
                                                                echo '<font class="profile_font" name="profile_font_online" color="red"><b>OFFLINE</b></font>';
                                                        }
                                                }
                                        ?></li></td></tr>
                        <tr><td>Created:</td><td><?php echo getClock($profile_znote_data['created'], true); ?></td></tr>
                        </table>
                        <?php
/*/
/   Znote AAC 1.4+ detailed character info (HP, MP, lvL, Exp, skills)
/   HTML code based on code from Gesior
/*/
$tableWidth = 540;
if ($config['TFSVersion'] != 'TFS_10') {
    $playerData = mysql_select_multi("SELECT `value` FROM `player_skills` WHERE `player_id`='$user_id' LIMIT 7;");
    $playerData['fist'] = $playerData[0]['value']; unset($playerData[0]);
    $playerData['club'] = $playerData[1]['value']; unset($playerData[1]);
    $playerData['sword'] = $playerData[2]['value']; unset($playerData[2]);
    $playerData['axe'] = $playerData[3]['value']; unset($playerData[3]);
    $playerData['dist'] = $playerData[4]['value']; unset($playerData[4]);
    $playerData['shield'] = $playerData[5]['value']; unset($playerData[5]);
    $playerData['fish'] = $playerData[6]['value']; unset($playerData[6]);

    $player = mysql_select_single("SELECT `health`, `healthmax`, `mana`, `manamax`, `experience`, `maglevel`, `level` FROM `players` WHERE `id`='$user_id' LIMIT 1;");
    $playerData['magic'] = $player['maglevel'];
    $playerData['exp'] = array(
        'now' => $player['experience'],
        'next' => (int)(level_to_experience($player['level']+1) - $player['experience']),
        'percent' => (int)(($player['experience'] - level_to_experience($player['level'])) / (level_to_experience($player['level']+1) - $player['experience']) * 100)
    );
    $playerData['health'] = array(
        'now' => $player['health'],
        'max' => $player['healthmax'],
        'percent' => (int)($player['health'] / $player['healthmax'] * 100),
    );
    $playerData['mana'] = array(
        'now' => $player['mana'],
        'max' => $player['manamax'],
        'percent' => (int)($player['mana'] / $player['manamax'] * 100),
    );
} else {
    $player = mysql_select_single("SELECT `health`, `healthmax`, `mana`, `manamax`, `experience`, `skill_fist`, `skill_club`, `skill_sword`, `skill_axe`, `skill_dist`, `skill_shielding`, `skill_fishing`, `maglevel`, `level` FROM `players` WHERE `id`='$user_id' LIMIT 1;");
    $playerData = array(
        'fist' => $player['skill_fist'],
        'club' => $player['skill_club'],
        'sword' => $player['skill_sword'],
        'axe' => $player['skill_axe'],
        'dist' => $player['skill_dist'],
        'shield' => $player['skill_shielding'],
        'fish' => $player['skill_fishing'],
        'magic' => $player['maglevel'],
        'exp' => array(
            'now' => $player['experience'],
            'next' => (int)(level_to_experience($player['level']+1) - $player['experience']),
            'percent' => (int)(($player['experience'] - level_to_experience($player['level'])) / (level_to_experience($player['level']+1) - $player['experience']) * 100)
        ),
        'health' => array(
            'now' => $player['health'],
            'max' => $player['healthmax'],
            'percent' => (int)($player['health'] / $player['healthmax'] * 100),
        ),
        'mana' => array(
            'now' => $player['mana'],
            'max' => $player['manamax'],
            'percent' => (int)($player['mana'] / $player['manamax'] * 100),
        )
    );
}
// Incase they have more health/mana than they should due to equipment bonus etc
if ($playerData['exp']['percent'] > 100) $playerData['exp']['percent'] = 100;
if ($playerData['health']['percent'] > 100) $playerData['health']['percent'] = 100;
if ($playerData['mana']['percent'] > 100) $playerData['mana']['percent'] = 100;
//data_dump($playerData, false, "Player Data");
?>
<!-- PLAYER SKILLS TABLE -->
<center><table cellspacing="1" cellpadding="4" style="width: <?php echo $tableWidth; ?>px;">
    <tr class="yellow">
        <th>Fist</th>
        <th>Club</th>
        <th>Sword</th>
        <th>Axe</th>
        <th>Dist</th>
        <th>Shield</th>
        <th>Fish</th>
        <th>Magic</th>
    </tr>
    <tr>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['fist']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['club']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['sword']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['axe']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['dist']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['shield']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['fish']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['magic']; ?>
        </td>
    </tr>
</table></center>
<!-- PLAYER INFO TABLE -->
<center><table cellspacing="1" cellpadding="4" style="width: <?php echo $tableWidth; ?>px;">
    <tr>
        <td bgcolor="#F1E0C6" align="left" width="20%">
            <b>Player HP:</b>
        </td>
        <td bgcolor="#F1E0C6" align="left">
            <?php echo $playerData['health']['now'].'/'.$playerData['health']['max']; ?>
            <div style="width: 100%; height: 3px; border: 1px solid #000;">
                <div style="background: red; width: <?php echo $playerData['health']['percent']; ?>%; height: 3px;">
                </div>
            </div>
        </td>
    </tr>
    <tr>
        <td bgcolor="#D4C0A1" align="left">
            <b>Player MP:</b>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['mana']['now'].'/'.$playerData['mana']['max']; ?>
            <div style="width: 100%; height: 3px; border: 1px solid #000;">
                <div style="background: blue; width: <?php echo $playerData['mana']['percent']; ?>%; height: 3px;">
                </div>
            </div>
        </td>
    </tr>
    <tr>
        <td bgcolor="#D4C0A1" align="left">
            <b>Player XP:</b>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo number_format($playerData['exp']['now'], 0, "", " "); ?> Experience.
        </td>
    </tr>
    <tr>
        <td bgcolor="#F1E0C6" align="left">
            <b>To Next Lvl:</b>
        </td>
        <td bgcolor="#F1E0C6" align="left">
            Need <b><?php echo number_format($playerData['exp']['next'], 0, "", " "); ?> experience (<?php echo 100-$playerData['exp']['percent']; ?>%)</b> to Level <b><?php echo $player['level']+1; ?></b>.
            <div title="99.320604545 %" style="width: 100%; height: 3px; border: 1px solid #000;">
                <div style="background: red; width: <?php echo $playerData['exp']['percent']; ?>%; height: 3px;"></div>
            </div>
        </td>
    </tr>
</table></center>
<!-- END detailed character info -->
                                <table><tr class="yellow">
                                <th><center>Comment:</center>
                                </th>
                                </tr>
                                <tr><td><center><textarea name="profile_comment_textarea" cols="70" rows="10" readonly="readonly" class="span12"><?php echo $profile_znote_data['comment']; ?></textarea></center></td></tr></table>
                                <!-- DEATH LIST -->
                                <li>
                                        <h1>Death List:</h1><br>
                                        <table id="characterprofileTable" class="table table-striped table-hover">
                                                                <tr class="yellow">
                                                                        <th>
                                                                                Date:
                                                                        </th>
                                                                        <th>
                                                                                Level:
                                                                        </th>
                                                                        <th>
                                                                                Killed by:
                                                                        </th>
                                                                </tr>
                                        <?php
                                        if ($config['TFSVersion'] == 'TFS_02' || $config['TFSVersion'] == 'TFS_10') {
                                                $array = user_fetch_deathlist($user_id);
                                                if ($array) {
                                                        //data_dump($array, false, "Data:");
                                                        ?>
                                                        <ul>
                                                                <?php
                                                                // Design and present the list
                                                                foreach ($array as $value) {
                                                                        echo '<tr>';
                                                                        // $value[0]
                                                                        $value['time'] = getClock($value['time'], true);                                      
                                                                        if ($value['is_player'] == 1) {
                                                                                $value['killed_by'] = 'player: <a href="characterprofile.php?name='. $value['killed_by'] .'">'. $value['killed_by'] .'</a>';
                                                                        } else {
                                                                                $value['killed_by'] = 'monster: '. $value['killed_by'] .'.';
                                                                        }
                                                                       
                                                                        echo '<td>'. $value['time'] .'</td>
                                                                        <td> Killed at level '. $value['level'] .'</td>
                                                                        <td>'. $value['killed_by'];'</td>
                                                                        </tr>';
                                                                }
                                                        ?>
                                                        </ul>
                                                        <?php
                                                        } else {
                                                                echo '<b><font color="green">This player has never died.</font></b>';
                                                        }
                                                        //Done.
                                                } else if ($config['TFSVersion'] == 'TFS_03') {
                                                        $array = user_fetch_deathlist03($user_id);
                                                        if ($array) {
                                                        ?>
                                                        <ul>
                                                                <?php
                                                                // Design and present the list
                                                                foreach ($array as $value) {
                                                                        echo '<tr>';
                                                                        $value[3] = user_get_killer_id(user_get_kid($value['id']));
                                                                        if ($value[3] !== false && $value[3] >= 1) {
                                                                                $namedata = user_character_data((int)$value[3], 'name');
                                                                                if ($namedata !== false) {
                                                                                        $value[3] = $namedata['name'];
                                                                                        $value[3] = '<a href="characterprofile.php?name='. $value[3] .'">'. $value[3] .'</a>';
                                                                                } else {
                                                                                        $value[3] = 'deleted player.';
                                                                                }
                                                                        } else {
                                                                                $value[3] = user_get_killer_m_name(user_get_kid($value['id']));
                                                                                if ($value[3] === false) $value[3] = 'deleted player.';
                                                                        }
                                                                        echo '<td>'. getClock($value['date'], true) .'</td> <td>Killed at level '. $value['level'] .'.</td> <td>'. $value[3];
                                                                        '</td></tr>';
                                                                }
                                                        ?>
                                                        </ul>
                                                        <?php
                                                        } else {
                                                                echo '<b><font color="green">This player has never died.</font></b>';
                                                        }
                                                }
                                                ?>
                                </table>
                               
                                <!-- END DEATH LIST -->
                               
                               
                               
                                <!-- CHARACTER LIST -->
                                <?php
                                if (user_character_hide($profile_data['name']) != 1 && user_character_list_count(user_character_account_id($name)) > 1) {
                                ?>
                                        <li>
                                                <h1>Other visible characters on this account:</h1><br>
                                                <?php
                                                $characters = user_character_list(user_character_account_id($profile_data['name']));
                                                // characters: [0] = name, [1] = level, [2] = vocation, [3] = town_id, [4] = lastlogin, [5] = online
                                                if ($characters && count($characters) > 1) {
                                                        ?>
                                                        <table id="characterprofileTable" class="table table-striped table-hover">
                                                                <tr class="yellow">
                                                                        <th>
                                                                                Name:
                                                                        </th>
                                                                        <th>
                                                                                Level:
                                                                        </th>
                                                                        <th>
                                                                                Vocation:
                                                                        </th>
                                                                        <th>
                                                                                Last login:
                                                                        </th>
                                                                        <th>
                                                                                Status:
                                                                        </th>
                                                                </tr>
                                                                <?php
                                                                // Design and present the list
                                                                foreach ($characters as $char) {
                                                                        if ($char['name'] != $profile_data['name']) {
                                                                                if (hide_char_to_name(user_character_hide($char['name'])) != 'hidden') {
                                                                                        echo '<tr>';
                                                                                        echo '<td><a href="characterprofile.php?name='. $char['name'] .'">'. $char['name'] .'</a></td>';
                                                                                        echo '<td>'. $char['level'] .'</td>';
                                                                                        echo '<td>'. $char['vocation'] .'</td>';
                                                                                        echo '<td>'. $char['lastlogin'] .'</td>';
                                                                                        echo '<td>'. $char['online'] .'</td>';
                                                                                        echo '</tr>';
                                                                                }
                                                                        }
                                                                }
                                                        ?>
                                                        </table>
                                                        <?php
                                                        } else {
                                                                echo '<b><font color="green">This player has never died.</font></b>';
                                                        }
                                                                //Done.
                                                        ?>
                                        </li>
                                <?php
                                }
                                ?>
                                <!-- END CHARACTER LIST -->
                                <li><font class="profile_font" name="profile_font_share_url">Address: <a href="<?php
                                        if ($config['htwrite']) echo "http://".$_SERVER['HTTP_HOST']."/". $profile_data['name'];
                                        else echo "http://".$_SERVER['HTTP_HOST']."/characterprofile.php?name=". $profile_data['name'];
                                       
                                ?>"><?php
                                        if ($config['htwrite']) echo "http://".$_SERVER['HTTP_HOST']."/". $profile_data['name'];
                                        else echo "http://".$_SERVER['HTTP_HOST']."/characterprofile.php?name=". $profile_data['name'];
                                ?></a></font></li>
                        </ul>
                <!-- END PROFILE MARKUP HERE-->
               
                <?php
        } else {
                echo htmlentities(strip_tags($name, ENT_QUOTES)).' does not exist.';
        }
} else {
        header('Location: index.php');
}

include 'layout/overall/footer.php'; ?>

Thanks in advance ^^
 
Solution
lots of html structural errors.
The profile code is quite messy, here is a small cleanup, trying to add town as well, see if it works:
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
if ($config['log_ip']) {
    znote_visitor_insert_detailed_data(4);
}
if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
    $name = $_GET['name'];
 
    if (user_character_exist($name)) {
        $user_id = user_character_id($name);
        if ($config['TFSVersion'] == 'TFS_10') {
                $profile_data = user_character_data($user_id, 'name', 'level', 'vocation', 'lastlogin', 'town_id');
                $profile_data['online'] = user_is_online_10($user_id);
        } else $profile_data =...
You first need to get the town_id. You did not say your TFS version so I will go with TFS_10

You need to add town_id to line 12

Code:
$profile_data = user_character_data($user_id, 'name', 'level', 'vocation', 'lastlogin', 'town_id');

Then you can add the following table row

Code:
<tr><td><?php echo $config['towns'][$profile_data['town_id']]; ?></td></tr>

You need to have your towns set-up on your config.php file.
 
ok, got like this now

line 41
PHP:
                                <tr><td>Residence</td></tr><?php echo $config['towns'][$profile_data['town_id']]; ?></td></tr>

line 11
PHP:
                        $profile_data = user_character_data($user_id, 'name', 'level', 'vocation', 'town_id', 'lastlogin');

and get this

9fb214de3a.png


how i can make this work?
@Znote
 
Last edited:
@ralke

For me its working fine (tested on TFS 1.0+) So... did you put town_id on the correct query (your version one) and does your schema have town_id?

Because you said TFS_03 so it should be on line 14 not 11.
 
@ralke

For me its working fine (tested on TFS 1.0+) So... did you put town_id on the correct query (your version one) and does your schema have town_id?

Because you said TFS_03 so it should be on line 14 not 11.

thats why, town_id should be a mysql table right? i saw my sql database and town_id is missing :p also tried line 14 too and still having blank residence ^^
 
Make sure to actually add the town names in your config.php as well ( townid => "townName" )
 
thats why, town_id should be a mysql table right? i saw my sql database and town_id is missing :p also tried line 14 too and still having blank residence ^^
town_id is a column from your players table. Check if you have that
 
Make sure to actually add the town names in your config.php as well ( townid => "townName" )

sure got this on config.php

PHP:
    // Town ids and names: (In RME map editor, open map, click CTRL + T to view towns, their names and their IDs.
    // townID => 'townName' etc: ['3'=>'Thais']
    $config['towns'] = array(
        1 => 'Venore',
        2 => 'Thais',
        3 => 'Kazordoon',
        4 => 'Carlin',
        5 => "Ab'Dendriel",
        6 => 'Rookgaard',
        7 => 'Liberty Bay',
        8 => 'Port Hope',
        9 => 'Ankrahmun',
        10 => 'Darashia',
        11 => 'Edron',
        12 => 'Svargrond',
        13 => 'Yalahar',
        14 => 'Farmine',
    );

town_id is a column from your players table. Check if you have that

this right? :p

aba2639e19.png


btw i tried changing if ($config['TFSVersion'] == 'TFS_10') to TFS_03 but when i do that characterprofile.php stop working, and i have TFS_03 on config.php (working).

thx for your replies ^^
 
lots of html structural errors.
The profile code is quite messy, here is a small cleanup, trying to add town as well, see if it works:
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
if ($config['log_ip']) {
    znote_visitor_insert_detailed_data(4);
}
if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
    $name = $_GET['name'];
 
    if (user_character_exist($name)) {
        $user_id = user_character_id($name);
        if ($config['TFSVersion'] == 'TFS_10') {
                $profile_data = user_character_data($user_id, 'name', 'level', 'vocation', 'lastlogin', 'town_id');
                $profile_data['online'] = user_is_online_10($user_id);
        } else $profile_data = user_character_data($user_id, 'name', 'level', 'vocation', 'lastlogin', 'town_id', 'online');
        $profile_znote_data = user_znote_character_data($user_id, 'created', 'hide_char', 'comment');
     
        $guild_exist = false;
        if (get_character_guild_rank($user_id) > 0) {
                $guild_exist = true;
                $guild = get_player_guild_data($user_id);
                $guild_name = get_guild_name($guild['guild_id']);
        }
        ?>
     
        <!-- PROFILE MARKUP HERE-->
        <h1>Character Profile:</h1>
        <table>
            <tr class="yellow"><th><center>Name:</th><th><?php echo $profile_data['name']; ?></center></th></tr>
            <tr><td>Level:</td><td><?php echo $profile_data['level']; ?></td></tr>
            <tr><td>Vocation:</td><td><?php echo vocation_id_to_name($profile_data['vocation']); ?></td></tr>
            <tr>
                <td>Guild:</td>
                <td><?php
                        if ($guild_exist) {
                        ?>
                        <?php echo $guild['rank_name']; ?> of <a href="guilds.php?name=<?php echo $guild_name; ?>"><?php echo $guild_name; ?></a>
                        <?php
                        }
                        else {
                        echo 'None';
                        }
                ?></td>
            </tr>
            <tr>
                <td>Residence</td>
                <td><?php echo $config['towns'][$profile_data['town_id']]; ?></td>
            </tr>
            <tr>
                <td>Last Login:</td>
                <td><?php
                    if ($profile_data['lastlogin'] != 0) { echo getClock($profile_data['lastlogin'], true, false); } else { echo 'Never.'; }
                ?></td>
            </tr>
            <tr>
                <td>Status:</td>
                <td><?php
                    if ($config['TFSVersion'] == 'TFS_10') {
                        if ($profile_data['online']) {
                            echo '<font class="profile_font" name="profile_font_online" color="green"><b>ONLINE</b></font>';
                        } else {
                            echo '<font class="profile_font" name="profile_font_online" color="red"><b>OFFLINE</b></font>';
                        }
                    } else {
                        if ($profile_data['online'] == 1) {
                            echo '<font class="profile_font" name="profile_font_online" color="green"><b>ONLINE</b></font>';
                        } else {
                            echo '<font class="profile_font" name="profile_font_online" color="red"><b>OFFLINE</b></font>';
                        }
                    }
                ?></td>
            </tr>
            <tr>
                <td>Created:</td>
                <td><?php echo getClock($profile_znote_data['created'], true); ?></td>
            </tr>
        </table>
<?php
/*/
/   Znote AAC 1.4+ detailed character info (HP, MP, lvL, Exp, skills)
/   HTML code based on code from Gesior
/*/
$tableWidth = 540;
if ($config['TFSVersion'] != 'TFS_10') {
    $playerData = mysql_select_multi("SELECT `value` FROM `player_skills` WHERE `player_id`='$user_id' LIMIT 7;");
    $playerData['fist'] = $playerData[0]['value']; unset($playerData[0]);
    $playerData['club'] = $playerData[1]['value']; unset($playerData[1]);
    $playerData['sword'] = $playerData[2]['value']; unset($playerData[2]);
    $playerData['axe'] = $playerData[3]['value']; unset($playerData[3]);
    $playerData['dist'] = $playerData[4]['value']; unset($playerData[4]);
    $playerData['shield'] = $playerData[5]['value']; unset($playerData[5]);
    $playerData['fish'] = $playerData[6]['value']; unset($playerData[6]);

    $player = mysql_select_single("SELECT `health`, `healthmax`, `mana`, `manamax`, `experience`, `maglevel`, `level` FROM `players` WHERE `id`='$user_id' LIMIT 1;");
    $playerData['magic'] = $player['maglevel'];
    $playerData['exp'] = array(
        'now' => $player['experience'],
        'next' => (int)(level_to_experience($player['level']+1) - $player['experience']),
        'percent' => (int)(($player['experience'] - level_to_experience($player['level'])) / (level_to_experience($player['level']+1) - $player['experience']) * 100)
    );
    $playerData['health'] = array(
        'now' => $player['health'],
        'max' => $player['healthmax'],
        'percent' => (int)($player['health'] / $player['healthmax'] * 100),
    );
    $playerData['mana'] = array(
        'now' => $player['mana'],
        'max' => $player['manamax'],
        'percent' => (int)($player['mana'] / $player['manamax'] * 100),
    );
} else {
    $player = mysql_select_single("SELECT `health`, `healthmax`, `mana`, `manamax`, `experience`, `skill_fist`, `skill_club`, `skill_sword`, `skill_axe`, `skill_dist`, `skill_shielding`, `skill_fishing`, `maglevel`, `level` FROM `players` WHERE `id`='$user_id' LIMIT 1;");
    $playerData = array(
        'fist' => $player['skill_fist'],
        'club' => $player['skill_club'],
        'sword' => $player['skill_sword'],
        'axe' => $player['skill_axe'],
        'dist' => $player['skill_dist'],
        'shield' => $player['skill_shielding'],
        'fish' => $player['skill_fishing'],
        'magic' => $player['maglevel'],
        'exp' => array(
            'now' => $player['experience'],
            'next' => (int)(level_to_experience($player['level']+1) - $player['experience']),
            'percent' => (int)(($player['experience'] - level_to_experience($player['level'])) / (level_to_experience($player['level']+1) - $player['experience']) * 100)
        ),
        'health' => array(
            'now' => $player['health'],
            'max' => $player['healthmax'],
            'percent' => (int)($player['health'] / $player['healthmax'] * 100),
        ),
        'mana' => array(
            'now' => $player['mana'],
            'max' => $player['manamax'],
            'percent' => (int)($player['mana'] / $player['manamax'] * 100),
        )
    );
}
// Incase they have more health/mana than they should due to equipment bonus etc
if ($playerData['exp']['percent'] > 100) $playerData['exp']['percent'] = 100;
if ($playerData['health']['percent'] > 100) $playerData['health']['percent'] = 100;
if ($playerData['mana']['percent'] > 100) $playerData['mana']['percent'] = 100;
//data_dump($playerData, false, "Player Data");
?>
<!-- PLAYER SKILLS TABLE -->
<center><table cellspacing="1" cellpadding="4" style="width: <?php echo $tableWidth; ?>px;">
    <tr class="yellow">
        <th>Fist</th>
        <th>Club</th>
        <th>Sword</th>
        <th>Axe</th>
        <th>Dist</th>
        <th>Shield</th>
        <th>Fish</th>
        <th>Magic</th>
    </tr>
    <tr>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['fist']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['club']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['sword']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['axe']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['dist']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['shield']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['fish']; ?>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['magic']; ?>
        </td>
    </tr>
</table></center>
<!-- PLAYER INFO TABLE -->
<center><table cellspacing="1" cellpadding="4" style="width: <?php echo $tableWidth; ?>px;">
    <tr>
        <td bgcolor="#F1E0C6" align="left" width="20%">
            <b>Player HP:</b>
        </td>
        <td bgcolor="#F1E0C6" align="left">
            <?php echo $playerData['health']['now'].'/'.$playerData['health']['max']; ?>
            <div style="width: 100%; height: 3px; border: 1px solid #000;">
                <div style="background: red; width: <?php echo $playerData['health']['percent']; ?>%; height: 3px;">
                </div>
            </div>
        </td>
    </tr>
    <tr>
        <td bgcolor="#D4C0A1" align="left">
            <b>Player MP:</b>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo $playerData['mana']['now'].'/'.$playerData['mana']['max']; ?>
            <div style="width: 100%; height: 3px; border: 1px solid #000;">
                <div style="background: blue; width: <?php echo $playerData['mana']['percent']; ?>%; height: 3px;">
                </div>
            </div>
        </td>
    </tr>
    <tr>
        <td bgcolor="#D4C0A1" align="left">
            <b>Player XP:</b>
        </td>
        <td bgcolor="#D4C0A1" align="left">
            <?php echo number_format($playerData['exp']['now'], 0, "", " "); ?> Experience.
        </td>
    </tr>
    <tr>
        <td bgcolor="#F1E0C6" align="left">
            <b>To Next Lvl:</b>
        </td>
        <td bgcolor="#F1E0C6" align="left">
            Need <b><?php echo number_format($playerData['exp']['next'], 0, "", " "); ?> experience (<?php echo 100-$playerData['exp']['percent']; ?>%)</b> to Level <b><?php echo $player['level']+1; ?></b>.
            <div title="99.320604545 %" style="width: 100%; height: 3px; border: 1px solid #000;">
                <div style="background: red; width: <?php echo $playerData['exp']['percent']; ?>%; height: 3px;"></div>
            </div>
        </td>
    </tr>
</table></center>
<!-- END detailed character info -->
<table>
    <tr class="yellow">
        <th><center>Comment:</center></th>
    </tr>
    <tr>
        <td><center><textarea name="profile_comment_textarea" cols="70" rows="10" readonly="readonly" class="span12"><?php echo $profile_znote_data['comment']; ?></textarea></center></td>
    </tr>
</table>
<!-- DEATH LIST -->
<h1>Death List:</h1><br>
<table id="characterprofileTable" class="table table-striped table-hover">
    <tr class="yellow">
        <th>Date:</th>
        <th>Level:</th>
        <th>Killed by:</th>
    </tr>
    <?php
    if ($config['TFSVersion'] == 'TFS_02' || $config['TFSVersion'] == 'TFS_10') {
        $array = user_fetch_deathlist($user_id);
        if ($array) {
             
                // Design and present the list
                foreach ($array as $value) {
                    echo '<tr>';
                    // $value[0]
                    $value['time'] = getClock($value['time'], true);                                    
                    if ($value['is_player'] == 1) {
                        $value['killed_by'] = 'player: <a href="characterprofile.php?name='. $value['killed_by'] .'">'. $value['killed_by'] .'</a>';
                    } else {
                        $value['killed_by'] = 'monster: '. $value['killed_by'] .'.';
                    }
                 
                    echo '<td>'. $value['time'] .'</td>
                    <td> Killed at level '. $value['level'] .'</td>
                    <td>'. $value['killed_by'];'</td>
                    </tr>';
                }
             
            } else {
                echo '<b><font color="green">This player has never died.</font></b>';
            }
            //Done.
        } else if ($config['TFSVersion'] == 'TFS_03') {
            $array = user_fetch_deathlist03($user_id);
            if ($array) {
         
                // Design and present the list
                foreach ($array as $value) {
                    echo '<tr>';
                    $value[3] = user_get_killer_id(user_get_kid($value['id']));
                    if ($value[3] !== false && $value[3] >= 1) {
                        $namedata = user_character_data((int)$value[3], 'name');
                        if ($namedata !== false) {
                            $value[3] = $namedata['name'];
                            $value[3] = '<a href="characterprofile.php?name='. $value[3] .'">'. $value[3] .'</a>';
                        } else {
                            $value[3] = 'deleted player.';
                        }
                    } else {
                        $value[3] = user_get_killer_m_name(user_get_kid($value['id']));
                        if ($value[3] === false) $value[3] = 'deleted player.';
                    }
                    echo '<td>'. getClock($value['date'], true) .'</td> <td>Killed at level '. $value['level'] .'.</td> <td>'. $value[3];
                    '</td></tr>';
                }
         
            } else {
                echo '<b><font color="green">This player has never died.</font></b>';
            }
        }
        ?>
</table>
<!-- END DEATH LIST -->         
<!-- CHARACTER LIST -->
<?php
if (user_character_hide($profile_data['name']) != 1 && user_character_list_count(user_character_account_id($name)) > 1) {
?>
    <h1>Other visible characters on this account:</h1><br>
    <?php
    $characters = user_character_list(user_character_account_id($profile_data['name']));
    // characters: [0] = name, [1] = level, [2] = vocation, [3] = town_id, [4] = lastlogin, [5] = online
    if ($characters && count($characters) > 1) {
        ?>
        <table id="characterprofileTable" class="table table-striped table-hover">
            <tr class="yellow">
                <th>Name:</th>
                <th>Level:</th>
                <th>Vocation:</th>
                <th>Last login:</th>
                <th>Status:</th>
            </tr>
            <?php
            // Design and present the list
            foreach ($characters as $char) {
                if ($char['name'] != $profile_data['name']) {
                    if (hide_char_to_name(user_character_hide($char['name'])) != 'hidden') {
                        echo '<tr>';
                        echo '<td><a href="characterprofile.php?name='. $char['name'] .'">'. $char['name'] .'</a></td>';
                        echo '<td>'. $char['level'] .'</td>';
                        echo '<td>'. $char['vocation'] .'</td>';
                        echo '<td>'. $char['lastlogin'] .'</td>';
                        echo '<td>'. $char['online'] .'</td>';
                        echo '</tr>';
                    }
                }
            }
            ?>
        </table>
        <?php
    } else {
        echo '<b><font color="green">This player has never died.</font></b>';
    }
    //Done.
}
?>
<!-- END CHARACTER LIST -->
<font class="profile_font" name="profile_font_share_url">Address: <a href="<?php
        if ($config['htwrite']) echo "http://".$_SERVER['HTTP_HOST']."/". $profile_data['name'];
        else echo "http://".$_SERVER['HTTP_HOST']."/characterprofile.php?name=". $profile_data['name'];
?>"><?php
        if ($config['htwrite']) echo "http://".$_SERVER['HTTP_HOST']."/". $profile_data['name'];
        else echo "http://".$_SERVER['HTTP_HOST']."/characterprofile.php?name=". $profile_data['name'];
?></a></font>
<!-- END PROFILE MARKUP HERE-->
<?php
} else {
    echo htmlentities(strip_tags($name, ENT_QUOTES)).' does not exist.';
}
} else {
    header('Location: index.php');
}
include 'layout/overall/footer.php'; ?>
 
Last edited:
Solution
Back
Top