Hi. Why does this method not work? When I pass any CSW_* constant, it returns me *not* random numbers but they're wrong.
Did I do something wrong?
Testing code:
PHP Code:
#include amxmodx
#include cstrike_const
const CSW_PRIMARY = (CSW_ALL_SHOTGUNS | CSW_ALL_SMGS | CSW_ALL_RIFLES | CSW_ALL_SNIPERRIFLES | CSW_ALL_MACHINEGUNS);
const CSW_SECONDARY = (CSW_ALL_PISTOLS);
const CSW_GRENADES = (CSW_ALL_GRENADES);
public plugin_init()
{
new slot, cached, szWeaponName[32];
for(new wpn = CSW_P228; wpn <= CSW_P90; wpn++)
{
cached = wpn;
if(get_weaponname(cached, szWeaponName, charsmax(szWeaponName)))
{
slot = get_weapon_slot(cached);
console_print(0, "%i :: %s :: Slot: %i", cached, szWeaponName, slot);
}
}
}
/** I'm asking about this method */
public get_weapon_slot(wpn)
{
if(wpn & CSW_PRIMARY) return CS_WEAPONSLOT_PRIMARY;
if(wpn & CSW_SECONDARY) return CS_WEAPONSLOT_SECONDARY;
if(wpn & CSW_KNIFE) return CS_WEAPONSLOT_KNIFE;
if(wpn & CSW_GRENADES) return CS_WEAPONSLOT_GRENADE;
return 0;
}
Output:
__________________