• 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!

player health in website

Elgenady

Veteran OT User
Joined
Aug 5, 2011
Messages
1,637
Solutions
35
Reaction score
351
when use items with maxhealthpoints player health in website change to be like this
health.png

and code from website
PHP:
    $hp = ($player->getHealth() / $player->getHealthMax() * 100);

                        $main_content .= '<td align=center ><table width=100%><tr><td align=center><table CELLSPACING="1" CELLPADDING="4"><tr><td BGCOLOR="#D4C0A1" align="left" width="20%"><b>Player Health:</b></td>

                                        <td BGCOLOR="#D4C0A1" align="left">'.$player->getHealth().'/'.$player->getHealthMax().'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: red; width: '.$hp.'%; height: 3px;"></td></tr>';

                        if ($player->getManaMax() > 0) {

                                $mana = ($player->getMana() / $player->getManaMax() * 100);

                                $main_content .= '<tr><td BGCOLOR="#F1E0C6" align="left"><b>Player Mana:</b></td><td BGCOLOR="#F1E0C6" align="left">'.$player->getMana().'/'.$player->getManaMax().'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: blue; width: '.$mana.'%; height: 3px;"></td>';

0.4
gesior
 
Last edited:
PHP:
$hp = min(100, $player->getHealth() / $player->getHealthMax() * 100);
$main_content .= '<td align=center ><table width=100%><tr><td align=center><table CELLSPACING="1" CELLPADDING="4"><tr><td BGCOLOR="#D4C0A1" align="left" width="20%"><b>Player Health:</b></td>
                <td BGCOLOR="#D4C0A1" align="left">'.$player->getHealth().'/'.$player->getHealthMax().'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: red; width: '.$hp.'%; height: 3px;"></td></tr>';
if ($player->getManaMax() > 0) {
        $mana = min(100, $player->getMana() / $player->getManaMax() * 100);
        $main_content .= '<tr><td BGCOLOR="#F1E0C6" align="left"><b>Player Mana:</b></td><td BGCOLOR="#F1E0C6" align="left">'.$player->getMana().'/'.$player->getManaMax().'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: blue; width: '.$mana.'%; height: 3px;"></td>';
 
PHP:
$hp = min(100, $player->getHealth() / $player->getHealthMax() * 100);
$main_content .= '<td align=center ><table width=100%><tr><td align=center><table CELLSPACING="1" CELLPADDING="4"><tr><td BGCOLOR="#D4C0A1" align="left" width="20%"><b>Player Health:</b></td>
                <td BGCOLOR="#D4C0A1" align="left">'.$player->getHealth().'/'.$player->getHealthMax().'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: red; width: '.$hp.'%; height: 3px;"></td></tr>';
if ($player->getManaMax() > 0) {
        $mana = min(100, $player->getMana() / $player->getManaMax() * 100);
        $main_content .= '<tr><td BGCOLOR="#F1E0C6" align="left"><b>Player Mana:</b></td><td BGCOLOR="#F1E0C6" align="left">'.$player->getMana().'/'.$player->getManaMax().'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: blue; width: '.$mana.'%; height: 3px;"></td>';
the line fixed but number still
2300/2220
its must be 2300/2300 right?
health.png
 
Last edited:
the line fixed but number still
2300/2220
its must be 2300/2300 right?
View attachment 56935
PHP:
$playerHealth = $player->getHealth();
$playerMaxHealth = $player->getHealthMax();
$healthBarWidth = max(0, min(100, $playerHealth / $playerMaxHealth * 100));
$main_content .= '<td align=center ><table width=100%><tr><td align=center><table CELLSPACING="1" CELLPADDING="4"><tr><td BGCOLOR="#D4C0A1" align="left" width="20%"><b>Player Health:</b></td><td BGCOLOR="#D4C0A1" align="left">'.min($playerHealth, $playerMaxHealth).'/'.$playerMaxHealth.'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: red; width: '.$healthBarWidth.'%; height: 3px;"></td></tr>';

if ($player->getManaMax() > 0) {
    $playerMana = $player->getMana();
    $playerMaxMana = $player->getManaMax();
    $manaBarWidth = max(0, min(100, $playerMana / $playerMaxMana * 100));
    $main_content .= '<tr><td BGCOLOR="#F1E0C6" align="left"><b>Player Mana:</b></td><td BGCOLOR="#F1E0C6" align="left">'.min($playerMana, $playerMaxMana).'/'.$playerMaxMana.'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: blue; width: '.$manaBarWidth.'%; height: 3px;"></td>';
 
PHP:
$playerHealth = $player->getHealth();
$playerMaxHealth = $player->getHealthMax();
$healthBarWidth = max(0, min(100, $playerHealth / $playerMaxHealth * 100));
$main_content .= '<td align=center ><table width=100%><tr><td align=center><table CELLSPACING="1" CELLPADDING="4"><tr><td BGCOLOR="#D4C0A1" align="left" width="20%"><b>Player Health:</b></td><td BGCOLOR="#D4C0A1" align="left">'.min($playerHealth, $playerMaxHealth).'/'.$playerMaxHealth.'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: red; width: '.$healthBarWidth.'%; height: 3px;"></td></tr>';

if ($player->getManaMax() > 0) {
    $playerMana = $player->getMana();
    $playerMaxMana = $player->getManaMax();
    $manaBarWidth = max(0, min(100, $playerMana / $playerMaxMana * 100));
    $main_content .= '<tr><td BGCOLOR="#F1E0C6" align="left"><b>Player Mana:</b></td><td BGCOLOR="#F1E0C6" align="left">'.min($playerMana, $playerMaxMana).'/'.$playerMaxMana.'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: blue; width: '.$manaBarWidth.'%; height: 3px;"></td>';
health.png
now show health with out add maxhealthpoints this char in game health 2300
 
View attachment 56936
now show health with out add maxhealthpoints this char in game health 2300
PHP:
$playerHealth = $player->getHealth();
$playerMaxHealth = $player->getHealthMax();
$healthBarWidth = min(100, $playerHealth / $playerMaxHealth * 100);
$main_content .= '<td align=center ><table width=100%><tr><td align=center><table CELLSPACING="1" CELLPADDING="4"><tr><td BGCOLOR="#D4C0A1" align="left" width="20%"><b>Player Health:</b></td><td BGCOLOR="#D4C0A1" align="left">'.max($playerHealth, $playerMaxHealth).'/'.$playerMaxHealth.'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: red; width: '.$healthBarWidth.'%; height: 3px;"></td></tr>';

if ($player->getManaMax() > 0) {
    $playerMana = $player->getMana();
    $playerMaxMana = $player->getManaMax();
    $manaBarWidth = min(100, $playerMana / $playerMaxMana * 100);
    $main_content .= '<tr><td BGCOLOR="#F1E0C6" align="left"><b>Player Mana:</b></td><td BGCOLOR="#F1E0C6" align="left">'.max($playerMana, $playerMaxMana).'/'.$playerMaxMana.'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: blue; width: '.$manaBarWidth.'%; height: 3px;"></td>';
 
PHP:
$playerHealth = $player->getHealth();
$playerMaxHealth = $player->getHealthMax();
$healthBarWidth = min(100, $playerHealth / $playerMaxHealth * 100);
$main_content .= '<td align=center ><table width=100%><tr><td align=center><table CELLSPACING="1" CELLPADDING="4"><tr><td BGCOLOR="#D4C0A1" align="left" width="20%"><b>Player Health:</b></td><td BGCOLOR="#D4C0A1" align="left">'.max($playerHealth, $playerMaxHealth).'/'.$playerMaxHealth.'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: red; width: '.$healthBarWidth.'%; height: 3px;"></td></tr>';

if ($player->getManaMax() > 0) {
    $playerMana = $player->getMana();
    $playerMaxMana = $player->getManaMax();
    $manaBarWidth = min(100, $playerMana / $playerMaxMana * 100);
    $main_content .= '<tr><td BGCOLOR="#F1E0C6" align="left"><b>Player Mana:</b></td><td BGCOLOR="#F1E0C6" align="left">'.max($playerMana, $playerMaxMana).'/'.$playerMaxMana.'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: blue; width: '.$manaBarWidth.'%; height: 3px;"></td>';
now show health / (maxhealth - maxhealthpoint)
2300/2220
health.png
 
when use items with maxhealthpoints player health in website change to be like this
View attachment 56932

and code from website
PHP:
    $hp = ($player->getHealth() / $player->getHealthMax() * 100);

                        $main_content .= '<td align=center ><table width=100%><tr><td align=center><table CELLSPACING="1" CELLPADDING="4"><tr><td BGCOLOR="#D4C0A1" align="left" width="20%"><b>Player Health:</b></td>

                                        <td BGCOLOR="#D4C0A1" align="left">'.$player->getHealth().'/'.$player->getHealthMax().'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: red; width: '.$hp.'%; height: 3px;"></td></tr>';

                        if ($player->getManaMax() > 0) {

                                $mana = ($player->getMana() / $player->getManaMax() * 100);

                                $main_content .= '<tr><td BGCOLOR="#F1E0C6" align="left"><b>Player Mana:</b></td><td BGCOLOR="#F1E0C6" align="left">'.$player->getMana().'/'.$player->getManaMax().'<div style="width: 100%; height: 3px; border: 1px solid #000;"><div style="background: blue; width: '.$mana.'%; height: 3px;"></td>';

0.4
gesior
This is problem cuz player have more hitpoints compare to how is setup as max. fix player hitpoints in database
 
Back
Top