Code:
public Action OnWeaponCanUse(int client, int weapon)
{
int def = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
CSWeaponID csweapon = CS_ItemDefIndexToID(def);
if(!CS_IsValidWeaponID(csweapon)) return Plugin_Continue;
int slot = CS_WeaponIDToLoadoutSlot(csweapon);
PrintToChatAll("slot val: %d", slot);
char wp[32];
CS_WeaponIDToAlias(csweapon, wp, sizeof(wp));
PrintToChatAll("%s", wp);
return Plugin_Continue;
}
In the code above, I check if
CS_IsValidWeaponID is true. Given the check and the fact, that
CS_WeaponIDToAlias always returns proper weapon name, while
CS_WeaponIDToLoadoutSlot remains always 0, I asssume it's about not implementing it correctly or the function not being available yet.
Speaking of the docs, "Returns the loadout slot based on the CSWeaponID. (CS:GO only)" - I pass correct CSWeaponID and should get loadout slot, but I don't.
It'd be nice if someone more advanced could point out my mistake or refactor the code properly.