The code is wrong, touch is hooked between
armoury_entity,
weaponbox and any other entity. You should make sure that the
id is a player. Also the classname check is wrong, because it will always be
armoury_entity or
weaponbox and not the weapon classname.
To know what weapon an
armoury_entity contain do:
PHP Code:
new Weapon = cs_get_armoury_type(armoury_entity)
To know what weapon a
weaponbox entity contain use this stock by connor:
PHP Code:
const XO_CWEAPONBOX = 4;
new const m_rgpPlayerItems_CWeaponBox[6] = {34,35,...};
GetWeaponBoxWeaponType( ent )
{
new weapon;
for(new i = 1; i<= 5; i++)
{
weapon = get_pdata_cbase(ent, m_rgpPlayerItems_CWeaponBox[i], XO_CWEAPONBOX);
if( weapon > 0 )
{
return cs_get_weapon_id(weapon);
}
}
return 0;
}
It basically loop all weapon slots from the weaponbox and return the found weapon. It's not 100% correct, but should work in most of conditions. This code assume that the box contain only one weapon, but it can contain more. In CS it usually contain only one weapon, so it's ok.
To know if he touched an
armoury_entity or a
weaponbox you should have two different callbacks for the
Ham_Touch forward or check inside it the classname like:
PHP Code:
switch(ClassName[0])
{
case 'a':
{
//armoury entity touched
}
case 'w':
{
//weaponbox entity touched
}
}
After you get the weapon index check if it is the restricted weapon(CSW_AWP), if so supercede the hook, else do nothing.
__________________