Adventx

Furien Spawn Knife Menu

Oct 14th, 2014
1,470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.77 KB | None | 0 0
  1. /*
  2.     Furien Spawn Knife Menu
  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. #include <amxmodx>
  20. #include <cstrike>
  21. #include <fakemeta>
  22. #include <hamsandwich>
  23. #include <fun>
  24.  
  25. new const PLUGIN[] = "Furien Spawn Knife Menu";
  26. new const VERSION[] = "0.0.9";
  27.  
  28. #define is_user_valid(%0)       (1 <= %0 <= g_iMaxPlayers)
  29. #define is_user_vip(%1)         (get_user_flags(%1) & ADMIN_LEVEL_H)
  30.  
  31. // Customization vars
  32. new g_iMaxPlayers, bool:g_bKnifeIgnes[33], bool:g_bKnifeKatana[33], bool:g_bKnifexFother[33], bool:g_bKnifeNataKnife[33],
  33. bool:g_bKnifeDualKatana[33], bool:g_bKnifeHuntedKnife[33], bool:g_bKnifeRegeneratorElf[33], bool:g_bKnifeChoosen[33];
  34.  
  35. new const g_szKnifeModels[][] =
  36. {
  37.     "models/furien_knife/v_ignes.mdl",
  38.     "models/furien_knife/v_katana.mdl",
  39.     "models/furien_knife/v_xfother.mdl",
  40.     "models/furien_knife/v_nata_knife.mdl",
  41.     "models/furien_knife/v_dual_katana.mdl",
  42.     "models/furien_knife/v_hunted_knife.mdl",
  43.     "models/furien_knife/v_elf_christmas.mdl"
  44. };
  45.  
  46. //Native
  47. native fcs_get_user_credits(id);
  48. native fcs_set_user_credits(id, credits);
  49.  
  50. public plugin_init()
  51. {
  52.     register_plugin(PLUGIN, VERSION, "Adventx");
  53.  
  54.     // Events
  55.     register_event("CurWeapon", "event_CurrentWeapon", "be", "1=1");
  56.  
  57.     // HAM Forwards
  58.     RegisterHam(Ham_Spawn, "player", "fw_PalyerSpawn_Post", 1);
  59.     RegisterHam(Ham_TakeDamage, "player", "fw_PlayerTakeDamage");
  60.  
  61.     // Client Commands
  62.     register_clcmd("say /knife","clcmd_knife");
  63.  
  64.     // Vars
  65.     g_iMaxPlayers = get_maxplayers();
  66. }
  67.  
  68. public plugin_precache()
  69. {
  70.     // Precache Models
  71.     for (new i = 0; i < sizeof g_szKnifeModels; i++)
  72.         engfunc(EngFunc_PrecacheModel, g_szKnifeModels[i]);
  73. }
  74.  
  75. public client_putinserver(id)
  76. {
  77.     // reset boolean's
  78.     fm_reset_variable(id);
  79. }
  80.  
  81. public fw_PalyerSpawn_Post(id)
  82. {
  83.     if (!is_user_alive(id) || cs_get_user_team(id) != CS_TEAM_T)
  84.         return;
  85.  
  86.     ShowMenuKnife(id);
  87.     fm_reset_variable(id);
  88. }
  89.  
  90. public ShowMenuKnife(id)
  91. {
  92.     new szTitle[128];
  93.     formatex(szTitle, charsmax(szTitle), "\rFurien Knife Menu^n\yCredite: \w%d", fcs_get_user_credits(id));
  94.    
  95.     new szMenu = menu_create(szTitle, "KnifeMenuHandler");
  96.    
  97.     menu_additem(szMenu, "Ignes", "1");
  98.     menu_additem(szMenu, "Katana", "2");
  99.     menu_additem(szMenu, "xFother^n", "3");
  100.    
  101.     menu_additem(szMenu, "Nata Knife   \r[ \y15 Credits \r]", "4");
  102.     menu_additem(szMenu, "Dual Katana   \r[ \y20 Credits \r]", "5");
  103.     menu_additem(szMenu, "Hunted Knife   \r[ \y25 Credits \r]", "6");
  104.    
  105.     if(is_user_vip(id))
  106.         menu_additem (szMenu, "Regenerator Elf   \r[ \rONLY VIP \r]", "7");
  107.     else
  108.         menu_additem (szMenu, "Regenerator Elf   \r[ \dONLY VIP \r]", "7");
  109.    
  110.     menu_setprop(szMenu, MPROP_EXIT, MEXIT_ALL);
  111.     menu_display(id, szMenu, 0);
  112.    
  113.     return PLUGIN_HANDLED;
  114. }
  115.  
  116. public KnifeMenuHandler(id, szMenu, item)
  117. {
  118.     if(item == MENU_EXIT || !is_user_alive(id) || cs_get_user_team(id) != CS_TEAM_T)
  119.     {
  120.         menu_destroy(szMenu);
  121.         return PLUGIN_HANDLED;
  122.     }
  123.    
  124.     new data[6], szName[64], iaccess, callback;
  125.     menu_item_getinfo(szMenu, item, iaccess, data,charsmax (data), szName,charsmax (szName), callback);
  126.     new key = str_to_num(data);
  127.    
  128.     switch (key)
  129.     {
  130.         case 1:
  131.         {
  132.             g_bKnifeIgnes[id]   = true;
  133.             g_bKnifeChoosen[id] = true;
  134.            
  135.             event_CurrentWeapon(id);
  136.             ChatColor(id, "!g[Furien] !nYou have chosen knife !tIgnes");
  137.         }
  138.        
  139.         case 2:
  140.         {
  141.             g_bKnifeKatana[id]  = true;
  142.             g_bKnifeChoosen[id] = true;
  143.            
  144.             event_CurrentWeapon(id);
  145.             ChatColor(id, "!g[Furien] !nYou have chosen knife !tKatana");
  146.         }
  147.        
  148.         case 3:
  149.         {
  150.             g_bKnifexFother[id] = true;
  151.             g_bKnifeChoosen[id] = true;
  152.            
  153.             event_CurrentWeapon(id);
  154.             ChatColor(id, "!g[Furien] !nYou have chosen knife !txFother");
  155.         }
  156.        
  157.         case 4:
  158.         {
  159.             if (fcs_get_user_credits(id) < 15)
  160.             {
  161.                 ShowMenuKnife(id);
  162.                 ChatColor(id, "!g[Furien] !nYou don't have enough credits to buy !tNata Knife");
  163.             }
  164.            
  165.             else
  166.             {  
  167.                 g_bKnifeNataKnife[id]       = true;
  168.                 g_bKnifeChoosen[id] = true;
  169.                
  170.                 event_CurrentWeapon(id);            
  171.                 fcs_set_user_credits(id, fcs_get_user_credits(id) - 15);
  172.                 ChatColor(id, "!g[Furien] !nYou bought !tNata Knife !nfor !t15 credits");
  173.             }
  174.         }
  175.        
  176.         case 5:
  177.         {  
  178.             if (fcs_get_user_credits(id) < 20)
  179.             {
  180.                 ShowMenuKnife(id);
  181.                 ChatColor(id, "!g[Furien] !nYou don't have enough credits to buy !tDual Katana");            
  182.             }
  183.            
  184.             else
  185.             {
  186.                 g_bKnifeDualKatana[id]  = true;
  187.                 g_bKnifeChoosen[id] = true;
  188.                
  189.                 event_CurrentWeapon(id);                                    
  190.                 fcs_set_user_credits(id, fcs_get_user_credits(id) - 20);
  191.                 ChatColor(id, "!g[Furien] !nYou bought !tDual Katana !nfor !t20 credits");
  192.             }
  193.         }
  194.        
  195.         case 6:
  196.         {
  197.             if (fcs_get_user_credits(id) < 25)
  198.             {
  199.                 ShowMenuKnife(id);
  200.                 ChatColor(id, "!g[Furien] !nYou don't have enough credits to buy !tHuned Knife");
  201.             }
  202.            
  203.             else
  204.             {
  205.                 g_bKnifeHuntedKnife[id] = true;
  206.                 g_bKnifeChoosen[id] = true;
  207.                
  208.                 event_CurrentWeapon(id);
  209.                 fcs_set_user_credits(id, fcs_get_user_credits(id) - 25);            
  210.                 ChatColor(id, "!g[Furien] !nYou bought !tHunted Knife !nfor !t25 credits");
  211.             }
  212.         }
  213.        
  214.         case 7:
  215.         {
  216.             if(is_user_vip(id))
  217.             {
  218.                 g_bKnifeRegeneratorElf[id]  = true;
  219.                 g_bKnifeChoosen[id]     = true;
  220.                
  221.                 event_CurrentWeapon(id);
  222.                 ChatColor(id, "!g[Furien VIP] !nYou have chosen knife !tRegenerator Elf");
  223.             }
  224.            
  225.             else
  226.             {
  227.                 ChatColor(id, "!g[Furien VIP] !nFor more details add !gY!M: [email protected]");
  228.                 ShowMenuKnife(id);
  229.             }
  230.         }
  231.     }
  232.    
  233.     menu_destroy (szMenu);
  234.     return PLUGIN_HANDLED;
  235. }
  236.  
  237. public fw_PlayerTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
  238. {
  239.     if (iInflictor == iAttacker && is_user_valid(iAttacker) && get_user_weapon(iAttacker) == CSW_KNIFE)
  240.     {
  241.         if (g_bKnifeIgnes[iAttacker])
  242.             SetHamParamFloat(4, fDamage * 1.5);
  243.        
  244.         if (g_bKnifeKatana[iAttacker])
  245.             SetHamParamFloat(4, fDamage * 1.8);
  246.        
  247.         if (g_bKnifexFother[iAttacker])
  248.             SetHamParamFloat(4, fDamage * 2.0);
  249.        
  250.         if (g_bKnifeNataKnife[iAttacker])
  251.             SetHamParamFloat(4, fDamage * 2.5);
  252.        
  253.         if (g_bKnifeDualKatana[iAttacker])
  254.             SetHamParamFloat(4, fDamage * 3.0);
  255.        
  256.         if (g_bKnifeHuntedKnife[iAttacker])
  257.             SetHamParamFloat(4, fDamage * 3.5);
  258.        
  259.         if (g_bKnifeRegeneratorElf[iAttacker])
  260.             SetHamParamFloat(4, fDamage * 4.0);
  261.     }
  262. }
  263.  
  264. public event_CurrentWeapon(id)
  265. {
  266.     if (get_user_weapon(id) == CSW_KNIFE)
  267.     {
  268.         if(g_bKnifeIgnes[id])
  269.             set_pev(id, pev_viewmodel2, g_szKnifeModels[0]);
  270.        
  271.         if(g_bKnifeKatana[id])
  272.             set_pev(id, pev_viewmodel2, g_szKnifeModels[1]);
  273.        
  274.         if(g_bKnifexFother[id])
  275.             set_pev(id, pev_viewmodel2, g_szKnifeModels[2]);
  276.        
  277.         if(g_bKnifeNataKnife[id])
  278.             set_pev(id, pev_viewmodel2, g_szKnifeModels[3]);
  279.        
  280.         if(g_bKnifeDualKatana[id])
  281.             set_pev(id, pev_viewmodel2, g_szKnifeModels[4]);
  282.        
  283.         if(g_bKnifeHuntedKnife[id])
  284.             set_pev(id, pev_viewmodel2, g_szKnifeModels[5]);
  285.        
  286.         if(g_bKnifeRegeneratorElf[id])
  287.             set_pev(id, pev_viewmodel2, g_szKnifeModels[6]);
  288.     }
  289. }
  290.  
  291. public ClCmdSayKnife(id)
  292. {
  293.     if (!is_user_alive(id) || cs_get_user_team(id) != CS_TEAM_T && g_bKnifeChoosen[id])
  294.         return;
  295.    
  296.     ShowMenuKnife(id);
  297. }
  298.  
  299. public fm_reset_variable(id)
  300. {
  301.     g_bKnifeIgnes[id]       = false;
  302.     g_bKnifeKatana[id]      = false;
  303.     g_bKnifexFother[id]     = false;
  304.     g_bKnifeNataKnife[id]       = false;
  305.     g_bKnifeDualKatana[id]      = false;
  306.     g_bKnifeHuntedKnife[id]     = false;
  307.     g_bKnifeRegeneratorElf[id]  = false;
  308.     g_bKnifeChoosen[id]     = false;
  309. }
  310.  
  311. stock ChatColor(const id, const input[], any:...)
  312. {
  313.     new count = 1, players[32];
  314.     static msg[191];
  315.     vformat(msg, 190, input, 3);
  316.    
  317.     replace_all(msg, 190, "!g", "^4"); // Green Color
  318.     replace_all(msg, 190, "!n", "^1"); // Default Color
  319.     replace_all(msg, 190, "!t", "^3"); // Team Color
  320.     replace_all(msg, 190, "!t2", "^0"); // Team2 Color
  321.    
  322.     if (id) players[0] = id; else get_players(players, count, "ch"); {
  323.         for (new i = 0; i < count; i++) {
  324.             if (is_user_connected(players[i])) {
  325.                 message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
  326.                 write_byte(players[i]);
  327.                 write_string(msg);
  328.                 message_end();
  329.             }
  330.         }
  331.     }
  332. }
  333.  
  334. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  335. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  336. */
Advertisement
Add Comment
Please, Sign In to add comment