Jump to content
MakeWebGames

Recommended Posts

Posted

Hi everyone, I'm wondering can anyone help me on this small setup please?

Say you have 100,000 strength and you purchase a stat increasment of 0.2, how can you add that 0.2 as a % on top of the 100,000 strength?

so you'll get 100,200 strength but then say you train your strength at a gym and gain 524 strength and come out with 100,524 (oringal stat). you'll still then get the 0.2% extra strength on top and your strength will become... 100,725 strength...

if you understand what i mean, please can you help me out on this little bit please on how to set this up?

____________________________________________________

these are the stats codes

 

".$stat['strength']."
".$stat['strength_extra']."

 

this is the table field

 

CREATE TABLE IF NOT EXISTS `player_stats` (
 `userid` int(11) NOT NULL default '0',
 `strength` decimal(50,4) NOT NULL default '0.0000',
 `strength_extra` decimal(5,1) NOT NULL default '0.0',
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

____________________________________________________

Posted
It would be something along the lines of:

".$stat['strength_extra']." = (".$stat['strength'].") * 1.02

not quite sure what you mean. but i tried

".number_format($stat['strength_extra'] = $stat['strength'] * 1.02)."

but it just dropped my strength down from 264,600 to 269. ($stat['strength_extra'] value is 0.2 on my user) but wanna change that 0.2 into a addon percentage (%).

Posted
not quite sure what you mean. but i tried

".number_format($stat['strength_extra'] = $stat['strength'] * 1.02)."

but it just dropped my strength down from 264,600 to 269. ($stat['strength_extra'] value is 0.2 on my user) but wanna change that 0.2 into a addon percentage (%).

Not sure but I think you need more brackets there ... try this.

".number_format($stat['strength_extra']) = ($stat['strength'] * 1.02)."

Or define your variable as;

$strength_extra=($strength * 1.02)

Posted (edited)

Are you meaning to have that stat effect at all times? and not just add 0.2% once?

If your trying to accomplish this you need to make the item equipped-able,like a weapon...

because if the user takes the item, it just adds 0.2% to that particular stat once...

You would also have to add the calculation from that item equipped to where the stats show, and add calculations to the attack pages also.

Edited by lucky3809
Posted

When are you using this “extra” part of the stat? It would make more sense that you change the attack formula to take it into account, and leave the gym alone altogether, that is assuming you're buying the stat somewhere else...

Posted (edited)
Are you meaning to have that stat effect at all times? and not just add 0.2% once?

If your trying to accomplish this you need to make the item equipped-able,like a weapon...

because if the user takes the item, it just adds 0.2% to that particular stat once...

You would also have to add the calculation from that item equipped to where the stats show, and add calculations to the attack pages also.

yes, it will stay on forever. When you purchase the 0.2 value for the $stat['strength_extra'] it will well make the value 0.2% extra stats. But then you can purchase another 0.2 when you get the requirements and then you'll have 0.4% extra.

I wont need to edit the items at all, as its nothing to do with that type of thing.

 

$extra = ($ir['strength']/100)*0.2; // 0.2 % of current strength as a bonus.

$newStr = $ir['strength'] + $extra; // Normal strength plus the bonus strength.

I tried that but didnt work. :(

$extra = ($stat['strength'])*$stat['strength_extra']; // strength_extra value is 0 until purchasing the 0.2 and etc.

$newStr = $stat['strength'] + $extra;

".number_format($newStr)." // for stat display.

any chance you could try different method to help me out at all please?

Edited by crimecreation
Posted
yes, it will stay on forever. When you purchase the 0.2 value for the $stat['strength_extra'] it will well make the value 0.2% extra stats. But then you can purchase another 0.2 when you get the requirements and then you'll have 0.4% extra.

I wont need to edit the items at all, as its nothing to do with that type of thing.

I tried that but didnt work. :(

$extra = ($stat['strength'])*$stat['strength_extra']; // strength_extra value is 0 until purchasing the 0.2 and etc.

$newStr = $stat['strength'] + $extra;

".number_format($newStr)." // for stat display.

any chance you could try different method to help me out at all please?

It would work surely,

okay lets do it this way.

if ($stat['strength_extra'] > 0) { 
   $extra = ($stat['strength']/100)*$stat['strength_extra'];
   $stat['strength'] += $extra;
   echo number_format ($stat['strength']);
  //Query to update the new strength should you wish to do so.
}
Posted

$extra = ((($stat['strength']/100)*$stat['strength_extra'])+$stat['strength']);

This will give you the result

Initial strength = 270,600

Final strength with a bonus of 0.2 = 271,141

Posted
$extra = ((($stat['strength']/100)*$stat['strength_extra'])+$stat['strength']);

This will give you the result

Initial strength = 270,600

Final strength with a bonus of 0.2 = 271,141

if ($stat['strength_extra'] > 0) {

$extra = ((($stat['strength']/100)*$stat['strength_extra'])+$stat['strength']);

$stat['strength'] += $extra;

echo number_format ($stat['strength']);

}

it didnt work either :( this is quite hard to figure out lol.

270,600 to 541. didnt add that number on top of the stat.

it just shows the number thats meant to add on top of it.

any ideas?

Posted (edited)

I bet if you echo $extra it will be correct :P

if ($stat['strength_extra'] > 0) {

$extra = ((($stat['strength']/100)*$stat['strength_extra'])+$stat['strength']);

echo number_format ($extra);

}

Edited by rulerofzu
Posted
I bet if you echo $extra it will be correct :P

if ($stat['strength_extra'] > 0) {

$extra = ((($stat['strength']/100)*$stat['strength_extra'])+$stat['strength']);

echo number_format ($extra);

}

nope didnt work either goes from 270,600 to 271. lol.

Posted

Your getting 271 just 271? Not 271,141 which is what that produces (tested).

Run this

$strength=270600;

$bonus=0.2;

if ($strength > 0) {

$extra = ((($strength/100)*$bonus)+$strength);

$newstr += $extra;

echo number_format ($newstr);

//Query to update the new strength should you wish to do so.

}

If you only get 271 instead of 271,141 then something is wrong elsewhere

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...