Cstrike: Add cs_is_valid_itemid() stock
This commit is contained in:
parent
75853dae60
commit
2c5cc4289e
|
@ -11,7 +11,7 @@
|
|||
// Counter-Strike Module
|
||||
//
|
||||
|
||||
#include "CstrikeitemsInfos.h"
|
||||
#include "CstrikeItemsInfos.h"
|
||||
|
||||
CsItemInfo ItemsManager;
|
||||
|
||||
|
|
|
@ -1096,15 +1096,23 @@ stock CsWeaponClassType:cs_get_weapon_class(weapon_id)
|
|||
{
|
||||
new CsWeaponClassType:type = CS_WEAPONCLASS_NONE;
|
||||
|
||||
if (CSI_NONE <= weapon_id <= CSI_LAST_WEAPON || weapon_id == CSI_SHIELDGUN || weapon_id == CSI_SHIELD)
|
||||
if (cs_is_valid_itemid(weapon_id, .weapon_only = true) || weapon_id == CSI_SHIELD)
|
||||
{
|
||||
new const bits = (1 << weapon_id);
|
||||
|
||||
if (bits & (1 << CSI_KNIFE))
|
||||
switch (weapon_id)
|
||||
{
|
||||
case CSI_SHIELDGUN, CSI_SHIELD:
|
||||
{
|
||||
type = CS_WEAPONCLASS_PISTOL;
|
||||
}
|
||||
case CSI_KNIFE:
|
||||
{
|
||||
type = CS_WEAPONCLASS_KNIFE;
|
||||
}
|
||||
else if(bits & CSI_ALL_PISTOLS || weapon_id == CSI_SHIELDGUN || weapon_id == CSI_SHIELD)
|
||||
default:
|
||||
{
|
||||
new const bits = (1 << weapon_id);
|
||||
|
||||
if(bits & CSI_ALL_PISTOLS)
|
||||
{
|
||||
type = CS_WEAPONCLASS_PISTOL;
|
||||
}
|
||||
|
@ -1133,10 +1141,41 @@ stock CsWeaponClassType:cs_get_weapon_class(weapon_id)
|
|||
type = CS_WEAPONCLASS_SNIPERRIFLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether an item id is not out of bounds.
|
||||
*
|
||||
* @param id Item id (CSI_* constants)
|
||||
* @param weapon_only If true, only the real weapon ids will be checked,
|
||||
* including shield as well
|
||||
*
|
||||
* @return True if item id is valid, false otherwise
|
||||
*/
|
||||
stock bool:cs_is_valid_itemid(id, bool:weapon_only = false)
|
||||
{
|
||||
if (id <= CSI_NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (id > CSI_LAST_WEAPON && id != CSI_SHIELDGUN && weapon_only)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (id >= CSI_MAX_COUNT)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when CS internally fires a command to a player.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user