In the first stock the index we retrieve is is the index of the weapon ( CSW_* ) since we compare it with the CSW_* bitsum ( iType )
Then we retrieve it's name ( weapon_* )
Then in the second stock, iWeaponID cannot be the entity index, because we retrieve just one by the name of the weapon, and there are multiple weapons with the same name also the entity index is actually retrieved after with get_entity_by_owner ( ks_get_entity_owner )
In conclusion we retrieve the weapon index in the second stock while we already retrieved it in the first...