Raised This Month: $ Target: $400
 0% 

Negative Sign on Needed Amount


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
infek
Senior Member
Join Date: May 2009
Location: Behind you
Old 07-25-2010 , 20:34   Negative Sign on Needed Amount
Reply With Quote #1

This is really bothering me I have a XP Mod and Im trying to set up how much XP they need to get an item and this is how i have it set up and for some reason this damn negative sign shows up

PHP Code:
CvarHere register_cvar("blah""500" 
PHP Code:
new exp points[id]
new 
cost get_pcvar_numCvarHere )
new 
left exp cost;
 
if( 
exp cost )
{
    
ColorChatidGREEN"[%s]^x01 You need %i more XP to buy this item!"TITLEleft);
    return 
PLUGIN_HANDLED;
   }
  } 
Well heres what i mean This is what will show up
You need -200 more XP to buy this item, lets just say it cost 500 and i have 300 it says i need -200 more
__________________
"Domo Arigato, Mr. Roboto!"
PM me if you want to know a secret
infek is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 07-25-2010 , 20:40   Re: Negative Sign on Needed Amount
Reply With Quote #2

Quote:
Originally Posted by infek View Post
This is really bothering me I have a XP Mod and Im trying to set up how much XP they need to get an item and this is how i have it set up and for some reason this damn negative sign shows up

PHP Code:
CvarHere register_cvar("blah""500" 
PHP Code:
new exp points[id]
new 
cost get_pcvar_numCvarHere )
new 
left exp cost;
 
if( 
exp cost )
{
    
ColorChatidGREEN"[%s]^x01 You need %i more XP to buy this item!"TITLEleft);
    return 
PLUGIN_HANDLED;
   }
  } 
Well heres what i mean This is what will show up
You need -200 more XP to buy this item, lets just say it cost 500 and i have 300 it says i need -200 more
< is less than
> is greater than

Also, you want to allow them to buy it if their XP is equal to the cost.

So,

PHP Code:
if( exp cost 
->
PHP Code:
if( exp >= cost 
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
infek
Senior Member
Join Date: May 2009
Location: Behind you
Old 07-25-2010 , 20:42   Re: Negative Sign on Needed Amount
Reply With Quote #3

Thanks, alot. I Already know < is less than but
PHP Code:
if( exp >= cost 
   {
    if( 
is_user_aliveid ) )
    {
     if( !
ItemUsed[id] )
     {
      
ColorChatidGREEN"[%s]^x01 You have purchased^x03 This item!"TITLE );
      
pointsid ] -= cost
      ItemUsed
[id] = true
other part
PHP Code:
   else if( exp cost )
   {
    
ColorChatidGREEN"[%s]^x01 You need %i more XP to buy This Item"TITLEleft);
    return 
PLUGIN_HANDLED;
   }
  } 
thats why i have exp < cost so if they have a less amount it'll show them they how much they need left the problem is it shows You need -Numberhere to buy this item
__________________
"Domo Arigato, Mr. Roboto!"
PM me if you want to know a secret

Last edited by infek; 07-25-2010 at 20:47.
infek is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-25-2010 , 22:58   Re: Negative Sign on Needed Amount
Reply With Quote #4

You made a simple mistake with your math, chief.

You should be using ( cost - exp ) to determine xp needed.

Example:

Cost = 500
Exp = 300

500 - 300 = 200

What you are doing:

Exp - cost

300 - 500 = -200
__________________

Last edited by Bugsy; 07-25-2010 at 23:11.
Bugsy is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-25-2010 , 23:05   Re: Negative Sign on Needed Amount
Reply With Quote #5

Exactly bugsy. Lol, common sense, the only thing that would make it negative is the subtraction. Changing the > sign won't change the value of it, it would just change who it's showed to.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
infek
Senior Member
Join Date: May 2009
Location: Behind you
Old 07-25-2010 , 23:16   Re: Negative Sign on Needed Amount
Reply With Quote #6

holy, i didnt think of the subtraction. >_< Well thanks bugsys.
__________________
"Domo Arigato, Mr. Roboto!"
PM me if you want to know a secret
infek is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode