Fixed CS_GetWeaponPrice for some weapon (bug 4994, r=psychonic).

This commit is contained in:
Drifter 2011-07-14 12:57:18 -04:00
parent a65239a8af
commit 6046b8fb79
3 changed files with 19 additions and 2 deletions

View File

@ -44,6 +44,13 @@
int CallPriceForward(int client, const char *weapon_name, int price); int CallPriceForward(int client, const char *weapon_name, int price);
#define WEAPON_C4 6
#define WEAPON_KNIFE 28
#define WEAPON_SHIELD 30
#define WEAPON_KEVLAR 31
#define WEAPON_ASSAULTSUIT 32
#define WEAPON_NIGHTVISION 33
/** /**
* @brief Sample implementation of the SDK Extension. * @brief Sample implementation of the SDK Extension.
* Note: Uncomment one of the pre-defined virtual functions in order to use it. * Note: Uncomment one of the pre-defined virtual functions in order to use it.

View File

@ -327,6 +327,16 @@ static cell_t CS_GetTranslatedWeaponAlias(IPluginContext *pContext, const cell_t
} }
static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params) static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params)
{ {
//Hard code return values for weapons that dont call GetWeaponPrice and always use default value.
if (params[2] == WEAPON_C4 || params[2] == WEAPON_KNIFE || params[2] == WEAPON_SHIELD)
return 0;
if (params[2] == WEAPON_KEVLAR)
return 650;
if (params[2] == WEAPON_ASSAULTSUIT)
return 1000;
if (params[2] == WEAPON_NIGHTVISION)
return 1250;
static ICallWrapper *pWrapper = NULL; static ICallWrapper *pWrapper = NULL;
static int priceOffset = -1; static int priceOffset = -1;
if (!pWrapper) if (!pWrapper)

View File

@ -212,9 +212,9 @@ native CS_DropWeapon(client, weaponIndex, bool:toss, bool:blockhook = false);
* @return Returns price of the weapon (even if modified) * @return Returns price of the weapon (even if modified)
* *
* @error Invalid client, failing to get weapon info, or failing to get price offset. * @error Invalid client, failing to get weapon info, or failing to get price offset.
* @note Not all "weapons" will return their default price. Example: c4, knife, vest, vest helmet, night vision. * @note c4, knife and shield will always return 0. vest, vest helmet and night vision will always return default price.
*/ */
native CS_GetWeaponPrice(client, CSWeaponID:id, bool:defaultprice=false); native CS_GetWeaponPrice(client, CSWeaponID:id, bool:defaultprice = false);
/** /**
* Do not edit below this line! * Do not edit below this line!