Advertisement
Hyuna

Guard Weapon Menu (Last Update: 06/02/2013)

Dec 19th, 2012
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     **** Update 06/02/2013 ****
  3.     I'm won't update this plugin any more.
  4.     No license for this plugin/
  5.     Free for All plugin - You can do what you want
  6.  
  7.     Note: No support for this plugin!
  8.     Don't contact with me about this plugin!!!
  9.     This plugin is fully bugged and not working!
  10. */
  11.  
  12. #include <amxmodx>
  13. #include <fakemeta>
  14. #include <hamsandwich>
  15.  
  16. #define OFFSET_AWM_AMMO         377
  17. #define OFFSET_SCOUT_AMMO       378
  18. #define OFFSET_PARA_AMMO        379
  19. #define OFFSET_FAMAS_AMMO       380
  20. #define OFFSET_M3_AMMO          381
  21. #define OFFSET_USP_AMMO         382
  22. #define OFFSET_FIVESEVEN_AMMO       383
  23. #define OFFSET_DEAGLE_AMMO      384
  24. #define OFFSET_P228_AMMO        385
  25. #define OFFSET_GLOCK_AMMO       386
  26. #define OFFSET_FLASH_AMMO       387
  27. #define OFFSET_HE_AMMO          388
  28. #define OFFSET_SMOKE_AMMO       389
  29. #define OFFSET_C4_AMMO          390
  30.  
  31. #define MAX_WEAPONS 8
  32.  
  33. #define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))
  34.  
  35. enum _:Teams{
  36.     FM_TEAM_UNASSIGNED,
  37.     FM_TEAM_T,
  38.     FM_TEAM_CT,
  39.     FM_TEAM_SPECTATOR
  40. };
  41.  
  42. new const g_Weaponsnames [MAX_WEAPONS] [] = {
  43.     "M4A1",
  44.     "AK47",
  45.     "MP5",
  46.     "Galil",
  47.     "Famas",
  48.     "Awp",
  49.     "Scout",
  50.     "ShutGun [M3]"
  51. };
  52.  
  53. new const g_Weapons_code [MAX_WEAPONS] [] = {
  54.     "weapon_m4a1",
  55.     "weapon_ak47",
  56.     "weapon_mp5",
  57.     "weapon_galil",
  58.     "weapon_famas",
  59.     "weapon_awp",
  60.     "weapon_scout",
  61.     "weapon_m3"
  62. };
  63.  
  64. new const g_Weapons_code2 [MAX_WEAPONS] [] = {
  65.     CSW_M4A1,
  66.     CSW_AK47,
  67.     CSW_MP5NAVY,
  68.     CSW_GALIL,
  69.     CSW_FAMAS,
  70.     CSW_AWP,
  71.     CSW_SCOUT,
  72.     CSW_M3
  73. };
  74.  
  75. new g_weapon_choose[33];
  76.  
  77. public plugin_init(){
  78.     register_plugin("Guard Weapon Menu","0.0.1","");
  79.     RegisterHam(Ham_Spawn,"player","PlayerSpawn",1);
  80. }
  81.  
  82. public client_putinserver(client) g_weapon_choose[client] = 0;
  83. public client_disconnect(client) g_weapon_choose[client] = 0;
  84.  
  85. public PlayerSpawn(client){
  86.     if (!is_user_connected(client) || !is_user_alive(client))
  87.         return;
  88.  
  89.     fm_strip_user_weapons(client);
  90.     fm_give_item(client, "weapon_knife");
  91.  
  92.     if (fm_get_user_team(client) == FM_TEAM_CT)
  93.         GuardMenu(client);
  94. }
  95.  
  96. public GuardMenu(client){
  97.     new Guard = menu_create("\r[ \yGuard's Weapon Menu \r]", "GuardMenu_Handler");
  98.     new weapon[64];
  99.  
  100.     formatex(weapon,63,"Weapon: \d[\y%s\d]",g_Weaponsnames[g_weapon_choose[client]]);
  101.     menu_additem(Guard,weapon);
  102.  
  103.     menu_additem(Guard,"Choose Weapon!");
  104.  
  105.     menu_setprop(Guard,MPROP_EXIT,MEXIT_NEVER);
  106.     menu_display(client,Guard);
  107. }
  108.  
  109. public GuardMenu_Handler(client,Guard,item){
  110.     switch(item)
  111.     {
  112.         case MENU_EXIT: menu_destroy(Guard);
  113.         case 0:
  114.         {
  115.             if (g_weapon_choose[client] = MAX_WEAPONS - 1)
  116.                 g_weapon_choose[client] = -1;
  117.  
  118.             g_weapon_choose[client]++;
  119.             GuardMenu(client);
  120.         }
  121.  
  122.         case 1:
  123.         {
  124.             fm_give_item(client,g_Weapons_code[g_weapon_choose[client]]);
  125.             fm_set_user_bpammo(client,str_to_num(g_Weapons_code2[g_weapon_choose[client]]),9999);
  126.  
  127.             fm_give_item(client, "weapon_deagle");
  128.             fm_give_item(client, "weapon_hegrenade");
  129.             fm_give_item(client, "weapon_flashbang");
  130.             fm_give_item(client, "weapon_smokegrenade");
  131.             fm_set_user_bpammo(client, CSW_DEAGLE, 9999);
  132.             fm_set_user_bpammo(client, CSW_HEGRENADE, 1);
  133.             fm_set_user_bpammo(client, CSW_FLASHBANG, 2);
  134.             fm_set_user_bpammo(client, CSW_SMOKEGRENADE, 4);
  135.         }
  136.     }
  137.  
  138.     menu_destroy(Guard);
  139. }
  140.  
  141. stock fm_set_user_bpammo(index, weapon, amount)
  142. {
  143.     new offset;
  144.    
  145.     switch(weapon)
  146.     {
  147.         case CSW_AWP: offset = OFFSET_AWM_AMMO;
  148.             case CSW_SCOUT,CSW_AK47,CSW_G3SG1: offset = OFFSET_SCOUT_AMMO;
  149.             case CSW_M249: offset = OFFSET_PARA_AMMO;
  150.             case CSW_M4A1,CSW_FAMAS,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552: offset = OFFSET_FAMAS_AMMO;
  151.             case CSW_M3,CSW_XM1014: offset = OFFSET_M3_AMMO;
  152.             case CSW_USP,CSW_UMP45,CSW_MAC10: offset = OFFSET_USP_AMMO;
  153.             case CSW_FIVESEVEN,CSW_P90: offset = OFFSET_FIVESEVEN_AMMO;
  154.             case CSW_DEAGLE: offset = OFFSET_DEAGLE_AMMO;
  155.             case CSW_P228: offset = OFFSET_P228_AMMO;
  156.             case CSW_GLOCK18,CSW_MP5NAVY,CSW_TMP,CSW_ELITE: offset = OFFSET_GLOCK_AMMO;
  157.             case CSW_FLASHBANG: offset = OFFSET_FLASH_AMMO;
  158.             case CSW_HEGRENADE: offset = OFFSET_HE_AMMO;
  159.             case CSW_SMOKEGRENADE: offset = OFFSET_SMOKE_AMMO;
  160.             case CSW_C4: offset = OFFSET_C4_AMMO;
  161.            
  162.         default:{
  163.             new invalidMsg[20 + 7];
  164.             formatex(invalidMsg,20 + 6,"Invalid weapon id %d",weapon);
  165.             set_fail_state(invalidMsg);
  166.            
  167.             return 0;
  168.         }
  169.     }
  170.    
  171.     set_pdata_int(index,offset,amount);
  172.    
  173.     return 1;
  174. }
  175.  
  176. stock fm_give_item(index, const item[]) {
  177.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
  178.         return 0;
  179.  
  180.     new ent = fm_create_entity(item);
  181.     if (!pev_valid(ent))
  182.         return 0;
  183.  
  184.     new Float:origin[3];
  185.     pev(index, pev_origin, origin);
  186.     set_pev(ent, pev_origin, origin);
  187.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
  188.     dllfunc(DLLFunc_Spawn, ent);
  189.  
  190.     new save = pev(ent, pev_solid);
  191.     dllfunc(DLLFunc_Touch, ent, index);
  192.     if (pev(ent, pev_solid) != save)
  193.         return ent;
  194.  
  195.     engfunc(EngFunc_RemoveEntity, ent);
  196.  
  197.     return -1;
  198. }
  199.  
  200. stock fm_strip_user_weapons(index) {
  201.     new ent = fm_create_entity("player_weaponstrip");
  202.     if (!pev_valid(ent))
  203.         return 0;
  204.  
  205.     dllfunc(DLLFunc_Spawn, ent);
  206.     dllfunc(DLLFunc_Use, ent, index);
  207.     engfunc(EngFunc_RemoveEntity, ent);
  208.  
  209.     return 1;
  210. }
  211.  
  212. stock fm_get_user_team(index)
  213.     return get_pdata_int(index,114);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement