View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-13-2016 , 22:00   Re: Problem with my CS Pick up manager
Reply With Quote #10

I am not having an issue, it seems to work normally for me but I only gave it a quick test. You aren't doing any reference to entity index so I don't think it is because of that. There may be other things that are wrong in your code but the below are the things that I quickly noticed.
Code:
public addkey( id, level, cid ) {     if( !cmd_access( id, level, cid, 2 ) )         return PLUGIN_HANDLED;     new Arg1[16];     read_argv( 1 , Arg1, charsmax( Arg1 ) );     new adder[64];     formatex( adder, charsmax( adder ), "models/w_%s.mdl", Arg1 );     new szVaultData[ 60 ] , iTS;         if( nvault_lookup( gNewVault, adder , szVaultData, charsmax( szVaultData ) , iTS ) )     {         client_print( id, 2, "This key is already saved in the pick up manager list." );         return PLUGIN_HANDLED;     }     //This loop should begin at 1 since item 0 is "========== All weapons-key avaible to add to add in list ========== ",     for( new i = 0; i < sizeof ( gKeyList ) ; i++ )     {         //You should search the entire list before deciding whether or not the key exists in the list. In your code, the loop is going to         //exit after the first iteration.                 //contain/containi/strfind all return the position of the found substring. In some cases, this can be at the beginning of the         //string which is position 0 so doing a !containi() condition is wrong, it should be if ( containi() == -1 ) then string not found.         if ( !containi( gKeyList[i], Arg1 ) )         {             client_print( id , 2, "Unnable to found this key, type amx_cspum_keylist for all keys avaible to insert." );             return PLUGIN_HANDLED;         }         else         {               client_print( id , 2, "You succesfully added %s in list!", Arg1 );             nvault_set( gNewVault, adder , "1" );             return PLUGIN_HANDLED;         }     }         return PLUGIN_HANDLED; } public OnPlayerTouchWeaponBox( ent , id ) {     if( !ent || !id )         return -1;     new szWeaponModel[40];     pev( ent, pev_model, szWeaponModel, charsmax( szWeaponModel ) )     new iCvarValue = get_pcvar_num( giTypeCvar );     new szVaultData[ 60 ] , iTS;         //I would not call nvault_lookup() in a touch forward. This is called way too much and the nvault module is getting     //spammed with lookup calls. You should store each of your weapons status in an array, maybe refresh it each round.     if( nvault_lookup( gNewVault, szWeaponModel , szVaultData, charsmax( szVaultData ) , iTS ) )     {         switch( iCvarValue )         {             case 1: engfunc( EngFunc_RemoveEntity, ent );             case 2: return PLUGIN_HANDLED;             default: return PLUGIN_CONTINUE;         }     }     return PLUGIN_CONTINUE; }
__________________

Last edited by Bugsy; 09-13-2016 at 22:11.
Bugsy is online now