AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   subtracting xp help (https://forums.alliedmods.net/showthread.php?t=17583)

onfirenburnin420 09-04-2005 12:22

subtracting xp help
 
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 }

Xanimos 09-04-2005 12:40

Code:
PlayerXP[id] -= get_cvar_num("ammo_cost")

XxAvalanchexX 09-04-2005 14:30

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.

onfirenburnin420 09-04-2005 17:35

thank you <3


All times are GMT -4. The time now is 14:19.

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