Jump to content
MakeWebGames

Energy problem


jamboy1

Recommended Posts

Hello!

i understand how to make energy so it reaches 100, i have to problems regarding this.

My problems are:

I would like 150 energy bar for donators (that goes back to 100 when donatorship has finished)

And i also havn't figured out where to put the division in the gym. so with 100 energy, you'll train 100 times, rather than 10 times, could someone give me the division to this please? i'd apretiate any help given.

Link to comment
Share on other sites

Re: Energy problem

it would all depend on how you made it go to 150

but if you done it how i think and i would have you would have added somethign to the users table like

150bar

and if the 150 = 1 then there energy is 150%

and if the 150 = 0 then there energy is 100%

if its that then put in your day cron

 

mysql_query("UPDATE users SET 150bar = 0 WHERE donatordays < 1");

 

If you didnt do it that way....please explain how you did and i will gladly help...

Of course the 150bar is an example if you did it that way you probarly called it something else if so just change the 150bar to whatever you called it..

Hope this helps :mrgreen:

Link to comment
Share on other sites

Re: Energy problem

It was in the header, i updated users to 100 energy, then in the header it was something like

if donatordays = >0 energy = 100

if donatordays = >1 energy equals 150

i can't remember what exactly it was though.

Link to comment
Share on other sites

Re: Energy problem

lol, I'm confussed now......You don't know how you did it?

You don't ahve to say I understand you want to protect your code I was just giving an idea of how to do it if you where to have done it that way...

From what I understand your way will not work...

A players energy is not a % its a number when there level goes up the number goes up...I think at level one there energy in the database is 12 so for yours to work it would have to be 18 but I dont know but figure as they level it would give you errors..

Link to comment
Share on other sites

Re: Energy problem

No it's different!

 

function check_level()
{
global $db;
global $ir,$c,$userid;
$ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*17.5);
if($ir['exp'] >= $ir['exp_needed'])
{
$expu=$ir['exp']-$ir['exp_needed'];
$ir['level']+=1;
$ir['exp']=$expu;
$ir['energy']+=0;
$ir['brave']+=0;
$ir['maxenergy']+=0;
$ir['maxbrave']+=0;
$ir['hp']+=100;
$ir['maxhp']+=100;
$ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*17.5);
$db->query("UPDATE users SET level=level+1,exp=$expu,
hp=hp+0,maxhp=maxhp+100 where userid=$userid");
}
}

 

also in register i set energy and max energy to 10, so.

in this code here, i'm made energy and brave to never go up when leveling, and i have also changed the max health to go up 100 per level, all i need right now is the code in gym to devide the amount of energy into a certain amount of trains

Link to comment
Share on other sites

  • 6 months later...

Re: Energy problem

probably not the best way but a work around...

adding a new field to users table "donatormaxenergy" to override "maxenergy" if donatordays > 0

and adding a new line to cron in these guides

UPDATE users SET energy=energy+(donatormaxenergy/(whatever)) WHERE energy<donatormaxenergy AND donatordays>0

... this is just a guide, i don't even know if something on these lines would work, though probably i will, and as of energy usage on other places such as gym... you only need to add a few lines to update energy accordingly, as "energy" field is the same

Link to comment
Share on other sites

Re: Energy problem

There is no point of adding an extra query that is gonna be doing nothing. Do what i said in the previous post, then to display it try something like this

 

echo '[b]Energy:[/b] '.$ir['energy'].' / '.$ir['maxenergy'].
'<div style="height:5px:background:#900;padding:0;width:150px;">'.
'<div style="height:5px:background:#090;width:'.floor(($ir['energy'] / $ir['maxenergy']) * 100).'%"></div></div>'; 
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...