Add cs_get_item_alias() native & cleanup alias datas

This commit is contained in:
Arkshine 2016-01-24 19:29:09 +01:00
parent 664c25bdac
commit c3a52b366e
8 changed files with 165 additions and 233 deletions

View File

@ -144,12 +144,17 @@
{ {
"ItemInfos" "ItemInfos"
{ {
"CommonAlias" "BuyAliases"
{ {
//
// Weapon
//
"p228" "p228"
{ {
"itemid" "1" // CSW/I_P228 "itemid" "1" // CSW/I_P228
"classid" "2" // CS_WEAPONCLASS_PISTOL "classid" "2" // CS_WEAPONCLASS_PISTOL
"altname" "228compact"
} }
"scout" "scout"
{ {
@ -160,6 +165,7 @@
{ {
"itemid" "5" // CSW/I_XM1014 "itemid" "5" // CSW/I_XM1014
"classid" "5" // CS_WEAPONCLASS_SHOTGUN "classid" "5" // CS_WEAPONCLASS_SHOTGUN
"altname" "autoshotgun"
} }
"mac10" "mac10"
{ {
@ -170,244 +176,123 @@
{ {
"itemid" "8" // CSW/I_AUG "itemid" "8" // CSW/I_AUG
"classid" "7" // CS_WEAPONCLASS_RIFLE "classid" "7" // CS_WEAPONCLASS_RIFLE
"altname" "bullpup"
} }
"elites" "elites"
{ {
"itemid" "10" // CSW/I_ELITE "itemid" "10" // CSW/I_ELITE
"classid" "2" // CS_WEAPONCLASS_PISTOL "classid" "2" // CS_WEAPONCLASS_PISTOL
} }
"fn57" "fn57"
{ {
"itemid" "11" // CSW/I_FIVESEVEN "itemid" "11" // CSW/I_FIVESEVEN
"classid" "2" // CS_WEAPONCLASS_PISTOL "classid" "2" // CS_WEAPONCLASS_PISTOL
"altname" "fiveseven"
} }
"ump45" "ump45"
{ {
"itemid" "12" // CSW/I_UMP45 "itemid" "12" // CSW/I_UMP45
"classid" "4" // CS_WEAPONCLASS_SUBMACHINEGUN "classid" "4" // CS_WEAPONCLASS_SUBMACHINEGUN
} }
"sg550" "sg550"
{ {
"itemid" "13" // CSW/I_SG550 "itemid" "13" // CSW/I_SG550
"classid" "8" // CS_WEAPONCLASS_SNIPERRIFLE "classid" "8" // CS_WEAPONCLASS_SNIPERRIFLE
"altname" "krieg550"
} }
"galil" "galil"
{ {
"itemid" "14" // CSW/I_GALIL "itemid" "14" // CSW/I_GALIL
"classid" "7" // CS_WEAPONCLASS_RIFLE "classid" "7" // CS_WEAPONCLASS_RIFLE
"altname" "defender"
} }
"famas" "famas"
{ {
"itemid" "15" // CSW/I_FAMAS "itemid" "15" // CSW/I_FAMAS
"classid" "7" // CS_WEAPONCLASS_RIFLE "classid" "7" // CS_WEAPONCLASS_RIFLE
"altname" "clarion"
} }
"usp" "usp"
{ {
"itemid" "16" // CSW/I_USP "itemid" "16" // CSW/I_USP
"classid" "2" // CS_WEAPONCLASS_PISTOL "classid" "2" // CS_WEAPONCLASS_PISTOL
"altname" "km45"
} }
"glock" "glock"
{ {
"itemid" "17" // CSW/I_GLOCK18 "itemid" "17" // CSW/I_GLOCK18
"classid" "2" // CS_WEAPONCLASS_PISTOL "classid" "2" // CS_WEAPONCLASS_PISTOL
"altname" "9x19mm"
} }
"awp" "awp"
{ {
"itemid" "18" // CSW/I_AWP "itemid" "18" // CSW/I_AWP
"classid" "8" // CS_WEAPONCLASS_SNIPERRIFLE "classid" "8" // CS_WEAPONCLASS_SNIPERRIFLE
"altname" "magnum"
} }
"mp5" "mp5"
{ {
"itemid" "19" // CSW/I_MP5NAVY "itemid" "19" // CSW/I_MP5NAVY
"classid" "4" // CS_WEAPONCLASS_SUBMACHINEGUN "classid" "4" // CS_WEAPONCLASS_SUBMACHINEGUN
"altname" "smg"
} }
"m249" "m249"
{ {
"itemid" "20" // CSW/I_M249 "itemid" "20" // CSW/I_M249
"classid" "6" // CS_WEAPONCLASS_MACHINEGUN "classid" "6" // CS_WEAPONCLASS_MACHINEGUN
} }
"m3" "m3"
{ {
"itemid" "21" // CSW/I_M3 "itemid" "21" // CSW/I_M3
"classid" "5" // CS_WEAPONCLASS_SHOTGUN "classid" "5" // CS_WEAPONCLASS_SHOTGUN
"altname" "12gauge"
} }
"m4a1" "m4a1"
{ {
"itemid" "22" // CSW/I_M4A1 "itemid" "22" // CSW/I_M4A1
"classid" "7" // CS_WEAPONCLASS_RIFLE "classid" "7" // CS_WEAPONCLASS_RIFLE
} }
"tmp" "tmp"
{ {
"itemid" "23" // CSW/I_TMP "itemid" "23" // CSW/I_TMP
"classid" "4" // CS_WEAPONCLASS_SUBMACHINEGUN "classid" "4" // CS_WEAPONCLASS_SUBMACHINEGUN
"altname" "mp"
} }
"g3sg1" "g3sg1"
{ {
"itemid" "24" // CSW/I_G3SG1 "itemid" "24" // CSW/I_G3SG1
"classid" "8" // CS_WEAPONCLASS_SNIPERRIFLE "classid" "8" // CS_WEAPONCLASS_SNIPERRIFLE
"altname" "d3au1"
} }
"deagle" "deagle"
{ {
"itemid" "26" // CSW/I_DEAGLE "itemid" "26" // CSW/I_DEAGLE
"classid" "2" // CS_WEAPONCLASS_PISTOL "classid" "2" // CS_WEAPONCLASS_PISTOL
"altname" "nighthawk"
} }
"sg552" "sg552"
{ {
"itemid" "27" // CSW/I_SG552 "itemid" "27" // CSW/I_SG552
"classid" "7" // CS_WEAPONCLASS_RIFLE "classid" "7" // CS_WEAPONCLASS_RIFLE
"altname" "krieg552"
} }
"ak47" "ak47"
{ {
"itemid" "28" // CSW/I_AK47 "itemid" "28" // CSW/I_AK47
"classid" "7" // CS_WEAPONCLASS_RIFLE "classid" "7" // CS_WEAPONCLASS_RIFLE
"altname" "cv47"
} }
"p90" "p90"
{ {
"itemid" "30" // CSW/I_P90 "itemid" "30" // CSW/I_P90
"classid" "4" // CS_WEAPONCLASS_SUBMACHINEGUN "classid" "4" // CS_WEAPONCLASS_SUBMACHINEGUN
"altname" "c90"
} }
"fiveseven"
{
"itemid" "11" // CSW/I_FIVESEVEN
"classid" "2" // CS_WEAPONCLASS_PISTOL
}
}
"WeaponAlias" //
{ // Equipment
"grenade" //
{
"itemid" "4" // CSW/I_HEGRENADE
"classid" "3" // CS_WEAPONCLASS_GRENADE
}
"hegrenade"
{
"itemid" "4" // CSW/I_HEGRENADE
"classid" "3" // CS_WEAPONCLASS_GRENADE
}
"c4"
{
"itemid" "6" // CSW/I_C4
"classid" "3" // CS_WEAPONCLASS_GRENADE
}
"elite"
{
"itemid" "10" // CSW/I_ELITE
"classid" "2" // CS_WEAPONCLASS_PISTOL
}
"glock18"
{
"itemid" "17" // CSW/I_GLOCK18
"classid" "2" // CS_WEAPONCLASS_PISTOL
}
"mp5navy"
{
"itemid" "19" // CSW/I_MP5NAVY
"classid" "4" // CS_WEAPONCLASS_SUBMACHINEGUN
}
"knife"
{
"itemid" "29" // CSW/I_KNIFE
"classid" "1" // CS_WEAPONCLASS_KNIFE
}
}
"BuyAlias"
{
"228compact"
{
"itemid" "1" // CSW/I_P228
"classid" "2" // CS_WEAPONCLASS_PISTOL
}
"autoshotgun"
{
"itemid" "5" // CSW/I_XM1014
"classid" "5" // CS_WEAPONCLASS_SHOTGUN
}
"bullpup"
{
"itemid" "8" // CSW/I_AUG
"classid" "7" // CS_WEAPONCLASS_RIFLE
}
"sg550"
{
"itemid" "13" // CSW/I_SG550
"classid" "7" // CS_WEAPONCLASS_RIFLE
}
"krieg550"
{
"itemid" "13" // CSW/I_SG550
"classid" "7" // CS_WEAPONCLASS_RIFLE
}
"defender"
{
"itemid" "14" // CSW/I_GALIL
"classid" "7" // CS_WEAPONCLASS_RIFLE
}
"clarion"
{
"itemid" "15" // CSW/I_FAMAS
"classid" "7" // CS_WEAPONCLASS_RIFLE
}
"km45"
{
"itemid" "16" // CSW/I_USP
"classid" "2" // CS_WEAPONCLASS_PISTOL
}
"9x19mm"
{
"itemid" "17" // CSW/I_GLOCK18
"classid" "2" // CS_WEAPONCLASS_PISTOL
}
"magnum"
{
"itemid" "18" // CSW/I_AWP
"classid" "8" // CS_WEAPONCLASS_SNIPERRIFLE
}
"smg"
{
"itemid" "19" // CSW/I_MP5NAVY
"classid" "4" // CS_WEAPONCLASS_SUBMACHINEGUN
}
"12gauge"
{
"itemid" "21" // CSW/I_M3
"classid" "5" // CS_WEAPONCLASS_SHOTGUN
}
"mp"
{
"itemid" "23" // CSW/I_TMP
"classid" "4" // CS_WEAPONCLASS_SUBMACHINEGUN
}
"d3au1"
{
"itemid" "24" // CSW/I_G3SG1
"classid" "8" // CS_WEAPONCLASS_SNIPERRIFLE
}
"nighthawk"
{
"itemid" "26" // CSW/I_DEAGLE
"classid" "2" // CS_WEAPONCLASS_PISTOL
}
"krieg552"
{
"itemid" "27" // CSW/I_SG552
"classid" "7" // CS_WEAPONCLASS_RIFLE
}
"cv47"
{
"itemid" "28" // CSW/I_AK47
"classid" "7" // CS_WEAPONCLASS_RIFLE
}
"c90"
{
"itemid" "30" // CSW/I_P90
"classid" "4" // CS_WEAPONCLASS_SUBMACHINEGUN
}
}
"BuyEquipAlias"
{
"hegren" "hegren"
{ {
"itemid" "4" // CSW/I_HEGRENADE "itemid" "4" // CSW/I_HEGRENADE
@ -455,25 +340,20 @@
"classid" "2" // CS_WEAPONCLASS_PISTOL "classid" "2" // CS_WEAPONCLASS_PISTOL
"classname" "weapon_shield" "classname" "weapon_shield"
} }
}
"BuyAmmoAlias" //
{ // Ammunition
//
"primammo" "primammo"
{ {
"itemid" "36" // CSI_PRIAMMO "itemid" "36" // CSI_PRIAMMO
"altname" "buyammo1"
} }
"secammo" "secammo"
{ {
"itemid" "37" // CSI_SECAMMO "itemid" "37" // CSI_SECAMMO
} "altname" "buyammo2"
"buyammo1"
{
"itemid" "36" // CSI_PRIAMMO
}
"buyammo2"
{
"itemid" "37" // CSI_SECAMMO
} }
} }
} }

View File

@ -19,6 +19,7 @@
*/ */
#define CSI_NONE CSW_NONE #define CSI_NONE CSW_NONE
#define CSI_P228 CSW_P228 #define CSI_P228 CSW_P228
#define CSI_GLOCK CSW_GLOCK // Unused by game
#define CSI_SCOUT CSW_SCOUT #define CSI_SCOUT CSW_SCOUT
#define CSI_HEGRENADE CSW_HEGRENADE #define CSI_HEGRENADE CSW_HEGRENADE
#define CSI_XM1014 CSW_XM1014 #define CSI_XM1014 CSW_XM1014
@ -73,6 +74,7 @@
*/ */
#define CSW_NONE 0 #define CSW_NONE 0
#define CSW_P228 1 #define CSW_P228 1
#define CSW_GLOCK 2 // Unused by game
#define CSW_SCOUT 3 #define CSW_SCOUT 3
#define CSW_HEGRENADE 4 #define CSW_HEGRENADE 4
#define CSW_XM1014 5 #define CSW_XM1014 5

View File

@ -162,7 +162,7 @@ DETOUR_DECL_STATIC1(C_ClientCommand, void, edict_t*, pEdict) // void ClientComma
UTIL_StringToLower(command, commandLowered, sizeof(commandLowered)); UTIL_StringToLower(command, commandLowered, sizeof(commandLowered));
if (ItemsManager.GetAliasInfosFromBuy(commandLowered, &info)) if (ItemsManager.GetAliasInfos(commandLowered, &info))
{ {
CurrentItemId = info.itemid; CurrentItemId = info.itemid;
} }

View File

@ -24,7 +24,6 @@ char WeaponNameList[MAX_WEAPONS][64];
CsItemInfo::CsItemInfo() CsItemInfo::CsItemInfo()
: :
m_ParseState(PSTATE_ALIASES_TYPE), m_ParseState(PSTATE_ALIASES_TYPE),
m_List(nullptr),
m_ListsRetrievedFromConfig(false) m_ListsRetrievedFromConfig(false)
{} {}
@ -35,9 +34,8 @@ CsItemInfo::~CsItemInfo()
void CsItemInfo::Clear() void CsItemInfo::Clear()
{ {
m_CommonAliasesList.clear();
m_WeaponAliasesList.clear();
m_BuyAliasesList.clear(); m_BuyAliasesList.clear();
m_BuyAliasesAltList.clear();
} }
bool CsItemInfo::HasConfigError() bool CsItemInfo::HasConfigError()
@ -51,33 +49,15 @@ SMCResult CsItemInfo::ReadSMC_NewSection(const SMCStates *states, const char *na
{ {
case PSTATE_ALIASES_TYPE: case PSTATE_ALIASES_TYPE:
{ {
m_List = nullptr; if (!strcmp(name, "BuyAliases"))
if (!strcmp(name, "CommonAlias"))
{
m_List = &m_CommonAliasesList;
}
else if (!strcmp(name, "WeaponAlias"))
{
m_List = &m_WeaponAliasesList;
}
else if (!strcmp(name, "BuyAlias") || !strcmp(name, "BuyEquipAlias") || !strcmp(name, "BuyAmmoAlias"))
{
m_List = &m_BuyAliasesList;
}
if (m_List)
{ {
m_ParseState = PSTATE_ALIASES_ALIAS; m_ParseState = PSTATE_ALIASES_ALIAS;
} }
break; break;
} }
case PSTATE_ALIASES_ALIAS: case PSTATE_ALIASES_ALIAS:
{ {
m_AliasInfo.clear();
m_Alias = name; m_Alias = name;
m_ParseState = PSTATE_ALIASES_ALIAS_DEFS; m_ParseState = PSTATE_ALIASES_ALIAS_DEFS;
break; break;
} }
@ -129,6 +109,10 @@ SMCResult CsItemInfo::ReadSMC_KeyValue(const SMCStates *states, const char *key,
} }
} }
} }
else if (!strcmp(key, "altname"))
{
m_AliasAlt = value;
}
break; break;
} }
} }
@ -147,11 +131,16 @@ SMCResult CsItemInfo::ReadSMC_LeavingSection(const SMCStates *states)
} }
case PSTATE_ALIASES_ALIAS_DEFS: case PSTATE_ALIASES_ALIAS_DEFS:
{ {
m_List->replace(m_Alias.chars(), m_AliasInfo); if (m_AliasAlt.length())
{
m_BuyAliasesAltList.replace(m_AliasAlt.chars(), m_AliasInfo);
m_AliasInfo.alt_alias = Move(m_AliasAlt);
}
m_BuyAliasesList.replace(m_Alias.chars(), m_AliasInfo);
m_WeaponIdToClass[m_AliasInfo.itemid] = static_cast<CsWeaponClassType>(m_AliasInfo.classid); m_WeaponIdToClass[m_AliasInfo.itemid] = static_cast<CsWeaponClassType>(m_AliasInfo.classid);
m_AliasInfo.clear(); m_AliasInfo.clear();
m_ParseState = PSTATE_ALIASES_ALIAS; m_ParseState = PSTATE_ALIASES_ALIAS;
break; break;
} }
@ -170,7 +159,7 @@ void CsItemInfo::ReadSMC_ParseEnd(bool halted, bool failed)
bool CsItemInfo::GetAliasInfos(const char *alias, AliasInfo *info) bool CsItemInfo::GetAliasInfos(const char *alias, AliasInfo *info)
{ {
if (GetAliasInfosFromBuy(alias, info) || m_WeaponAliasesList.retrieve(alias, info)) if (m_BuyAliasesList.retrieve(alias, info) || m_BuyAliasesAltList.retrieve(alias, info))
{ {
return true; return true;
} }
@ -178,11 +167,17 @@ bool CsItemInfo::GetAliasInfos(const char *alias, AliasInfo *info)
return false; return false;
} }
bool CsItemInfo::GetAliasInfosFromBuy(const char *alias, AliasInfo *info) bool CsItemInfo::GetAliasFromId(size_t id, ke::AString &name, ke::AString &altname)
{ {
if (m_CommonAliasesList.retrieve(alias, info) || m_BuyAliasesList.retrieve(alias, info)) for (auto iter = m_BuyAliasesList.iter(); !iter.empty(); iter.next())
{ {
return true; if (iter->value.itemid == id)
{
name = iter->key;
altname = iter->value.alt_alias;
return true;
}
} }
return false; return false;
@ -190,47 +185,50 @@ bool CsItemInfo::GetAliasInfosFromBuy(const char *alias, AliasInfo *info)
bool CsItemInfo::GetAliasInfosFromName(const char *name, AliasInfo *info) bool CsItemInfo::GetAliasInfosFromName(const char *name, AliasInfo *info)
{ {
static const char prefix_weapon[] = "weapon_"; static const char prefix_weapon[] = "weapon";
static const char prefix_item[] = "item_"; static const char prefix_item[] = "item";
const char *alias = name; static const size_t prefix_weapon_length = sizeof(prefix_weapon) - 1;
static const size_t prefix_item_length = sizeof(prefix_item) - 1;
if (strstr(name, prefix_weapon) && strcmp(name + sizeof(prefix_weapon) - 1, "shield")) if (name[prefix_weapon_length] == '_' && !strncmp(name, prefix_weapon, prefix_weapon_length))
{ {
for (size_t id = 0; id < ARRAYSIZE(WeaponNameList); ++id) name += prefix_weapon_length + 1; // including '_'
{ }
if (!strcmp(name, WeaponNameList[id])) else if (name[prefix_item_length] == '_' && !strncmp(name, prefix_item, prefix_item_length))
{ {
info->classname = name; name += prefix_item_length + 1;
info->itemid = id; }
info->classid = WeaponIdToClass(id);
return true; for (size_t id = 0; id < ARRAYSIZE(WeaponNameList); ++id)
} {
const char *weapon = WeaponNameList[id];
if (weapon[prefix_weapon_length] == '_' && !strncmp(weapon, prefix_weapon, prefix_weapon_length))
{
weapon += prefix_weapon_length + 1;
} }
alias = name + sizeof(prefix_weapon) - 1; if (!strcmp(weapon, name))
}
else if (strstr(name, prefix_item))
{
for (auto iter = m_BuyAliasesList.iter(); !iter.empty(); iter.next())
{ {
if (iter->value.classname.length() && !iter->value.classname.compare(name)) info->classname = name;
{ info->itemid = id;
*info = iter->value; info->classid = WeaponIdToClass(id);
return true;
} return true;
} }
alias = name + sizeof(prefix_item) - 1;
} }
if (GetAliasInfos(alias, info)) for (auto iter = m_BuyAliasesList.iter(); !iter.empty(); iter.next())
{ {
return true; if (iter->value.classname.length() && !strcmp(iter->value.classname.chars() + prefix_item_length + 1, name))
{
*info = iter->value;
return true;
}
} }
return false; return GetAliasInfos(name, info);
} }
CsWeaponClassType CsItemInfo::WeaponIdToClass(int id) CsWeaponClassType CsItemInfo::WeaponIdToClass(int id)

View File

@ -31,11 +31,14 @@ struct AliasInfo
{ {
itemid = CSI_NONE; itemid = CSI_NONE;
classid = CS_WEAPONCLASS_NONE; classid = CS_WEAPONCLASS_NONE;
classname = nullptr;
alt_alias = nullptr;
} }
int itemid; int itemid;
int classid; int classid;
ke::AString classname; ke::AString classname;
ke::AString alt_alias;
}; };
enum class Equipments enum class Equipments
@ -73,8 +76,8 @@ class CsItemInfo : public ITextListener_SMC
public: public:
bool GetAliasInfos(const char *alias, AliasInfo *info); bool GetAliasInfos(const char *alias, AliasInfo *info);
bool GetAliasInfosFromBuy(const char *alias, AliasInfo *info);
bool GetAliasInfosFromName(const char *classname, AliasInfo *info); bool GetAliasInfosFromName(const char *classname, AliasInfo *info);
bool GetAliasFromId(size_t id, ke::AString &name, ke::AString &altname);
CsWeaponClassType WeaponIdToClass(int id); CsWeaponClassType WeaponIdToClass(int id);
@ -84,17 +87,16 @@ class CsItemInfo : public ITextListener_SMC
typedef StringHashMap<AliasInfo> AliasMap; typedef StringHashMap<AliasInfo> AliasMap;
AliasMap m_CommonAliasesList;
AliasMap m_WeaponAliasesList;
AliasMap m_BuyAliasesList; AliasMap m_BuyAliasesList;
AliasMap m_BuyAliasesAltList;
CsWeaponClassType m_WeaponIdToClass[CSI_MAX_COUNT]; CsWeaponClassType m_WeaponIdToClass[CSI_MAX_COUNT];
private: // Config parsing private: // Config parsing
int m_ParseState; int m_ParseState;
AliasMap* m_List;
ke::AString m_Alias; ke::AString m_Alias;
ke::AString m_AliasAlt;
AliasInfo m_AliasInfo; AliasInfo m_AliasInfo;
bool m_ListsRetrievedFromConfig; bool m_ListsRetrievedFromConfig;
int m_EquipmentsPrice[static_cast<size_t>(Equipments::Count)]; int m_EquipmentsPrice[static_cast<size_t>(Equipments::Count)];

