PDA

View Full Version : Subtraction code not doing as it should


Shroomboy
04-17-2002, 04:33 AM
Ok I am making a hack and the code adds/subtracts numbers due to buying/selling... Well when an item is bought eh numbers are added which is this code

$newhp = ($hpfield + $hp);
$newmp = ($mpfield + $mp);

and for the subtraction I used
$newhp = ($hpfield - $hp);
$newmp = ($mpfield - $mp);

but instead of it going back to zero it makes the number negative... like lets say $hpfield + $hp = 30 when i use the subtraction the number becomes -30... i know the problem is with the "-" I think... this is my first attempt at a hack... oh and BTW it is an EXP hack taht is intragrated with the itemshop to give your HP/MP and like 7 more compared to what weapon you buy...

Neo
04-17-2002, 05:04 AM
Now this is not a code problem.. this is a simple math problem. Now in school you learn that if you subtract a small value from a larger value you will in turn get a negative value. But if you subtract a large value from a smaller value you will in trun get a postivie value.

example:

3 - 60 = -57
60 - 3 = 57

so do you get how to do it now?

Admin
04-17-2002, 08:07 AM
Originally posted by neo
Now in school you learn that if you subtract a small value from a larger value you will in turn get a negative value. But if you subtract a large value from a smaller value you will in trun get a postivie value.
If you substract a small value from a larger value you get a positive number, neo. (10 - 6 = 4)

Shroomboy
04-17-2002, 08:15 AM
well i have tryed it both ways... and it still caused problems... ah someday I iwll figure it out...