[Znote AAC] Characterprofile detailed character info (HP, MP, Level, Exp, skills)

Discussion in 'Website Applications' started by Znote, Mar 8, 2014.

  1. Znote

    Znote <?php echo $title; ?> Staff Member Global Moderator Premium User

    Joined:
    Feb 14, 2008
    Messages:
    6,361
    Likes Received:
    1,058
    Best Answers:
    148
    [​IMG]

    Add it where you want it on characterprofile.php:
    PHP:
    1.  
    2. <?php
    3. /*/
    4. /   Znote AAC 1.4+ detailed character info (HP, MP, lvL, Exp, skills)
    5. /   HTML code based on code from Gesior
    6. /*/
    7. $tableWidth = 540;
    8. if ($config['TFSVersion'] != 'TFS_10') {
    9.     $playerData = mysql_select_multi("SELECT `value` FROM `player_skills` WHERE `player_id`='$user_id' LIMIT 7;");
    10.     $playerData['fist'] = $playerData[0]['value']; unset($playerData[0]);
    11.     $playerData['club'] = $playerData[1]['value']; unset($playerData[1]);
    12.     $playerData['sword'] = $playerData[2]['value']; unset($playerData[2]);
    13.     $playerData['axe'] = $playerData[3]['value']; unset($playerData[3]);
    14.     $playerData['dist'] = $playerData[4]['value']; unset($playerData[4]);
    15.     $playerData['shield'] = $playerData[5]['value']; unset($playerData[5]);
    16.     $playerData['fish'] = $playerData[6]['value']; unset($playerData[6]);
    17.  
    18.     $player = mysql_select_single("SELECT `health`, `healthmax`, `mana`, `manamax`, `experience`, `maglevel`, `level` FROM `players` WHERE `id`='$user_id' LIMIT 1;");
    19.     $playerData['magic'] = $player['maglevel'];
    20.     $playerData['exp'] = array(
    21.         'now' => $player['experience'],
    22.         'next' => (int)(level_to_experience($player['level']+1) - $player['experience']),
    23.         'percent' => (int)(($player['experience'] - level_to_experience($player['level'])) / (level_to_experience($player['level']+1) - $player['experience']) * 100)
    24.     );
    25.     $playerData['health'] = array(
    26.         'now' => $player['health'],
    27.         'max' => $player['healthmax'],
    28.         'percent' => (int)($player['health'] / $player['healthmax'] * 100),
    29.     );
    30.     $playerData['mana'] = array(
    31.         'now' => $player['mana'],
    32.         'max' => $player['manamax'],
    33.         'percent' => (int)($player['mana'] / $player['manamax'] * 100),
    34.     );
    35. } else {
    36.     $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;");
    37.     $playerData = array(
    38.         'fist' => $player['skill_fist'],
    39.         'club' => $player['skill_club'],
    40.         'sword' => $player['skill_sword'],
    41.         'axe' => $player['skill_axe'],
    42.         'dist' => $player['skill_dist'],
    43.         'shield' => $player['skill_shielding'],
    44.         'fish' => $player['skill_fishing'],
    45.         'magic' => $player['maglevel'],
    46.         'exp' => array(
    47.             'now' => $player['experience'],
    48.             'next' => (int)(level_to_experience($player['level']+1) - $player['experience']),
    49.             'percent' => (int)(($player['experience'] - level_to_experience($player['level'])) / (level_to_experience($player['level']+1) - $player['experience']) * 100)
    50.         ),
    51.         'health' => array(
    52.             'now' => $player['health'],
    53.             'max' => $player['healthmax'],
    54.             'percent' => (int)($player['health'] / $player['healthmax'] * 100),
    55.         ),
    56.         'mana' => array(
    57.             'now' => $player['mana'],
    58.             'max' => $player['manamax'],
    59.             'percent' => (int)($player['mana'] / $player['manamax'] * 100),
    60.         )
    61.     );
    62. }
    63. // Incase they have more health/mana than they should due to equipment bonus etc
    64. if ($playerData['exp']['percent'] > 100) $playerData['exp']['percent'] = 100;
    65. if ($playerData['health']['percent'] > 100) $playerData['health']['percent'] = 100;
    66. if ($playerData['mana']['percent'] > 100) $playerData['mana']['percent'] = 100;
    67. //data_dump($playerData, false, "Player Data");
    68. ?>
    69. <!-- PLAYER SKILLS TABLE -->
    70. <table cellspacing="1" cellpadding="4" style="width: <?php echo $tableWidth; ?>px;">
    71.     <tr class="yellow">
    72.         <th>Fist</th>
    73.         <th>Club</th>
    74.         <th>Sword</th>
    75.         <th>Axe</th>
    76.         <th>Dist</th>
    77.         <th>Shield</th>
    78.         <th>Fish</th>
    79.         <th>Magic</th>
    80.     </tr>
    81.     <tr>
    82.         <td bgcolor="#D4C0A1" align="left">
    83.             <?php echo $playerData['fist']; ?>
    84.         </td>
    85.         <td bgcolor="#D4C0A1" align="left">
    86.             <?php echo $playerData['club']; ?>
    87.         </td>
    88.         <td bgcolor="#D4C0A1" align="left">
    89.             <?php echo $playerData['sword']; ?>
    90.         </td>
    91.         <td bgcolor="#D4C0A1" align="left">
    92.             <?php echo $playerData['axe']; ?>
    93.         </td>
    94.         <td bgcolor="#D4C0A1" align="left">
    95.             <?php echo $playerData['dist']; ?>
    96.         </td>
    97.         <td bgcolor="#D4C0A1" align="left">
    98.             <?php echo $playerData['shield']; ?>
    99.         </td>
    100.         <td bgcolor="#D4C0A1" align="left">
    101.             <?php echo $playerData['fish']; ?>
    102.         </td>
    103.         <td bgcolor="#D4C0A1" align="left">
    104.             <?php echo $playerData['magic']; ?>
    105.         </td>
    106.     </tr>
    107. </table>
    108. <!-- PLAYER INFO TABLE -->
    109. <table cellspacing="1" cellpadding="4" style="width: <?php echo $tableWidth; ?>px;">
    110.     <tr>
    111.         <td bgcolor="#F1E0C6" align="left" width="20%">
    112.             <b>Player HP:</b>
    113.         </td>
    114.         <td bgcolor="#F1E0C6" align="left">
    115.             <?php echo $playerData['health']['now'].'/'.$playerData['health']['max']; ?>
    116.             <div style="width: 100%; height: 3px; border: 1px solid #000;">
    117.                 <div style="background: red; width: <?php echo $playerData['health']['percent']; ?>%; height: 3px;">
    118.                 </div>
    119.             </div>
    120.         </td>
    121.     </tr>
    122.     <tr>
    123.         <td bgcolor="#D4C0A1" align="left">
    124.             <b>Player MP:</b>
    125.         </td>
    126.         <td bgcolor="#D4C0A1" align="left">
    127.             <?php echo $playerData['mana']['now'].'/'.$playerData['mana']['max']; ?>
    128.             <div style="width: 100%; height: 3px; border: 1px solid #000;">
    129.                 <div style="background: blue; width: <?php echo $playerData['mana']['percent']; ?>%; height: 3px;">
    130.                 </div>
    131.             </div>
    132.         </td>
    133.     </tr>
    134.     <tr>
    135.         <td bgcolor="#D4C0A1" align="left">
    136.             <b>Player XP:</b>
    137.         </td>
    138.         <td bgcolor="#D4C0A1" align="left">
    139.             <?php echo number_format($playerData['exp']['now'], 0, "", " "); ?> Experience.
    140.         </td>
    141.     </tr>
    142.     <tr>
    143.         <td bgcolor="#F1E0C6" align="left">
    144.             <b>To Next Lvl:</b>
    145.         </td>
    146.         <td bgcolor="#F1E0C6" align="left">
    147.             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>.
    148.             <div title="99.320604545 %" style="width: 100%; height: 3px; border: 1px solid #000;">
    149.                 <div style="background: red; width: <?php echo $playerData['exp']['percent']; ?>%; height: 3px;"></div>
    150.             </div>
    151.         </td>
    152.     </tr>
    153. </table>
    154. <!-- END detailed character info -->
    155.  
    Enjoy.
     
    Last edited: Mar 8, 2014
  2. Zippow

    Zippow Member

    Joined:
    Aug 27, 2011
    Messages:
    454
    Likes Received:
    21
    Best Answers:
    0
    Nice!
     
  3. Wartio

    Wartio Any game ideas?

    Joined:
    Apr 2, 2010
    Messages:
    459
    Likes Received:
    29
    Best Answers:
    0
    Finally ;), Now the website looks more fancy and more detailed than before when it was like almost empty page ;), Good release Znote!
     
  4. Raggaer

    Raggaer Godly Member

    Joined:
    Jul 25, 2012
    Messages:
    1,521
    Likes Received:
    865
    Best Answers:
    8
    Cool, but I dont really think wheres the point on seeing the current HP a character have haha!
     
  5. Znote

    Znote <?php echo $title; ?> Staff Member Global Moderator Premium User

    Joined:
    Feb 14, 2008
    Messages:
    6,361
    Likes Received:
    1,058
    Best Answers:
    148
    Kinda agree with you, however I kept getting requests since its common on Gesior AAC.

    Anyway it is easy to remove player skills table or character info table, so its flexible to the owners desire. :)
     
  6. iDramatiik

    iDramatiik http://realia.no-ip.info/ RLMap 10.41 Free Points

    Joined:
    Apr 15, 2014
    Messages:
    157
    Likes Received:
    14
    Best Answers:
    0
    Noob question alert: How exactly do I add this in characterprofile.php before or after the current already there php/> or whatever

    thanks man looks good though
     
  7. Tibiamakers

    Tibiamakers yourolist.com

    Joined:
    May 24, 2010
    Messages:
    1,377
    Likes Received:
    95
    Best Answers:
    0
    Barcelonista? wtf hahah
     
    Evil Puncker likes this.
  8. Dark Anonymous

    Dark Anonymous New Member

    Joined:
    Jun 4, 2014
    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    didn't work with me
     

    Attached Files:

  9. Znote

    Znote <?php echo $title; ?> Staff Member Global Moderator Premium User

    Joined:
    Feb 14, 2008
    Messages:
    6,361
    Likes Received:
    1,058
    Best Answers:
    148
    Write correct TFS version in config.php
     
  10. 8408323

    8408323 Hoster

    Joined:
    Mar 6, 2009
    Messages:
    432
    Likes Received:
    25
    Best Answers:
    0
    Could you help me @Znote?
    I'm trying to delete the gap between the player's skills and the player's hp. Can't figure out how the gap could be removed. I hope you understand which gap I mean, otherwise I have to create a image.

    Thanks in advice,
    8408323
     
  11. Cornex

    Cornex Web Developer Staff Member Global Moderator

    Joined:
    Jun 15, 2008
    Messages:
    3,443
    Likes Received:
    1,157
    Best Answers:
    4
    Give this a try:

    PHP:
    1. <?php
    2. /*/
    3. /   Znote AAC 1.4+ detailed character info (HP, MP, lvL, Exp, skills)
    4. /   HTML code based on code from Gesior
    5. /*/
    6. $tableWidth = 540;
    7. if ($config['TFSVersion'] != 'TFS_10') {
    8.     $playerData = mysql_select_multi("SELECT `value` FROM `player_skills` WHERE `player_id`='$user_id' LIMIT 7;");
    9.     $playerData['fist'] = $playerData[0]['value']; unset($playerData[0]);
    10.     $playerData['club'] = $playerData[1]['value']; unset($playerData[1]);
    11.     $playerData['sword'] = $playerData[2]['value']; unset($playerData[2]);
    12.     $playerData['axe'] = $playerData[3]['value']; unset($playerData[3]);
    13.     $playerData['dist'] = $playerData[4]['value']; unset($playerData[4]);
    14.     $playerData['shield'] = $playerData[5]['value']; unset($playerData[5]);
    15.     $playerData['fish'] = $playerData[6]['value']; unset($playerData[6]);
    16.  
    17.     $player = mysql_select_single("SELECT `health`, `healthmax`, `mana`, `manamax`, `experience`, `maglevel`, `level` FROM `players` WHERE `id`='$user_id' LIMIT 1;");
    18.     $playerData['magic'] = $player['maglevel'];
    19.     $playerData['exp'] = array(
    20.         'now' => $player['experience'],
    21.         'next' => (int)(level_to_experience($player['level']+1) - $player['experience']),
    22.         'percent' => (int)(($player['experience'] - level_to_experience($player['level'])) / (level_to_experience($player['level']+1) - $player['experience']) * 100)
    23.     );
    24.     $playerData['health'] = array(
    25.         'now' => $player['health'],
    26.         'max' => $player['healthmax'],
    27.         'percent' => (int)($player['health'] / $player['healthmax'] * 100),
    28.     );
    29.     $playerData['mana'] = array(
    30.         'now' => $player['mana'],
    31.         'max' => $player['manamax'],
    32.         'percent' => (int)($player['mana'] / $player['manamax'] * 100),
    33.     );
    34. } else {
    35.     $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;");
    36.     $playerData = array(
    37.         'fist' => $player['skill_fist'],
    38.         'club' => $player['skill_club'],
    39.         'sword' => $player['skill_sword'],
    40.         'axe' => $player['skill_axe'],
    41.         'dist' => $player['skill_dist'],
    42.         'shield' => $player['skill_shielding'],
    43.         'fish' => $player['skill_fishing'],
    44.         'magic' => $player['maglevel'],
    45.         'exp' => array(
    46.             'now' => $player['experience'],
    47.             'next' => (int)(level_to_experience($player['level']+1) - $player['experience']),
    48.             'percent' => (int)(($player['experience'] - level_to_experience($player['level'])) / (level_to_experience($player['level']+1) - $player['experience']) * 100)
    49.         ),
    50.         'health' => array(
    51.             'now' => $player['health'],
    52.             'max' => $player['healthmax'],
    53.             'percent' => (int)($player['health'] / $player['healthmax'] * 100),
    54.         ),
    55.         'mana' => array(
    56.             'now' => $player['mana'],
    57.             'max' => $player['manamax'],
    58.             'percent' => (int)($player['mana'] / $player['manamax'] * 100),
    59.         )
    60.     );
    61. }
    62. // Incase they have more health/mana than they should due to equipment bonus etc
    63. if ($playerData['exp']['percent'] > 100) $playerData['exp']['percent'] = 100;
    64. if ($playerData['health']['percent'] > 100) $playerData['health']['percent'] = 100;
    65. if ($playerData['mana']['percent'] > 100) $playerData['mana']['percent'] = 100;
    66. //data_dump($playerData, false, "Player Data");
    67. ?>
    68. <!-- PLAYER SKILLS TABLE -->
    69. <table cellspacing="1" cellpadding="4" style="width: <?php echo $tableWidth; ?>px;margin-bottom:0px;">
    70.     <tr class="yellow">
    71.         <th>Fist</th>
    72.         <th>Club</th>
    73.         <th>Sword</th>
    74.         <th>Axe</th>
    75.         <th>Dist</th>
    76.         <th>Shield</th>
    77.         <th>Fish</th>
    78.         <th>Magic</th>
    79.     </tr>
    80.     <tr>
    81.         <td bgcolor="#D4C0A1" align="left">
    82.             <?php echo $playerData['fist']; ?>
    83.         </td>
    84.         <td bgcolor="#D4C0A1" align="left">
    85.             <?php echo $playerData['club']; ?>
    86.         </td>
    87.         <td bgcolor="#D4C0A1" align="left">
    88.             <?php echo $playerData['sword']; ?>
    89.         </td>
    90.         <td bgcolor="#D4C0A1" align="left">
    91.             <?php echo $playerData['axe']; ?>
    92.         </td>
    93.         <td bgcolor="#D4C0A1" align="left">
    94.             <?php echo $playerData['dist']; ?>
    95.         </td>
    96.         <td bgcolor="#D4C0A1" align="left">
    97.             <?php echo $playerData['shield']; ?>
    98.         </td>
    99.         <td bgcolor="#D4C0A1" align="left">
    100.             <?php echo $playerData['fish']; ?>
    101.         </td>
    102.         <td bgcolor="#D4C0A1" align="left">
    103.             <?php echo $playerData['magic']; ?>
    104.         </td>
    105.     </tr>
    106. </table>
    107. <!-- PLAYER INFO TABLE -->
    108. <table cellspacing="1" cellpadding="4" style="width: <?php echo $tableWidth; ?>px;margin-top:0px;">
    109.     <tr>
    110.         <td bgcolor="#F1E0C6" align="left" width="20%">
    111.             <b>Player HP:</b>
    112.         </td>
    113.         <td bgcolor="#F1E0C6" align="left">
    114.             <?php echo $playerData['health']['now'].'/'.$playerData['health']['max']; ?>
    115.             <div style="width: 100%; height: 3px; border: 1px solid #000;">
    116.                 <div style="background: red; width: <?php echo $playerData['health']['percent']; ?>%; height: 3px;">
    117.                 </div>
    118.             </div>
    119.         </td>
    120.     </tr>
    121.     <tr>
    122.         <td bgcolor="#D4C0A1" align="left">
    123.             <b>Player MP:</b>
    124.         </td>
    125.         <td bgcolor="#D4C0A1" align="left">
    126.             <?php echo $playerData['mana']['now'].'/'.$playerData['mana']['max']; ?>
    127.             <div style="width: 100%; height: 3px; border: 1px solid #000;">
    128.                 <div style="background: blue; width: <?php echo $playerData['mana']['percent']; ?>%; height: 3px;">
    129.                 </div>
    130.             </div>
    131.         </td>
    132.     </tr>
    133.     <tr>
    134.         <td bgcolor="#D4C0A1" align="left">
    135.             <b>Player XP:</b>
    136.         </td>
    137.         <td bgcolor="#D4C0A1" align="left">
    138.             <?php echo number_format($playerData['exp']['now'], 0, "", " "); ?> Experience.
    139.         </td>
    140.     </tr>
    141.     <tr>
    142.         <td bgcolor="#F1E0C6" align="left">
    143.             <b>To Next Lvl:</b>
    144.         </td>
    145.         <td bgcolor="#F1E0C6" align="left">
    146.             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>.
    147.             <div title="99.320604545 %" style="width: 100%; height: 3px; border: 1px solid #000;">
    148.                 <div style="background: red; width: <?php echo $playerData['exp']['percent']; ?>%; height: 3px;"></div>
    149.             </div>
    150.         </td>
    151.     </tr>
    152. </table>
    153. <!-- END detailed character info -->
     
  12. 8408323

    8408323 Hoster

    Joined:
    Mar 6, 2009
    Messages:
    432
    Likes Received:
    25
    Best Answers:
    0
    Thanks for your help, it contributed to some fixes! :)
     
  13. Ray Rewind

    Ray Rewind Doctor

    Joined:
    Jun 6, 2009
    Messages:
    1,349
    Likes Received:
    74
    Best Answers:
    0
    Could someone help me to fix this bug ?

    [​IMG]


    and how to move it to the center like other tables?

    [​IMG]
     
  14. Ray Rewind

    Ray Rewind Doctor

    Joined:
    Jun 6, 2009
    Messages:
    1,349
    Likes Received:
    74
    Best Answers:
    0
    I fixed the second bug - I replaced

    PHP:
    1. <table cellspacing="1" cellpadding="4" style="width: <?php echo $tableWidth; ?>px;">
    with
    PHP:
    1.     <table id="profiltable1">
     
  15. Nevalopo

    Nevalopo Demigod

    Joined:
    Jul 21, 2008
    Messages:
    5,164
    Likes Received:
    74
    Best Answers:
    0
    Cool! Works perfect.
    What is the difference between
    'percent' => (int)($player['mana'] / $player['manamax'] * 100),
    and
    'percent' => (int)($player['mana'] * 100),

    If im using $player['manamax'] im getting error because im running a class with 0 mana and it gives me division errors. I tried removing the manamax and it still works but doesn't feel right editing without knowing what effect it would have. It still shows max mana on other characters.
     
  16. imback1

    imback1 Unknown member

    Joined:
    Jul 11, 2013
    Messages:
    766
    Likes Received:
    43
    Best Answers:
    1
    Its working good but it's not working good on level cuz i died with char after then check website i found my exp 0% but there is 23 left to pass the level :S and its not correctly at all i mean the level only
    [​IMG]
    TFS 0.3.6
    characterprofile.php
    https://gist.github.com/Sasooo/54171dc158a53f344dc9
     
    pierroth likes this.
  17. Tarek1337

    Tarek1337 Well-Known Member

    Joined:
    Jun 9, 2012
    Messages:
    3,552
    Likes Received:
    1,129
    Best Answers:
    3
    Nothing shows up on 1.5 for TFS 1.1
     
    s7efan likes this.
  18. pierroth

    pierroth Mar Co.

    Joined:
    Sep 11, 2008
    Messages:
    344
    Likes Received:
    10
    Best Answers:
    0
    Does this still work? I'm using TFS 0.3, latest Znote AAC (1.5)
     
  19. pierroth

    pierroth Mar Co.

    Joined:
    Sep 11, 2008
    Messages:
    344
    Likes Received:
    10
    Best Answers:
    0
    Got it working thanks to Imback1.
     
  20. Jose Rondón

    Jose Rondón UTibia

    Joined:
    Oct 11, 2015
    Messages:
    63
    Likes Received:
    20
    Best Answers:
    0
    Shows blank on TFS 1.2 Znote 1.5
     

Share This Page

Loading...