vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Subtraction code not doing as it should (https://vborg.vbsupport.ru/showthread.php?t=37529)

Shroomboy 04-17-2002 04:33 AM

Subtraction code not doing as it should
 
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
PHP Code:

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

and for the subtraction I used
PHP Code:

$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

Quote:

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


All times are GMT. The time now is 08:40 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01041 seconds
  • Memory Usage 1,718KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete