Advertisement
Rejack

Guards Weapons Menu (v1.4)

Sep 16th, 2012 (edited)
1,372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.95 KB | None | 0 0
  1. #include < amxmodx >
  2. #include < cstrike >
  3. #include < hamsandwich >
  4. #include < fakemeta_util >
  5.  
  6. enum _:g_mData
  7. {
  8.     g_mName[ 32 ],
  9.     g_mClass[ 32 ],
  10.     g_mIndex,
  11.     g_mAmmo
  12. };
  13.  
  14. new szPrimary[ ][ g_mData ] =
  15. {
  16.     { "M4A1",   "weapon_m4a1",      CSW_M4A1,   120 },
  17.     { "AK47",   "weapon_ak47",      CSW_AK47,   120 },
  18.     { "GALIL""weapon_galil",     CSW_GALIL,  120 },
  19.     { "FAMAS""weapon_famas",     CSW_FAMAS,  120 },
  20.     { "M249",   "weapon_m249",      CSW_M249,   400 },
  21.     { "MP5NAVY",    "weapon_mp5navy",   CSW_MP5NAVY,    120 },
  22.     { "AWP",    "weapon_awp",       CSW_AWP,    70 },
  23.     { "SCOUT""weapon_scout",     CSW_SCOUT,  120 },
  24.     { "M3",     "weapon_m3",        CSW_M3,     80 }
  25. };
  26.  
  27. new szSecondary[ ][ g_mData ] =
  28. {
  29.     { "GLOCK""weapon_glock18",   CSW_GLOCK18,    200 },
  30.     { "USP",    "weapon_usp",       CSW_USP,    100 },
  31.     { "DEAGLE", "weapon_deagle",    CSW_DEAGLE, 70 },
  32.     { "FIVESEVEN""weapon_fiveseven", CSW_FIVESEVEN,  200 }
  33. };
  34.  
  35.  
  36. new szPrefix[ ] = "Prefix";
  37.  
  38. new Float:iCount[ 33 ], bool: bValid[ 33 ], pCvar[ 2 ], iPrimary[ 33 ], iSecondary[ 33 ];
  39.  
  40. public plugin_init()
  41. {
  42.     register_plugin( "Guards Weapons Menu", "1.4", "Rejack" );
  43.    
  44.     register_clcmd( "say /guns", "CmdSayGuns" );
  45.    
  46.     RegisterHam( Ham_Spawn, "player", "HamSpawnPost", 1 );
  47.    
  48.     pCvar[ 0 ] = register_cvar( "gw_toggle", "1" );
  49.     pCvar[ 1 ] = register_cvar( "gw_timer", "15" );
  50. }
  51.  
  52. public CmdSayGuns( client )
  53. {
  54.     bValid[ client ] = !bValid[ client ];
  55.    
  56.     client_print( client, print_chat, "Your weapons menu is now: %sabled, type /guns to %sable.", bValid[ client ] ? "Dis" : "En", bValid[ client ] ? "en" : "dis" );
  57.    
  58.     return 1;
  59. }
  60.  
  61. public HamSpawnPost( client )
  62. {
  63.     if ( !is_user_alive( client ) || !is_user_connected( client ) || cs_get_user_team( client ) != CS_TEAM_CT || !get_pcvar_num( pCvar[ 0 ] ) )
  64.         return 1;
  65.    
  66.     remove_task( client );
  67.    
  68.     iCount[ client ] = get_gametime();
  69.    
  70.     if ( !bValid[ client ] )
  71.         set_task( 1.0, "CmdShowMenu", client, _,_, "a", get_pcvar_num( pCvar[ 1 ] ) );
  72.    
  73.     else if ( bValid[ client ] )
  74.         GiveItems( client );
  75.    
  76.     return 1;
  77. }
  78.  
  79. public CmdShowMenu( client )
  80. {
  81.     show_menu( client, 0, "^n", 1 );
  82.    
  83.     if ( !is_user_alive( client ) || !is_user_connected( client ) || cs_get_user_team( client ) != CS_TEAM_CT || !get_pcvar_num( pCvar[ 0 ] ) )
  84.         return 1;
  85.    
  86.     if ( iCount[ client ] + get_pcvar_num( pCvar[ 1 ] ) < get_gametime() )
  87.     {
  88.         GiveItems( client );
  89.        
  90.         return 1;
  91.     }
  92.    
  93.     static szItem[ 128 ];
  94.    
  95.     formatex( szItem, charsmax( szItem ), "\r[%s]\w Guards Weapons Menu^n\r%i\d Seconds!", szPrefix, get_pcvar_num( pCvar[ 1 ] ) - floatround( (iCount[client]-get_gametime()) / (-1) ) );
  96.    
  97.     new Menu = menu_create( szItem, "SubShowMenu" );
  98.    
  99.     formatex( szItem, charsmax( szItem ), "Primary Weapon\d: [\r %s \d]", szPrimary[ iPrimary[ client ] ] );
  100.    
  101.     menu_additem( Menu, szItem );
  102.    
  103.     formatex( szItem, charsmax( szItem ), "Secondary Weapon\d: [\r %s \d]", szSecondary[ iSecondary[ client ] ] );
  104.    
  105.     menu_additem( Menu, szItem );
  106.    
  107.     menu_addblank( Menu, 0 );
  108.    
  109.     menu_additem( Menu, "\rOrder Package" );
  110.    
  111.     menu_addblank( Menu, 0 );
  112.    
  113.     formatex( szItem, charsmax( szItem ), "Weapons Menu\d: [\r %s \d]", bValid[ client ] ? "Disabled" : "Enabled" );
  114.    
  115.     menu_additem( Menu, szItem );
  116.    
  117.     menu_display( client, Menu );
  118.    
  119.     return 1;
  120. }
  121.  
  122. public SubShowMenu( client, Menu, Item )
  123. {
  124.     if ( !is_user_alive( client ) || !is_user_connected( client ) || cs_get_user_team( client ) != CS_TEAM_CT || !get_pcvar_num( pCvar[ 0 ] ) )
  125.         return 1;
  126.    
  127.     switch ( Item )
  128.     {
  129.         case 0:
  130.         {
  131.             if ( iPrimary[ client ] == charsmax( szPrimary ) )
  132.                 iPrimary[ client ] = -1;
  133.            
  134.             iPrimary[ client ]++;
  135.            
  136.             return CmdShowMenu( client );
  137.         }
  138.        
  139.         case 1:
  140.         {
  141.             if ( iSecondary[ client ] == charsmax( szSecondary ) )
  142.                 iSecondary[ client ] = -1;
  143.            
  144.             iSecondary[ client ]++;
  145.            
  146.             return CmdShowMenu( client );
  147.         }
  148.        
  149.         case 2,MENU_EXIT:
  150.         {
  151.             GiveItems( client );
  152.            
  153.             return 1;
  154.         }
  155.        
  156.         case 3:
  157.         {
  158.             bValid[ client ] = !bValid[ client ];
  159.            
  160.             client_print( client, print_chat, "Your weapons menu is now: %sabled, type /guns to %s", bValid[ client ] ? "Dis" : "En", bValid[ client ] ? "enable" : "disable" );
  161.            
  162.             return CmdShowMenu( client );
  163.         }
  164.     }
  165.    
  166.     menu_destroy( Menu );
  167.    
  168.     return 1;
  169. }
  170.  
  171. stock GiveItems( const index )
  172. {
  173.     if ( task_exists( index ) )
  174.         remove_task( index );
  175.    
  176.     fm_strip_user_weapons( index );
  177.    
  178.     fm_give_item( index, szPrimary[ iPrimary[ index ] ][ g_mClass ] );
  179.     fm_give_item( index, szSecondary[ iSecondary[ index ] ][ g_mClass ] );
  180.     fm_give_item( index, "weapon_knife" );
  181.     fm_give_item( index, "weapon_hegrenade" );
  182.     fm_give_item( index, "weapon_smokegrenade" );
  183.    
  184.     cs_set_user_bpammo( index, szPrimary[ iPrimary[ index ] ][ g_mIndex ], szPrimary[ iPrimary[ index ] ][ g_mAmmo ] );
  185.     cs_set_user_bpammo( index, szSecondary[ iSecondary[ index ] ][ g_mIndex ], szSecondary[ iSecondary[ index ] ][ g_mAmmo ] );
  186.     cs_set_user_bpammo( index, CSW_SMOKEGRENADE, 4 );
  187.    
  188.     if ( bValid[ index ] )
  189.         client_print( index, print_chat, "Your guns menu is disabled, type /guns to enable." );
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement