1.1 --- a/extensions/cstrike/natives.cpp Wed Jul 31 22:08:23 2013 -0400
1.2 +++ b/extensions/cstrike/natives.cpp Wed Jul 31 22:11:15 2013 -0400
1.3 @@ -296,6 +296,9 @@
1.4
1.5 static cell_t CS_WeaponIDToAlias(IPluginContext *pContext, const cell_t *params)
1.6 {
1.7 + if (!IsValidWeaponID(params[1]))
1.8 + return pContext->ThrowNativeError("Invalid WeaponID passed for this game");
1.9 +
1.10 char *dest;
1.11
1.12 pContext->LocalToString(params[2], &dest);
1.13 @@ -326,8 +329,8 @@
1.14
1.15 static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params)
1.16 {
1.17 - if (params[2] == (int)SMCSWeapon_NONE)
1.18 - return pContext->ThrowNativeError("Invalid Weapon ID passed");
1.19 + if (!IsValidWeaponID(params[2]))
1.20 + return pContext->ThrowNativeError("Invalid WeaponID passed for this game");
1.21
1.22 int id = GetRealWeaponID(params[2]);
1.23
1.24 @@ -466,7 +469,12 @@
1.25
1.26 pContext->LocalToString(params[1], &weapon);
1.27
1.28 - return GetFakeWeaponID(AliasToWeaponID(weapon));
1.29 + int id = GetFakeWeaponID(AliasToWeaponID(weapon));
1.30 +
1.31 + if (!IsValidWeaponID(id))
1.32 + return SMCSWeapon_NONE;
1.33 +
1.34 + return id;
1.35 }
1.36
1.37 static cell_t CS_SetTeamScore(IPluginContext *pContext, const cell_t *params)
1.38 @@ -603,6 +611,11 @@
1.39 return pContext->ThrowNativeError("Invalid team index passed (%i).", params[1]);
1.40 }
1.41
1.42 +static cell_t CS_IsValidWeaponID(IPluginContext *pContext, const cell_t *params)
1.43 +{
1.44 + return IsValidWeaponID(params[1]) ? 1 : 0;
1.45 +}
1.46 +
1.47 template <typename T>
1.48 static inline T *GetPlayerVarAddressOrError(const char *pszGamedataName, IPluginContext *pContext, CBaseEntity *pPlayerEntity)
1.49 {
1.50 @@ -755,6 +768,7 @@
1.51 {"CS_SetClientContributionScore", CS_SetClientContributionScore},
1.52 {"CS_GetClientAssists", CS_GetClientAssists},
1.53 {"CS_SetClientAssists", CS_SetClientAssists},
1.54 + {"CS_IsValidWeaponID", CS_IsValidWeaponID},
1.55 {NULL, NULL}
1.56 };
1.57