View File

@ -1809,6 +1809,40 @@ static cell AMX_NATIVE_CALL cs_get_item_id(AMX* amx, cell* params)
return CSI_NONE; return CSI_NONE;
} }
// native bool:cs_get_item_alias(itemid, name[], name_maxlen, altname[] = "", altname_maxlen = 0);
static cell AMX_NATIVE_CALL cs_get_item_alias(AMX* amx, cell* params)
{
if (ItemsManager.HasConfigError())
{
MF_LogError(amx, AMX_ERR_NATIVE, "Native cs_get_item_alias() is disabled because of corrupted or missing gamedata");
return 0;
}
auto itemid = params[1];
if (itemid == CSI_SHIELDGUN)
{
itemid = CSI_SHIELD;
}
else if (itemid == CSI_GLOCK)
{
itemid = CSI_GLOCK18;
}
else if (itemid <= CSI_NONE || itemid >= CSI_MAX_COUNT)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid item id: %d", itemid);
return FALSE;
}
ke::AString name, altname;
auto result = ItemsManager.GetAliasFromId(itemid, name, altname);
MF_SetAmxString(amx, params[2], name.chars(), params[3]);
MF_SetAmxString(amx, params[4], altname.chars(), params[5]);
return result ? TRUE : FALSE;
}
// native bool:cs_get_translated_item_alias(const alias[], itemname[], maxlength); // native bool:cs_get_translated_item_alias(const alias[], itemname[], maxlength);
static cell AMX_NATIVE_CALL cs_get_translated_item_alias(AMX* amx, cell* params) static cell AMX_NATIVE_CALL cs_get_translated_item_alias(AMX* amx, cell* params)
{ {
@ -2005,6 +2039,7 @@ AMX_NATIVE_INFO CstrikeNatives[] =
{"cs_find_ent_by_class", cs_find_ent_by_class}, {"cs_find_ent_by_class", cs_find_ent_by_class},
{"cs_find_ent_by_owner", cs_find_ent_by_owner}, {"cs_find_ent_by_owner", cs_find_ent_by_owner},
{"cs_get_item_id", cs_get_item_id}, {"cs_get_item_id", cs_get_item_id},
{"cs_get_item_alias", cs_get_item_alias},
{"cs_get_translated_item_alias",cs_get_translated_item_alias}, {"cs_get_translated_item_alias",cs_get_translated_item_alias},
{"cs_get_weapon_info", cs_get_weapon_info}, {"cs_get_weapon_info", cs_get_weapon_info},
{"cs_get_user_weapon_entity", cs_get_user_weapon_entity}, {"cs_get_user_weapon_entity", cs_get_user_weapon_entity},

View File

@ -361,7 +361,7 @@ native cs_set_user_plant(index, plant = 1, showbombicon = 1);
* @param index Client index * @param index Client index
* @param team Team id * @param team Team id
* @param model Internal model id, if CS_DONTCHANGE the game will choose the model * @param model Internal model id, if CS_DONTCHANGE the game will choose the model
or if CS_NORESET the game will not update it. * or if CS_NORESET the game will not update it.
* @param send_teaminfo If true, a TeamInfo message will be sent * @param send_teaminfo If true, a TeamInfo message will be sent
* *
* @noreturn * @noreturn
@ -1060,6 +1060,19 @@ native cs_find_ent_by_owner(start_index, const classname[], owner);
*/ */
native any:cs_get_item_id(const name[], &CsWeaponClassType:classid = CS_WEAPONCLASS_NONE); native any:cs_get_item_id(const name[], &CsWeaponClassType:classid = CS_WEAPONCLASS_NONE);
/**
* Returns the alias name associated with an item index.
*
* @param itemid Item id (CSI_* constants)
* @param name Buffer to store alias name to
* @param name_maxlen Maximum buffer size
* @param altname Optional buffer to store if available alternative alias name to
* @param altname_maxlen Maximum buffer size
*
* @return True if alias is found, false otherwise
*/
native bool:cs_get_item_alias(itemid, name[], name_maxlen, altname[] = "", altname_maxlen = 0);
/** /**
* Returns an item name associated with a command alias. * Returns an item name associated with a command alias.
* *

View File

@ -21,6 +21,7 @@
*/ */
#define CSW_NONE 0 #define CSW_NONE 0
#define CSW_P228 1 #define CSW_P228 1
#define CSW_GLOCK 2 // Unused by game, See CSW_GLOCK18.
#define CSW_SCOUT 3 #define CSW_SCOUT 3
#define CSW_HEGRENADE 4 #define CSW_HEGRENADE 4
#define CSW_XM1014 5 #define CSW_XM1014 5
@ -147,6 +148,7 @@ enum
*/ */
#define CSI_NONE CSW_NONE #define CSI_NONE CSW_NONE
#define CSI_P228 CSW_P228 #define CSI_P228 CSW_P228
#define CSI_GLOCK CSW_GLOCK // Unused by game, See CSI_GLOCK18.
#define CSI_SCOUT CSW_SCOUT #define CSI_SCOUT CSW_SCOUT
#define CSI_HEGRENADE CSW_HEGRENADE #define CSI_HEGRENADE CSW_HEGRENADE
#define CSI_XM1014 CSW_XM1014 #define CSI_XM1014 CSW_XM1014