Menu format problem
When i press to chage page it gives me gun not the other page.
PHP Code:
#define STARTID menu_d[ id ][ 1 ] #define MAXIDS ArraySize( primary_items ) #define SELECTED ( menu_d[ id ][ 1 ] + selection ) #define PRI_ menu_d[ id ][ 2 ] new const WEAPON_FILE[ ] = "vip_weapons.ini"; new Array: primary_ids, Array: primary_items, menu_d[ 33 ][ 3 ]; static _wid, _wname[ 32 ];
public plugin_init( ) { total_guns( ); }
public plugin_precache( ) { primary_items = ArrayCreate( 32, 1 ); primary_ids = ArrayCreate( 1, 1 ); secondary_items = ArrayCreate( 32, 1 ); secondary_ids = ArrayCreate( 1, 1 ); sniper_items = ArrayCreate( 32, 1 ); sniper_ids = ArrayCreate( 1, 1 ); }
public show_menu_guns( id ) { if( !is_user_alive( id ) ) return PLUGIN_HANDLED; new data_holder[ 526 ], len, i_prim; len = formatex( data_holder[ len ], charsmax( data_holder ) - len, "\rV\d.\rI\d.\rP \w- \wGinklu meniu\d.^n" ); get_mapname( szMap, 32 ); if( get_pcvar_num( _cvars[ 1 ] ) && !equali( szMap, "awp_", 3 ) ) { m_loops = min( STARTID + 8, MAXIDS ); for( i_prim = STARTID; i_prim < m_loops; i_prim++ ) len += formatex( data_holder[ len ], charsmax( data_holder ) - len, "^n \r%i\d. %s", i_prim - STARTID + 1, NAMES[ ArrayGetCell( primary_ids, i_prim ) ] ); len += formatex( data_holder[ len ], charsmax( data_holder ) - len, "^n^n\r9\d. \wKitas/Praitas puslapis" ); len += formatex( data_holder[ len ], charsmax( data_holder ) - len, "^n^n\r0\d. \wIseiti" );
show_menu( id, MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0, data_holder, -1, "Vip Guns Primary" ); } return PLUGIN_HANDLED; }
public choosen_menu_primary( id, selection ) { if( SELECTED >= MAXIDS ) { switch( selection ) { case 8: { if( STARTID + 8 < MAXIDS ) STARTID += 8; else STARTID = 0; } case 9: { return PLUGIN_HANDLED; } } show_menu_guns( id ); return PLUGIN_HANDLED; } PRI_ = SELECTED; if( !get_pcvar_num( _cvars[ 2 ] ) ) give_weapon_pri( id, PRI_ ); else show_sec_menu( id ); return PLUGIN_HANDLED; }
give_weapon_pri( id, x ) { if( !get_pcvar_num( _cvars[ 1 ] ) ) return;
if( !get_pcvar_num( _cvars[ 2 ] ) ) drop( id, 1 ); else { if( user_has_weapon( id, CSW_C4 ) ) _save_important[ id ][ 1 ] = true; if( cs_get_user_defuse( id ) ) _save_important[ id ][ 2 ] = true; if( user_has_weapon( id, CSW_KNIFE ) ) _save_important[ id ][ 3 ] = true; strip_user_weapons( id ); } if( get_pcvar_num( _cvars[ 1 ] ) ) { get_mapname( szMap, 32 ); if( !equali( szMap, "awp_", 3 ) ) { _wid = ArrayGetCell( primary_ids, x ); ArrayGetString( primary_items, x, _wname, charsmax( _wname ) ); fm_give_item( id, _wname ); ExecuteHamB( Ham_GiveAmmo, id, AMMO[ _wid ], AMMOTYPE[ _wid ], AMMO[ _wid ] ) } else { _wid = ArrayGetCell( sniper_ids, x ); ArrayGetString( sniper_items, x, _wname, charsmax( _wname ) ); fm_give_item( id, _wname ); ExecuteHamB( Ham_GiveAmmo, id, AMMO[ _wid ], AMMOTYPE[ _wid ], AMMO[ _wid ] ) } } if( !get_pcvar_num( _cvars[ 2 ] ) ) { if( get_pcvar_num( _cvars[ 3 ] ) ) { for( new i = 0; i < sizeof GRENADES; i++ ) fm_give_item( id, GRENADES[ i ] ); } if( _save_important[ id ][ 1 ] ) fm_give_item( id, "weapon_c4" ); if( _save_important[ id ][ 2 ] ) cs_set_user_defuse( id, 1, 0, 160, 0, "defuser", 0 ); if( _save_important[ id ][ 3 ] ) fm_give_item( id, "weapon_knife" );
for( new b = 0; b < 4; b++ ) _save_important[ id ][ b ] = false; } }
public total_guns( ) { new path[ 64 ]; get_configsdir( path, charsmax( path ) ); format( path, charsmax( path ), "%s/%s", path, WEAPON_FILE );
if( !file_exists( path ) ) { new error[ 100 ]; formatex( error, charsmax( error ), "Cannot load customization file %s!", path ); set_fail_state( error ); return; }
new linedata[ 1024 ], keys[ 64 ], value[ 960 ]; new file = fopen( path, "rt" );
while( file && !feof( file ) ) { fgets( file, linedata, charsmax( linedata ) ); replace( linedata, charsmax( linedata ), "^n", "" ); if( !linedata[ 0 ] || linedata[ 0 ] == ';' ) continue; strtok( linedata, keys, charsmax( keys ), value, charsmax( value ), '=' ); trim( keys ); trim( value ); if( equal( keys, "PRIMARY" ) ) { while( value[ 0 ] != 0 && strtok( value, keys, charsmax( keys ), value, charsmax( value ), ',' ) ) { trim( keys ); trim( value ); ArrayPushString( primary_items, keys ); ArrayPushCell( primary_ids, cs_weapon_name_to_id( keys ) ); } } else if( equal( keys, "SECONDARY" ) ) { while( value[ 0 ] != 0 && strtok( value, keys, charsmax( keys ), value, charsmax( value ), ',' ) ) { trim( keys ); trim( value ); ArrayPushString( secondary_items, keys ); ArrayPushCell( secondary_ids, cs_weapon_name_to_id( keys ) ); } } else if( equal( keys, "SNIPERS" ) ) { while( value[ 0 ] != 0 && strtok( value, keys, charsmax( keys ), value, charsmax( value ), ',' ) ) { trim( keys ); trim( value ); ArrayPushString( sniper_items, keys ); ArrayPushCell( sniper_ids, cs_weapon_name_to_id( keys ) ); } } } if (file) fclose(file) }
stock cs_weapon_name_to_id( const weapon[ ] ) { static i; for( i = 0; i < sizeof PRIMARY; i++ ) { if( equal( weapon, PRIMARY[ i ] ) ) return i; } return 0; }
|