crimecreation Posted April 7, 2011 Posted April 7, 2011 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; ____________________________________________________ Quote
skizzy Posted April 8, 2011 Posted April 8, 2011 I Don't know the exact code but it would have something to do with you gym code Quote
newttster Posted April 8, 2011 Posted April 8, 2011 It would be something along the lines of: ".$stat['strength_extra']." = (".$stat['strength'].") * 1.02 Quote
crimecreation Posted April 8, 2011 Author Posted April 8, 2011 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 (%). Quote
skizzy Posted April 8, 2011 Posted April 8, 2011 crime which is basic math 254,600 * 1.02 = 269,892 Quote
newttster Posted April 8, 2011 Posted April 8, 2011 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) Quote
lucky3809 Posted April 8, 2011 Posted April 8, 2011 (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 April 8, 2011 by lucky3809 Quote
Dominion Posted April 8, 2011 Posted April 8, 2011 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... Quote
Djkanna Posted April 9, 2011 Posted April 9, 2011 $extra = ($ir['strength']/100)*0.2; // 0.2 % of current strength as a bonus. $newStr = $ir['strength'] + $extra; // Normal strength plus the bonus strength. Quote
crimecreation Posted April 10, 2011 Author Posted April 10, 2011 (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 April 10, 2011 by crimecreation Quote
Djkanna Posted April 10, 2011 Posted April 10, 2011 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. } Quote
crimecreation Posted April 10, 2011 Author Posted April 10, 2011 didnt work either :( my strength just went from 270,600 to 271. cant figure this out lol. sorry if im bugging you on this. Quote
rulerofzu Posted April 10, 2011 Posted April 10, 2011 $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 Quote
crimecreation Posted April 10, 2011 Author Posted April 10, 2011 $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? Quote
rulerofzu Posted April 10, 2011 Posted April 10, 2011 (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 April 10, 2011 by rulerofzu Quote
crimecreation Posted April 10, 2011 Author Posted April 10, 2011 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. Quote
rulerofzu Posted April 10, 2011 Posted April 10, 2011 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 Quote
crimecreation Posted April 10, 2011 Author Posted April 10, 2011 cheers think ive got it now :) that was hard work lol. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.