So i found this weapon strip stock, and i was looking over to learn couple things from it when i got the the lines i marked with red
What i don't understand is why get the weapon's name using it's index, in order to pass it to the next stock to retrieve it's index using it's name when you could simply pass directly the index ? o.O
Code:
stock strip_weapons(iPlayer, iType)
{
new iWeapons[32], iNum, iWeaponID
get_user_weapons(iPlayer, iWeapons, iNum)
for (new x = 0; x < iNum; x++)
{
iWeaponID = iWeapons[x]
if ((1<<iWeaponID) & iType)
{
new szWeaponName[32]
get_weaponname(iWeaponID, szWeaponName, charsmax(szWeaponName))
ham_strip_weapon(iPlayer, szWeaponName)
cs_set_user_bpammo(iPlayer, iWeaponID, 0)
}
}
}
stock ham_strip_weapon(iPlayer, const szWeapon[])
{
new iWeaponID = get_weaponid(szWeapon)
if (!pev_valid(iWeaponID))
return false;
new iEntity = ks_get_entity_owner(-1, szWeapon, iPlayer)
if (!pev_valid(iEntity))
return false;
new iWeaponEntity = ks_get_weapon_owner(iPlayer)
new iWeapon = pev_valid(iWeaponEntity) ? cs_get_weapon_id(iWeaponEntity) : -1
if (iWeapon == iEntity)
ExecuteHamB(Ham_Weapon_RetireWeapon, iEntity)
if(!ExecuteHamB(Ham_RemovePlayerItem, iPlayer, iEntity))
return false;
ExecuteHamB(Ham_Item_Kill, iEntity)
set_pev(iPlayer, pev_weapons, pev(iPlayer, pev_weapons) & ~(1<<iWeaponID))
return true;
}
__________________