Hello. I'm trying to loop through all weapon slots to check if player has any weapon but if ti has no weapon, the plugin crashes with message Run time error 4: index out of bounds. Any ideas?
Code:
bool: HasAnyWeapon(iID)
{
new bool: bHasWeapons, iWeapon;
if(is_user_alive(iID))
{
for(new i = 0; i < MAX_WEAPON_SLOTS + 1; i++)
{
iWeapon = get_pdata_cbase(iID, m_rgpPlayerItems[i], XO_PLAYER);
if(!pev_valid(iWeapon))
continue;
if(!bHasWeapons)
{
bHasWeapons = true;
break;
}
}
}
return bHasWeapons;
}