View Single Post
Hacker13dev
New Member
Join Date: Feb 2023
Old 06-14-2023 , 15:15   Re: [CSGO] Issue with cstrike's CS_WeaponIDToLoadoutSlot
Reply With Quote #3

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.

Last edited by Hacker13dev; 06-14-2023 at 15:16.
Hacker13dev is offline