ColdWar-Pawn

Guard Weapons

Apr 5th, 2013
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.46 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include < amxmodx >
  4. #include < fakemeta >
  5. #include < hamsandwich >
  6.  
  7. const g_oCSTeams = 114;
  8.  
  9. enum _:Weapon
  10. {
  11.     SName[16],
  12.     CName[22],
  13.     CSWeapon
  14. }
  15.  
  16. enum _:CsTeams
  17. {
  18.     CS_TEAM_UNASSIGNED,
  19.     CS_TEAM_T,
  20.     CS_TEAM_CT,
  21.     CS_TEAM_SPEC
  22. }
  23.  
  24. new const szPrimarys[ ][ Weapon ] = {
  25.     { "M4A1", "weapon_m4a1", CSW_M4A1 },
  26.     { "AK47", "weapon_ak47", CSW_AK47 },
  27.     { "GALIL", "weapon_galil", CSW_GALIL },
  28.     { "FAMAS", "weapon_famas", CSW_FAMAS },
  29.     { "AWP", "weapon_awp", CSW_AWP }
  30. }
  31.  
  32. public plugin_init()
  33. {
  34.     register_plugin( "Guards Weapons", "v0.1", "+ColdWar" )
  35.     RegisterHam( Ham_Spawn, "player", "Ham_PlayerSpawn_Post", 1 );
  36. }
  37.  
  38. public Ham_PlayerSpawn_Post( client )
  39. {
  40.     if( !is_user_connected( client ) || !is_user_alive( client ) || fm_cs_get_user_team( client ) != CS_TEAM_CT )
  41.         return HAM_IGNORED;
  42.        
  43.     new iMenu = menu_create( "\r[AMXX]\w Guard Weapons Menu", "sub_weapons" );
  44.    
  45.     for( new i = 0 ; i < sizeof szPrimarys ; i ++ )
  46.         menu_additem( iMenu, szPrimarys[ SName ] );
  47.        
  48.     menu_display( client, iMenu );
  49.    
  50.     return HAM_IGNORED;
  51. }
  52.  
  53. public sub_weapons( client, iMenu, item )
  54. {
  55.     menu_destroy( iMenu );
  56.    
  57.     if( item == MENU_EXIT || fm_cs_get_user_team( client ) != CS_TEAM_CT )
  58.         return 1;
  59.        
  60.     fm_strip_user_weapons( client );
  61.    
  62.     fm_give_item( client, "weapon_knife" );
  63.    
  64.     fm_give_item( client, szPrimarys[ item ][ CName ] );
  65.     fm_give_item( client, "weapon_deagle" );
  66.    
  67.     fm_give_item( client , "weapon_smokegrenade" );
  68.     fm_give_item( client , "weapon_flashbang" );
  69.     fm_give_item( client , "weapon_hegrenade" );
  70.    
  71.     fm_cs_set_user_bpammo( client, szPrimarys[ item ][ CSWeapon ], 9999 );
  72.     fm_cs_set_user_bpammo( client, CSW_DEAGLE, 9999 );
  73.     fm_cs_set_user_bpammo( client, CSW_FLASHBANG, 2 );
  74.        
  75.     return 1;
  76. }
  77.  
  78. stock fm_strip_user_weapons(index)
  79. {
  80.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"));
  81.     if (!pev_valid(ent))
  82.         return 0;
  83.    
  84.     dllfunc(DLLFunc_Spawn, ent);
  85.     dllfunc(DLLFunc_Use, ent, index);
  86.     engfunc(EngFunc_RemoveEntity, ent);
  87.    
  88.     return 1;
  89. }
  90.  
  91. stock fm_give_item( client, const item[] )
  92. {
  93.     if ( !equal( item, "weapon_", 7 ) )
  94.         return 0;
  95.    
  96.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
  97.    
  98.     if ( !pev_valid( ent ) )
  99.         return 0;
  100.    
  101.     new Float:origin[3];
  102.    
  103.     pev( client, pev_origin, origin );
  104.    
  105.     set_pev( ent, pev_origin, origin );
  106.     set_pev( ent, pev_spawnflags, pev( ent, pev_spawnflags ) | SF_NORESPAWN );
  107.    
  108.     dllfunc( DLLFunc_Spawn, ent );
  109.     dllfunc( DLLFunc_Touch, ent, client );
  110.    
  111.     return ent;
  112. }
  113.  
  114. stock fm_cs_get_user_team( client )
  115. {
  116.     return get_pdata_int( client, g_oCSTeams );
  117. }
  118.    
  119. stock fm_cs_set_user_bpammo( client, csweapon, amount )
  120. {
  121.     new offset;
  122.    
  123.     switch(csweapon)
  124.     {
  125.         case CSW_AWP:
  126.             offset = 377;
  127.         case CSW_SCOUT,CSW_AK47,CSW_G3SG1:
  128.             offset = 378;
  129.         case CSW_M249:
  130.             offset = 379;
  131.         case CSW_M4A1,CSW_FAMAS,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552:
  132.             offset = 380;
  133.         case CSW_M3,CSW_XM1014:
  134.             offset = 381;
  135.         case CSW_USP,CSW_UMP45,CSW_MAC10:
  136.             offset = 382;
  137.         case CSW_FIVESEVEN,CSW_P90:
  138.             offset = 383;
  139.         case CSW_DEAGLE:
  140.             offset = 384;
  141.         case CSW_P228:
  142.             offset = 385;
  143.         case CSW_GLOCK18,CSW_MP5NAVY,CSW_TMP,CSW_ELITE:
  144.             offset = 386;
  145.         case CSW_FLASHBANG:
  146.             offset = 387;
  147.         case CSW_HEGRENADE:
  148.             offset = 388;
  149.         case CSW_SMOKEGRENADE:
  150.             offset = 389;
  151.         case CSW_C4:
  152.             offset = 390;
  153.     }
  154.     set_pdata_int(client,offset,amount);
  155.     return 1;  
  156. }
Advertisement
Add Comment
Please, Sign In to add comment