Adventx

Furien Weapons Advanced

Oct 11th, 2014
570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.88 KB | None | 0 0
  1. /*
  2.  *   Furien Weapons Advanced
  3.  *   Copyright (C) 2014  Adventx
  4.  *
  5.  *   This program is free software: you can redistribute it and/or modify
  6.  *   it under the terms of the GNU General Public License as published by
  7.  *   the Free Software Foundation, either version 3 of the License, or
  8.  *   (at your option) any later version.
  9.  * 
  10.  *   This program is distributed in the hope that it will be useful,
  11.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *   GNU General Public License for more details.
  14.  *
  15.  *   You should have received a copy of the GNU General Public License
  16.  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  *
  18.  *
  19.  *   ----------------
  20.  *   -*- Creadits -*-
  21.  *   ----------------
  22.  *
  23.  *   * AMXX Dev Team: for all the hard work which made this possible
  24.  *   * HamletEagle: for help me using enum
  25.  *
  26.  *
  27.  *   -----------------
  28.  *   -*- Changelog -*-
  29.  *   -----------------
  30.  *
  31.  *   * v0.0.2: (Dec 2014)
  32.  *       - Optimized code and rewritten again
  33.  *       - Small modifications to the code
  34.  *
  35. */
  36.  
  37. #include <amxmodx>
  38. #include <amxmisc>
  39. #include <cstrike>
  40. #include <hamsandwich>
  41. #include <fun>
  42.  
  43. new const PLUGIN[] = "Furien: Weapons Advanced";
  44. new const VERSION[] = "0.0.2";
  45. new const AUTHOR[] = "Adventx";
  46.  
  47. enum _:eData
  48. {
  49.     szWeaponName[64],
  50.     szWeaponEntity[64],
  51.     szWeaponAmmo,
  52.     szWeaponBpAmmo
  53. }
  54.  
  55. enum
  56. {
  57.     WEAPONS_PRIMARY = 0,
  58.     WEAPONS_SECONDARY
  59. }
  60.  
  61. new const g_szWeaponsPrimary[][eData] =
  62. {
  63.     { "M4A1",       "weapon_m4a1",      CSW_M4A1,       90, },
  64.     { "AK47",       "weapon_ak47",      CSW_AK47,       90, },
  65.     { "AUG",        "weapon_aug",       CSW_AUG,        90, },
  66.     { "SG552",      "weapon_sg552",     CSW_SG552,      90, },
  67.     { "Galil",      "weapon_galil",     CSW_GALIL,      90, },
  68.     { "Famas",      "weapon_famas",     CSW_FAMAS,      90, },
  69.     { "MP5 Navy",       "weapon_mp5navy",   CSW_MP5NAVY,        120,    },
  70.     { "XM1014",     "weapon_xm1014",    CSW_XM1014,     32, },
  71.     { "M3",         "weapon_m3",        CSW_M3,         32, },
  72.     { "P90",        "weapon_p90",       CSW_P90,        100,    },
  73.     { "M249",       "weapon_m249",      CSW_M249,       200,    },
  74.     { "SG550",      "weapon_sg550",     CSW_SG550,      90, },
  75.     { "G3SG1",      "weapon_g3sg1",     CSW_G3SG1,      90, }
  76. };
  77.  
  78. new const g_szWeaponsSecondary[][eData] =
  79. {
  80.     { "Deagle",     "weapon_deagle",    CSW_DEAGLE,     35  },
  81.     { "USP",        "weapon_usp",       CSW_USP,        100 },
  82.     { "Elite",      "weapon_elite",     CSW_ELITE,      120 }
  83. };
  84.  
  85. // Customization Vars
  86. new bool:g_bChoosenWeaponsPrimary[33];
  87. new bool:g_bChoosenWeaponsSecondary[33];
  88.  
  89. public plugin_init()
  90. {
  91.     register_plugin
  92.     (
  93.         .plugin_name    = PLUGIN,
  94.         .version    = VERSION,
  95.         .author     = AUTHOR
  96.     )
  97.    
  98.     // Client command
  99.     register_clcmd("say /weapons", "clcmd_weapons");
  100.     register_clcmd("say_team /weapons", "clcmd_weapons");
  101.    
  102.     // Ham Forwards
  103.     RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", true);
  104. }
  105.  
  106. public fw_PlayerSpawn_Post(id)
  107. {
  108.     if (!is_user_alive(id) || cs_get_user_team(id) != CS_TEAM_CT)
  109.         return;
  110.    
  111.     ShowWeaponsMenu(id, WEAPONS_PRIMARY);
  112.    
  113.     g_bChoosenWeaponsPrimary[id] = false;
  114.     g_bChoosenWeaponsSecondary[id] = false;
  115. }
  116.  
  117. public ShowWeaponsMenu(id, weapons)
  118. {
  119.     switch (weapons)
  120.     {
  121.         case WEAPONS_PRIMARY:
  122.         {
  123.             new szMenu = menu_create("Weapons Primary", "WeaponsPrimaryHandler");
  124.            
  125.             for (new i = 0; i < sizeof g_szWeaponsPrimary; i++)
  126.                 menu_additem(szMenu, g_szWeaponsPrimary[i][szWeaponName], "");
  127.         }
  128.        
  129.         case WEAPONS_SECONDARY:
  130.         {
  131.             new szMenu = menu_create("Weapons Secondary", "WeaponsSecondaryHandler");
  132.            
  133.             for (new i = 0; i < sizeof g_szWeaponsSecondary; i++)
  134.                 menu_additem(szMenu, g_szWeaponsSecondary[i][szWeaponName], "");
  135.         }
  136.     }
  137.    
  138.     menu_setprop(szMenu, MPROP_EXIT, MEXIT_ALL);
  139.     menu_display(id, szMenu, 0);
  140. }
  141.  
  142. public WeaponsPrimaryHandler(id, szMenu, item)
  143. {
  144.     if (item == MENU_EXIT || !is_user_alive(id) || cs_get_user_team(id) != CS_TEAM_CT)
  145.     {
  146.         menu_destroy(szMenu);
  147.         return PLUGIN_HANDLED;
  148.     }
  149.    
  150.     give_item(id, g_szWeaponsPrimary[item][szWeaponEntity]);
  151.     cs_set_user_bpammo(id, g_szWeaponsPrimary[item][szWeaponAmmo], g_szWeaponsPrimary[item][szWeaponBpAmmo]);
  152.    
  153.     g_bChoosenWeaponsPrimary[id] = true;
  154.     ShowWeaponsMenu(id, WEAPONS_SECONDARY);
  155.    
  156.     menu_destroy(szMenu);
  157.     return PLUGIN_HANDLED;
  158. }
  159.  
  160. public WeaponsSecondaryHandler(id, szMenu, item)
  161. {
  162.     if (item == MENU_EXIT || !is_user_alive(id) || cs_get_user_team(id) != CS_TEAM_CT)
  163.     {
  164.         menu_destroy(szMenu);
  165.         return PLUGIN_HANDLED;
  166.     }
  167.    
  168.     give_item(id, g_szWeaponsSecondary[item][szWeaponEntity]);
  169.     cs_set_user_bpammo(id, g_szWeaponsSecondary[item][szWeaponAmmo], g_szWeaponsSecondary[item][szWeaponBpAmmo]);
  170.    
  171.     g_bChoosenWeaponsSecondary[id] = true;
  172.    
  173.     menu_destroy(szMenu);
  174.     return PLUGIN_HANDLED;
  175. }
  176.  
  177. public clcmd_weapons(id)
  178. {
  179.     if (!is_user_alive(id) || cs_get_user_team(id) != CS_TEAM_CT)
  180.         return PLUGIN_HANDLED;
  181.    
  182.     if (g_bChoosenWeaponsPrimary[id] == false)
  183.         ShowWeaponsMenu(id, WEAPONS_PRIMARY);
  184.        
  185.     if (g_bChoosenWeaponsSecondary[id] == false)
  186.         ShowWeaponsMenu(id, WEAPONS_SECONDARY);
  187.    
  188.     ChatColor(id, "!g[Furien: Weapons Menu] !nYou select your weapons in this round");
  189.     return PLUGIN_HANDLED;
  190. }
  191.  
  192. stock ChatColor(index, const input[], any:...)
  193. {
  194.     new iPlayers[32], count = 1;
  195.     static msg[191];
  196.     vformat(msg, 190, input, 3);
  197.        
  198.     replace_all(msg, 190, "!g", "^4");  // Green Color
  199.     replace_all(msg, 190, "!n", "^1");  // Default Color
  200.     replace_all(msg, 190, "!t", "^3");  // Team Color
  201.     replace_all(msg, 190, "!t2", "^0"); // Team2 Color
  202.        
  203.     if (index) iPlayers[0] = index; else get_players(iPlayers, count, "ch");
  204.     {
  205.         for (new i = 0; i < count; i++)
  206.         {
  207.             if (is_user_connected(iPlayers[i]))
  208.             {
  209.                 message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, iPlayers[i]);
  210.                 write_byte(iPlayers[i]);
  211.                 write_string(msg);
  212.                 message_end();
  213.             }
  214.         }
  215.     }
  216. }
  217.  
  218. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  219. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  220. */
Advertisement
Add Comment
Please, Sign In to add comment