Raised This Month: $ Target: $400
 0% 

subtracting xp help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
onfirenburnin420
Senior Member
Join Date: Jan 2005
Old 09-04-2005 , 12:22   subtracting xp help
Reply With Quote #1

can anyone help me subtract xp... the way i tryed is not working here is part of the code:
Code:
public Ammo(id) {     if (PlayerXP[id] < get_cvar_num("ammo_cost"))         {         return PLUGIN_HANDLED     }         if (PlayerXP[id] > get_cvar_num("ammo_cost"))         PlayerXP[id] - get_cvar_num("ammo_cost")     ammo[id]=true     return PLUGIN_CONTINUE }
__________________
onfirenburnin420 is offline
Send a message via AIM to onfirenburnin420
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 09-04-2005 , 12:40  
Reply With Quote #2

Code:
PlayerXP[id] -= get_cvar_num("ammo_cost")
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 09-04-2005 , 14:30  
Reply With Quote #3

There are a few things wrong with this code.

a)
Code:
if (PlayerXP[id] > get_cvar_num("ammo_cost"))
This should be >= -- after all, if something costs 200 dollars and you have 200 dollars you should be able to buy it instead of requiring 201 dollars.

b)
Code:
PlayerXP[id] - get_cvar_num("ammo_cost")
As pointed out, this should be -= -- that actually assigns a value instead of returning one. Currently it would be like having a line that reads "4;", it doesn't do anything.

c)
Code:
if (PlayerXP[id] > get_cvar_num("ammo_cost"))     PlayerXP[id] - get_cvar_num("ammo_cost") ammo[id]=true
While technically at this point the user should be cleared for buying ammo, the ammo[id]=true statement should be included in your if statement. Or, just remove the if statement entirely.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
onfirenburnin420
Senior Member
Join Date: Jan 2005
Old 09-04-2005 , 17:35  
Reply With Quote #4

thank you <3
__________________
onfirenburnin420 is offline
Send a message via AIM to onfirenburnin420
Reply



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 14:19.


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