View Single Post
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 05-17-2018 , 07:42   [ H3LP ] Check if player has any weapons
Reply With Quote #1

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; }

Last edited by DarthMan; 05-17-2018 at 12:54. Reason: Solved
DarthMan is offline