se7enet purgatorio

Page 1 of 1 1
Topic Options
Rate This Topic
#18683 - 11/11/08 07:35 AM Making an Exp Bar
norrec
Malt-o-Meal


Registered: 10/22/08
Posts: 8

Offline
Hey,

I'm trying to make an experience bar just underneath all the other bars, and I'm stuck. Here are the arrays from panel.php

 Code:
    
    $row["hpbar"] = statusbars("hp", $userrow["currenthp"], $userrow["maxhp"]);
    $row["mpbar"] = statusbars("mp", $userrow["currentmp"], $userrow["maxmp"]);
    $row["tpbar"] = statusbars("tp", $userrow["currenttp"], $userrow["maxtp"]);
    $row["expbar"] = statusbars("exp", $userrow["experience"], $???["???"]);


HP would show for example: 34/100
I have the first value, which is $userrow["experience"]

Now I need to find the second value which is how much exp is missing until the next level.

I can't seem to find that value, I know there is one value called "Next Level" which indicates that in the extended profile page (users_profile.php) in templates, but I can't seems to find the correct $row... etc.

Could anyone help me out please?

Thanks in advance

Top
#18684 - 11/11/08 04:59 PM Re: Making an Exp Bar [Re: norrec]
AnmanIndustries
Cookie Crisp
*****

Registered: 03/21/05
Posts: 2876
Loc: Planet Stupid, AKA Earth

Offline
There is no VALUE. Its calculated by a formula. Its in several places. Im sure you can find it.
_________________________
If you want me to punch you in the nuts go to:
http://www.AnmanIndustries.com

I'll do it for free too. Enjoy.

Top
#18685 - 11/11/08 06:36 PM Re: Making an Exp Bar [Re: AnmanIndustries]
Fayt
Crunchberries
***

Registered: 11/08/05
Posts: 1131
Loc: My Computer, USA

Offline
 Code:
// Now make numbers stand out if theyre low.
		if ($userrow['currenthp'] <= ($userrow['maxhp'] / 5))
		{
			$userrow["currenthp"] = "<blink><span class=\"highlight\"><b>*" . $userrow["currenthp"] . "*</b></span></blink>";
		}


 Code:
$stattable = "<table width=\"150\"><tr><td width=\"150%\">\n";

		$stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:150px; height:5px; border:solid 1px black; vertical-align:bottom;\">\n";
		if ($stathp >= 100)
		{
			$stattable .= "<div style=\"padding:0px; width:" . $stathp . "px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>";
		}
		if ($stathp < 100 && $stathp >= 50)
		{
			$stattable .= "<div style=\"padding:0px; width:" . $stathp . "px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>";
		}
		if ($stathp < 50)
		{
			$stattable .= "<div style=\"padding:0px; width:" . $stathp . "px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>";
		}
		$stattable .= "</tr><tr><td>HP: " . $userrow["currenthp"] . " / " . $userrow["maxhp"] . "</td></tr></table>\n";



 Code:
// HP/MP/TP bars.
		$stathp = ceil($userrow['currenthp'] / $userrow['maxhp'] * 150);
		if ($userrow['maxmp'] != 0)
		{
			$statmp = ceil($userrow['currentmp'] / $userrow['maxmp'] * 150);
		}
		else
		{
			$statmp = 0;
		}
_________________________
MasterFayt - Amara 5 - Manas - Banar

Top
#18686 - 11/12/08 08:36 AM Re: Making an Exp Bar [Re: Fayt]
norrec
Malt-o-Meal


Registered: 10/22/08
Posts: 8

Offline
Hmmm well i found it... I am half way there.
------------------------------------------------

Exp for level 2 = 25 exp
Exp for level 3 = 60 exp

Let's say I'm just at level 2 so, the exp bar says: 25 / 60

25 = my current exp
60 = total exp for level 3

------------------------------

I need to make it when just reaching level 2 like: 0 / 35

0 = current exp - level 2 needed exp (25)
35 = level 3 needed exp (60) - level 2 needed exp (25)


Reason:
This makes the exp bar start from 0 and calculate the remaining exp.
If its not like this, the exp bar is pretty much useless, as it just shows the relation of two values, not on a % scale.

I think I got the formula, any one got an idea how to implement this?

Top
#18687 - 11/12/08 08:53 AM Re: Making an Exp Bar [Re: norrec]
Fayt
Crunchberries
***

Registered: 11/08/05
Posts: 1131
Loc: My Computer, USA

Offline
Right the way I have it in my game. Resets to 0 on level up
_________________________
MasterFayt - Amara 5 - Manas - Banar

Top
#18688 - 11/12/08 07:05 PM Re: Making an Exp Bar [Re: Fayt]
AnmanIndustries
Cookie Crisp
*****

Registered: 03/21/05
Posts: 2876
Loc: Planet Stupid, AKA Earth

Offline
This is simple if done properly.

$current_level = Experience needed for users current level.
$next_level = Experience needed for next level.
$needed = $next_level - $current_level
$have = $users_experience - $current_level
$percent = ($have / $needed) * 100


Your bar width is $percent.
_________________________
If you want me to punch you in the nuts go to:
http://www.AnmanIndustries.com

I'll do it for free too. Enjoy.

Top
Page 1 of 1 1


Hop to:

se7enet

Barack Obama Logo