View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-05-2021 , 23:51   Re: Owner Knife Only When CT
Reply With Quote #10

Use sizeof() in OnCurWeapon as well. Any time you are looping through an array, use sizeof(). charsmax() should only be used in string functions/natives to set the max chars.

You should probably also check that a model exists in the string here. Or atleast for model P
Code:
    for( new i = 0 ; i < charsmax( g_szWeapons ); i++ )
    {         if( get_user_team( id ) == g_szWeapons[ i ][ Teams ] && ( get_user_flags( id ) & g_szWeapons[ i ][ Access ] == g_szWeapons[ i ][ Access ] ) && iWeapon == g_szWeapons[ i ][ WeaponsID ] )         {
            if ( g_szWeapons[ i ][ ModelV ][ 0 ] != EOS )
                        set_pev( id, pev_viewmodel2, g_szWeapons[ i ][ ModelV ] )
            if ( g_szWeapons[ i ][ ModelP ][ 0 ] != EOS )
                        set_pev( id, pev_weaponmodel2, g_szWeapons[ i ][ ModelP ] )                         break;         }     }
__________________

Last edited by Bugsy; 11-05-2021 at 23:52.
Bugsy is offline