undead mage
Active Member
So im using this code to show how much % someone has done of a quest and everything works except that if someone did like 1 of the 3 mission it shows 33.333333333333% what do I have to change to make it show 33.33%? So that it will be max 2 numbers after the .
Code:
if(isset($config['site']['quests']) && is_array($config['site']['quests']) && count($config['site']['quests']) > 0)
$id = $player->getCustomField("id");
$number_of_quests = 0;
$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD align="left" COLSPAN=2 CLASS=white><B>Quests</B></TD></TD align="right"></TD></TR>';
$questCount = 0;
foreach ($config["site"]["quests"] as $questName => $questData) {
$backgroundColor = is_int($questCount / 2) ? $config["site"]["darkborder"] : $config["site"]["lightborder"];
$questCount = $questCount + 1; $questStatus = $SQL->query("SELECT * FROM `player_storage` WHERE `player_id` = ".$id." AND `key` = ".$questData["storageid"].";")->fetch();
$questPercent = (($questStatus["value"] - $questData["startvalue"])/$questData["endvalue"]) * 100;
$main_content .= "<tr bgcolor=\"".$backgroundColor."\"><td width=\"55%\">".$questName."</td><td width=\"45%\" style=\"text-align:center;\">".$questPercent."%<div style=\"background-color:white; margin-top:-14px; width: 100%; height: 12px; border: 1px solid #DDD;\"><div style=\"background: green; width: ".$questPercent."%; height: 12px;\"></div></div></td></tr>";
}