Raised This Month: $32 Target: $400
 8% 

Solved [ H3LP ] Check if player has any weapons


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode