knife menu

Coding Help/Re-API Supported
Post Reply
czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 529
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

knife menu

#1

Post by czirimbolo » 2 Months Ago

Hello,

I want to add extra knife plugin to my knife menu. Its working with one extra knife, but when I add more, the server is crashing with Segmentation Fault. Raheem or Jack can you take a look here and add knife plugin to this menu? New knife cost: 500 coins

Knife menu:
  1. #include <zombie_escape>
  2. #include <engine>
  3. #include <fun>
  4. #include <ze_vip>
  5.  
  6. #pragma tabsize 0
  7.  
  8. #define HOLYSWORD_COST 2600
  9.  
  10. // Models
  11. new const Storm_Models[][] =
  12. {
  13.     "models/v_axe.mdl",
  14.     "models/p_axe.mdl"
  15. }
  16.  
  17. new const Turbulent9_Models[][] =
  18. {
  19.     "models/v_turbulent9_knife.mdl",
  20.     "models/p_turbulent9_knife.mdl"
  21. }
  22.  
  23. new const Sabers_Models[][] =
  24. {
  25.     "models/v_laser_knife.mdl",
  26.     "models/p_laser_knife.mdl"
  27. }
  28.  
  29. new const Plasma_Models[][] =
  30. {
  31.     "models/v_stick.mdl",
  32.     "models/p_stick.mdl"
  33. }
  34.  
  35. new const Laevateinn_Models[][] =
  36. {
  37.     "models/v_black.mdl",
  38.     "models/p_black.mdl"
  39. }
  40.  
  41.  
  42.  
  43. // Sounds
  44. new const g_sound_knife[] = "items/gunpickup2.wav"
  45.  
  46. new const storm_sounds[][] =
  47. {
  48.     "zombie_escape/knife_menu/storm_sword_deploy.wav",
  49.     "zombie_escape/knife_menu/storm_sword_hit.wav",
  50.     "zombie_escape/knife_menu/storm_sword_hit.wav",
  51.     "zombie_escape/knife_menu/storm_sword_hit.wav",
  52.     "zombie_escape/knife_menu/storm_sword_hit.wav",
  53.     "zombie_escape/knife_menu/storm_sword_hitwall.wav",
  54.     "zombie_escape/knife_menu/storm_sword_slash.wav",
  55.     "zombie_escape/knife_menu/storm_sword_slash.wav",
  56.     "zombie_escape/knife_menu/storm_sword_stab.wav"
  57. }
  58.  
  59. new const turbulent9_sounds[][] =
  60. {
  61.     "zombie_escape/knife_menu/turbulent9_deploy.wav",
  62.     "zombie_escape/knife_menu/turbulent9_hit.wav",
  63.     "zombie_escape/knife_menu/turbulent9_hit.wav",
  64.     "zombie_escape/knife_menu/turbulent9_hit.wav",
  65.     "zombie_escape/knife_menu/turbulent9_hit.wav",
  66.     "zombie_escape/knife_menu/turbulent9_hitwall.wav",
  67.     "zombie_escape/knife_menu/turbulent9_slash.wav",
  68.     "zombie_escape/knife_menu/turbulent9_slash.wav",
  69.     "zombie_escape/knife_menu/turbulent9_stab.wav"
  70. }
  71.  
  72. new const sabers_sounds[][] =
  73. {
  74.     "zombie_escape/knife_menu/laser_deploy.wav",
  75.     "zombie_escape/knife_menu/laser_hit.wav",
  76.     "zombie_escape/knife_menu/laser_hit.wav",
  77.     "zombie_escape/knife_menu/laser_hit.wav",
  78.     "zombie_escape/knife_menu/laser_hit.wav",
  79.     "zombie_escape/knife_menu/laser_hitwall.wav",
  80.     "zombie_escape/knife_menu/laser_slash1.wav",
  81.     "zombie_escape/knife_menu/laser_slash2.wav",
  82.     "zombie_escape/knife_menu/laser_stab.wav"
  83. }
  84.  
  85. new const plasma_sounds[][] =
  86. {
  87.     "zombie_escape/knife_menu/plasma_deploy.wav",
  88.     "zombie_escape/knife_menu/plasma_hit.wav",
  89.     "zombie_escape/knife_menu/plasma_hit.wav",
  90.     "zombie_escape/knife_menu/plasma_hit.wav",
  91.     "zombie_escape/knife_menu/plasma_hit.wav",
  92.     "zombie_escape/knife_menu/plasma_hitwall.wav",
  93.     "zombie_escape/knife_menu/plasma_slash.wav",
  94.     "zombie_escape/knife_menu/plasma_slash.wav",
  95.     "zombie_escape/knife_menu/plasma_stab.wav"
  96. }
  97.  
  98. new const laevateinn_sounds[][] =
  99. {
  100.     "zombie_escape/knife_menu/laevateinn_deploy.wav",
  101.     "zombie_escape/knife_menu/laevateinn_hit.wav",
  102.     "zombie_escape/knife_menu/laevateinn_hit.wav",
  103.     "zombie_escape/knife_menu/laevateinn_hit.wav",
  104.     "zombie_escape/knife_menu/laevateinn_hit.wav",
  105.     "zombie_escape/knife_menu/laevateinn_hitwall.wav",
  106.     "zombie_escape/knife_menu/laevateinn_slash.wav",
  107.     "zombie_escape/knife_menu/laevateinn_slash.wav",
  108.     "zombie_escape/knife_menu/laevateinn_stab.wav"
  109. }
  110.  
  111. new const oldknife_sounds[][] =
  112. {
  113.     "weapons/knife_deploy1.wav",
  114.     "weapons/knife_hit1.wav",
  115.     "weapons/knife_hit2.wav",
  116.     "weapons/knife_hit3.wav",
  117.     "weapons/knife_hit4.wav",
  118.     "weapons/knife_hitwall1.wav",
  119.     "weapons/knife_slash1.wav",
  120.     "weapons/knife_slash2.wav",
  121.     "weapons/knife_stab.wav"
  122. }
  123.  
  124. new bool:g_bTurbulent9[33], bool:g_bSabers[33], bool:g_bPlasma[33],
  125. bool:g_bStorm[33], bool:g_bLaevateinn[33], bool:g_bNoSpeed, g_iUsedTimes[33], g_pCvarUseTimes
  126.  
  127. new cvar_speed_storm
  128. new cvar_speed_turb
  129. new cvar_speed_sabers
  130. new cvar_speed_plasma
  131. new cvar_speed_laevat
  132.  
  133. native SetUserHolySword(id)
  134. native DelUserHolySword(id)
  135.  
  136. public plugin_precache()
  137. {
  138.     new i
  139.  
  140.     for (i = 0; i <= charsmax(Storm_Models); i++)
  141.         precache_model(Storm_Models[i])
  142.  
  143.     for (i = 0; i <= charsmax(Turbulent9_Models); i++)
  144.         precache_model(Turbulent9_Models[i])
  145.  
  146.     for (i = 0; i <= charsmax(Sabers_Models); i++)
  147.         precache_model(Sabers_Models[i])
  148.  
  149.     for (i = 0; i <= charsmax(Plasma_Models); i++)
  150.         precache_model(Plasma_Models[i])
  151.  
  152.     for (i = 0; i <= charsmax(Laevateinn_Models); i++)
  153.         precache_model(Laevateinn_Models[i])
  154.  
  155.     for (i = 0; i <= charsmax(storm_sounds); i++)
  156.         precache_sound(storm_sounds[i])
  157.  
  158.     for (i = 0; i <= charsmax(turbulent9_sounds); i++)
  159.         precache_sound(turbulent9_sounds[i])
  160.  
  161.     for (i = 0; i <= charsmax(sabers_sounds); i++)
  162.         precache_sound(sabers_sounds[i])       
  163.  
  164.     for (i = 0; i <= charsmax(plasma_sounds); i++)
  165.         precache_sound(plasma_sounds[i])
  166.  
  167.     for (i = 0; i <= charsmax(laevateinn_sounds); i++)
  168.         precache_sound(laevateinn_sounds[i])
  169.  
  170.     precache_sound(g_sound_knife)
  171. }
  172.  
  173. public plugin_natives()
  174. {
  175.     register_native("ze_open_knife_menu", "native_ze_open_knife_menu", 1)
  176. }
  177.  
  178. public plugin_init()
  179. {
  180.     register_plugin("[ZE] Addon: Knife Menu", "1.3", "Mark")
  181.  
  182.     register_forward(FM_EmitSound, "fw_EmitSound")
  183.     register_forward(FM_PlayerPreThink, "fw_PlayerPreThink");
  184.  
  185.     register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
  186.     RegisterHookChain(RG_CBasePlayer_ResetMaxSpeed, "Fw_RestMaxSpeed_Post", 1)
  187.    
  188.     g_pCvarUseTimes = register_cvar("ze_knife_menu_use_times", "1000")
  189.  
  190.     register_message(get_user_msgid("DeathMsg"), "DeathMsg")
  191.  
  192.     register_clcmd("say /km", "Show_Knife_Menu")
  193.    
  194.     cvar_speed_storm = register_cvar("ze_storm_speed", "285.0")
  195.     cvar_speed_turb = register_cvar("ze_turb_speed", "285.0")
  196.     cvar_speed_sabers = register_cvar("ze_sabers_speed", "285.0")    
  197.     cvar_speed_plasma = register_cvar("ze_plasma_speed", "295.0")  
  198.     cvar_speed_laevat = register_cvar("ze_laevat_speed", "305.0")  
  199. }
  200.  
  201. public ze_user_humanized(id)
  202. {
  203.     g_iUsedTimes[id] = 0
  204. }
  205.  
  206. /*public ze_user_infected(Victim)
  207. {
  208.     g_bStorm[Victim] = false
  209.     g_bTurbulent9[Victim] = false  
  210.     g_bSabers[Victim] = false  
  211.     g_bPlasma[Victim] = false
  212.     g_bLaevateinn[Victim] = false
  213.     g_iUsedTimes[Victim] = 0
  214. }*/
  215.  
  216. public client_putinserver(id)
  217. {  
  218.     DelUserHolySword(id)
  219.     g_bStorm[id] = false
  220.     g_bTurbulent9[id] = false  
  221.     g_bSabers[id] = false  
  222.     g_bPlasma[id] = false
  223.     g_bLaevateinn[id] = false
  224.     g_iUsedTimes[id] = 0
  225. }
  226.  
  227. public client_disconnected(id)
  228. {
  229.     DelUserHolySword(id)   
  230.     g_bStorm[id] = false
  231.     g_bTurbulent9[id] = false
  232.     g_bSabers[id] = false  
  233.     g_bPlasma[id] = false
  234.     g_bLaevateinn[id] = false
  235.     g_iUsedTimes[id] = 0
  236. }
  237.  
  238. public ze_game_started()
  239. {
  240.     g_bNoSpeed = true
  241. }
  242.  
  243. public ze_zombie_release()
  244. {
  245.     g_bNoSpeed = false
  246.    
  247.     // call the reset speed function ;)
  248.     for(new id = 1; id <= 32; id++)
  249.     {
  250.         if (!is_user_alive(id))
  251.             continue;
  252.        
  253.         rg_reset_maxspeed(id)
  254.     }
  255. }
  256.  
  257. public Show_Knife_Menu(id)
  258. {
  259.     if (!is_user_connected(id))
  260.         return PLUGIN_CONTINUE
  261.  
  262.     if (ze_is_user_zombie(id))
  263.     {
  264.         ze_colored_print(id, "!tZombies can't open knife menu!y.")
  265.         return PLUGIN_HANDLED
  266.     }
  267.  
  268.     if (g_iUsedTimes[id] >= get_pcvar_num(g_pCvarUseTimes))
  269.     {
  270.         ze_colored_print(id, "!tYou can only open knife menu !y[!g%dx!y] per round!", get_pcvar_num(g_pCvarUseTimes))
  271.         return PLUGIN_HANDLED
  272.     }
  273.  
  274.     if (!is_user_alive(id))
  275.     {
  276.         ze_colored_print(id, "!tDead can't open knife menu!y.")
  277.         return PLUGIN_HANDLED
  278.     }
  279.  
  280.     Knife_Menu(id)
  281.     return PLUGIN_CONTINUE
  282. }
  283.  
  284. public Knife_Menu(id)
  285. {
  286.     new iMenu = menu_create("\rChoose Your Knife\w:^n^n- [ \ySpeed \rActivates \yon Zombie Release!\w ]^n\w- [ \r9 \yknives in Total!\w ] ^n-", "Menu_Handler")
  287.     menu_additem(iMenu, "\yAxe \w[ \r285 Speed\w ]", "", 0)
  288.     menu_additem(iMenu, "\yTurbulent-9 \w[ \r285 Speed\w ]", "", 0)
  289.     menu_additem(iMenu, "\ySabers \w[ \r285 Speed\w ]", "", 0)
  290.  
  291.     if (ze_get_vip_flags(id) & VIP_A)
  292.     {
  293.         menu_additem(iMenu, "\yCrowbar \w[ \rVIP\w ] [ \r295 Speed\w ]", "", 0)            
  294.     }
  295.    
  296.     if (ze_get_vip_flags(id) & VIP_F)
  297.     {
  298.         menu_additem(iMenu, "\yBlack Sword \w[ \rSVIP\w ] [ \r305 Speed\w ]", "", 0)
  299.         menu_additem(iMenu, "\yHolySword (SVIP) \w[\r2600 \ycoins\w]", "", 0)          
  300.     }
  301.         menu_setprop(iMenu,MPROP_EXITNAME,"Close")
  302.         menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL)
  303.         menu_display(id, iMenu, 0) 
  304. }
  305.  
  306. public Menu_Handler(id, iMenu, iKey)
  307. {
  308.     if(!is_user_alive(id) || ze_is_user_zombie(id))
  309.         return PLUGIN_HANDLED
  310.        
  311.     switch(iKey)
  312.     {
  313.         case 0: // Storm
  314.         {
  315.         DelUserHolySword(id)
  316.             g_bTurbulent9[id] = false
  317.             g_bSabers[id] = false
  318.             g_bPlasma[id] = false
  319.             g_bStorm[id] = true
  320.             g_bLaevateinn[id] = false
  321.             g_iUsedTimes[id] = 0
  322.             rg_remove_item(id, "weapon_knife")
  323.             rg_give_item(id, "weapon_knife", GT_APPEND)
  324.             //engclient_cmd(id, "weapon_knife")
  325.             //g_iUsedTimes[id]++
  326.             //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
  327.            
  328.         }
  329.         case 1: // Turbulent
  330.         {
  331.         DelUserHolySword(id)       
  332.             g_bTurbulent9[id] = true
  333.             g_bSabers[id] = false
  334.             g_bPlasma[id] = false
  335.             g_bStorm[id] = false
  336.             g_bLaevateinn[id] = false
  337.             g_iUsedTimes[id] = 0       
  338.             rg_remove_item(id, "weapon_knife")
  339.             rg_give_item(id, "weapon_knife", GT_APPEND)
  340.             //engclient_cmd(id, "weapon_knife")
  341.             //g_iUsedTimes[id]++
  342.             //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
  343.            
  344.         }
  345.         case 2: // Sabers
  346.         {
  347.         DelUserHolySword(id)       
  348.             g_bTurbulent9[id] = false
  349.             g_bSabers[id] = true
  350.             g_bPlasma[id] = false
  351.             g_bStorm[id] = false
  352.             g_bLaevateinn[id] = false  
  353.             g_iUsedTimes[id] = 0       
  354.             rg_remove_item(id, "weapon_knife")
  355.             rg_give_item(id, "weapon_knife", GT_APPEND)
  356.             //engclient_cmd(id, "weapon_knife")
  357.             //g_iUsedTimes[id]++
  358.             //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
  359.            
  360.         }                                
  361.         case 3: // Plasma
  362.         {
  363.         DelUserHolySword(id)       
  364.             g_bTurbulent9[id] = false
  365.             g_bSabers[id] = false
  366.             g_bPlasma[id] = true
  367.             g_bStorm[id] = false
  368.             g_bLaevateinn[id] = false
  369.             g_iUsedTimes[id] = 0       
  370.             rg_remove_item(id, "weapon_knife")
  371.             rg_give_item(id, "weapon_knife", GT_APPEND)
  372.             //engclient_cmd(id, "weapon_knife")
  373.             //g_iUsedTimes[id]++
  374.             //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
  375.            
  376.         }
  377.         case 4: // Laevateinn
  378.         {
  379.         DelUserHolySword(id)       
  380.             g_bTurbulent9[id] = false
  381.             g_bSabers[id] = false
  382.             g_bPlasma[id] = false
  383.             g_bStorm[id] = false
  384.             g_bLaevateinn[id] = true   
  385.             g_iUsedTimes[id] = 0           
  386.             rg_remove_item(id, "weapon_knife")
  387.             rg_give_item(id, "weapon_knife", GT_APPEND)
  388.             //engclient_cmd(id, "weapon_knife")
  389.             //g_iUsedTimes[id]++
  390.             //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
  391.            
  392.         }  
  393.         case 5: // Holysword
  394.         {      
  395.     if (ze_get_escape_coins(id) < HOLYSWORD_COST)
  396.     {
  397.         //ze_set_escape_coins(id,ze_get_escape_coins(id)+HOLYSWORD_COST); //return coins
  398.         return PLUGIN_HANDLED;
  399.     }
  400.     ze_set_escape_coins(id,ze_get_escape_coins(id) - HOLYSWORD_COST);
  401.    
  402.         SetUserHolySword(id)       
  403.             g_bTurbulent9[id] = false
  404.             g_bSabers[id] = false
  405.             g_bPlasma[id] = false
  406.             g_bStorm[id] = false
  407.             g_bLaevateinn[id] = false  
  408.             g_iUsedTimes[id] = 0       
  409.             rg_remove_item(id, "weapon_knife")
  410.             rg_give_item(id, "weapon_knife", GT_APPEND)
  411.             //engclient_cmd(id, "weapon_knife")
  412.             //g_iUsedTimes[id]++
  413.             //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
  414.            
  415.         }          
  416.     }
  417.  
  418.     menu_destroy(iMenu)
  419.     return PLUGIN_HANDLED
  420. }
  421.  
  422. public fw_EmitSound(id, channel, const sound[])
  423. {
  424.     if(!is_user_alive(id) || ze_is_user_zombie(id))
  425.         return FMRES_IGNORED
  426.        
  427.     new i
  428.     for (i = 0; i <= charsmax(turbulent9_sounds); i++)
  429.     for (i = 0; i <= charsmax(sabers_sounds); i++)
  430.     for (i = 0; i <= charsmax(plasma_sounds); i++)
  431.     for (i = 0; i <= charsmax(storm_sounds); i++)
  432.     for (i = 0; i <= charsmax(laevateinn_sounds); i++)
  433.  
  434.     {
  435.         if(equal(sound, oldknife_sounds[i]))
  436.         {
  437.  
  438.             if ((g_bTurbulent9[id]))
  439.             {
  440.                 emit_sound(id, channel, turbulent9_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  441.                 return FMRES_SUPERCEDE
  442.             }
  443.             else if ((g_bSabers[id]))
  444.             {
  445.                 emit_sound(id, channel, sabers_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  446.                 return FMRES_SUPERCEDE
  447.             }
  448.             else if ((g_bPlasma[id]) && (ze_get_vip_flags(id) & VIP_A))
  449.             {
  450.                 emit_sound(id, channel, plasma_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  451.                 return FMRES_SUPERCEDE
  452.             }
  453.             else if ((g_bStorm[id]))
  454.             {
  455.                 emit_sound(id, channel, storm_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  456.                 return FMRES_SUPERCEDE
  457.             }
  458.             else if ((g_bLaevateinn[id]) && (ze_get_vip_flags(id) & VIP_F))
  459.             {
  460.                 emit_sound(id, channel, laevateinn_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  461.                 return FMRES_SUPERCEDE
  462.             }
  463.             else if (!g_bTurbulent9[id] || !g_bSabers[id] || !g_bPlasma[id] || !g_bStorm[id] || !g_bLaevateinn[id])
  464.             {
  465.                 emit_sound(id, channel, oldknife_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  466.                 return FMRES_SUPERCEDE
  467.             }
  468.         }
  469.     }
  470.     return FMRES_IGNORED
  471. }
  472.  
  473. public CurrentWeapon(id)
  474. {
  475.     if(!is_user_alive(id) || ze_is_user_zombie(id))
  476.         return
  477.        
  478.     if(get_user_weapon(id) & CSW_KNIFE)
  479.     {
  480.  
  481.         if((g_bTurbulent9[id]))
  482.         {
  483.             cs_set_player_view_model(id, CSW_KNIFE, Turbulent9_Models[0])
  484.             cs_set_player_weap_model(id, CSW_KNIFE, Turbulent9_Models[1])
  485.         }
  486.         else if((g_bSabers[id]))
  487.         {
  488.             cs_set_player_view_model(id, CSW_KNIFE, Sabers_Models[0])
  489.             cs_set_player_weap_model(id, CSW_KNIFE, Sabers_Models[1])
  490.         }
  491.         else if((g_bPlasma[id]) && (ze_get_vip_flags(id) & VIP_A))
  492.         {
  493.             cs_set_player_view_model(id, CSW_KNIFE, Plasma_Models[0])
  494.             cs_set_player_weap_model(id, CSW_KNIFE, Plasma_Models[1])
  495.         }
  496.         else if((g_bStorm[id]) && (ze_get_vip_flags(id) & VIP_A))
  497.         {
  498.             cs_set_player_view_model(id, CSW_KNIFE, Storm_Models[0])
  499.             cs_set_player_weap_model(id, CSW_KNIFE, Storm_Models[1])
  500.         }
  501.         else if((g_bLaevateinn[id]) && (ze_get_vip_flags(id) & VIP_A))
  502.         {
  503.             cs_set_player_view_model(id, CSW_KNIFE, Laevateinn_Models[0])
  504.             cs_set_player_weap_model(id, CSW_KNIFE, Laevateinn_Models[1])
  505.         }  
  506.     }
  507. }
  508.  
  509. public Fw_RestMaxSpeed_Post(id)
  510. {
  511.     if (g_bNoSpeed)
  512.         return
  513.        
  514.     set_task(0.1, "DelayLoad", id)
  515.    
  516. }
  517.  
  518. public DelayLoad(id)
  519. {
  520.     new iWpnId = (get_user_weapon(id))
  521.    
  522.     if (iWpnId == CSW_KNIFE && g_bTurbulent9[id])
  523.     {
  524.         if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
  525.         {
  526.             new iFlags = get_entvar(id, var_flags);
  527.             new iWaterlvl = get_entvar(id, var_waterlevel)
  528.            
  529.             if (!(iFlags & FL_ONGROUND))
  530.                 return HC_CONTINUE
  531.  
  532.             if (iFlags & FL_WATERJUMP)
  533.                 return HAM_IGNORED
  534.  
  535.             if (iWaterlvl > 1)
  536.                 return HAM_IGNORED
  537.            
  538.             new Float:flVelocity[3]
  539.             get_entvar(id , var_velocity , flVelocity)
  540.  
  541.             flVelocity[2] += 325
  542.  
  543.             set_entvar(id , var_velocity , flVelocity)
  544.  
  545.             set_entvar(id, var_gaitsequence, 6)
  546.         }
  547.        
  548.         set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_turb))
  549.     }
  550.     if (iWpnId == CSW_KNIFE && g_bSabers[id])
  551.     {
  552.         if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
  553.         {
  554.             new iFlags = get_entvar(id, var_flags);
  555.             new iWaterlvl = get_entvar(id, var_waterlevel)
  556.            
  557.             if (!(iFlags & FL_ONGROUND))
  558.                 return HC_CONTINUE
  559.  
  560.             if (iFlags & FL_WATERJUMP)
  561.                 return HAM_IGNORED
  562.  
  563.             if (iWaterlvl > 1)
  564.                 return HAM_IGNORED
  565.            
  566.             new Float:flVelocity[3]
  567.             get_entvar(id , var_velocity , flVelocity)
  568.  
  569.             flVelocity[2] += 325
  570.  
  571.             set_entvar(id , var_velocity , flVelocity)
  572.  
  573.             set_entvar(id, var_gaitsequence, 6)
  574.         }
  575.        
  576.         set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_sabers))
  577.     }
  578.     if (iWpnId == CSW_KNIFE && g_bPlasma[id])
  579.     {
  580.         if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
  581.         {
  582.             new iFlags = get_entvar(id, var_flags);
  583.             new iWaterlvl = get_entvar(id, var_waterlevel)
  584.            
  585.             if (!(iFlags & FL_ONGROUND))
  586.                 return HC_CONTINUE
  587.  
  588.             if (iFlags & FL_WATERJUMP)
  589.                 return HAM_IGNORED
  590.  
  591.             if (iWaterlvl > 1)
  592.                 return HAM_IGNORED
  593.            
  594.             new Float:flVelocity[3]
  595.             get_entvar(id , var_velocity , flVelocity)
  596.  
  597.             flVelocity[2] += 325
  598.  
  599.             set_entvar(id , var_velocity , flVelocity)
  600.  
  601.             set_entvar(id, var_gaitsequence, 6)
  602.         }
  603.        
  604.         set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_plasma))
  605.     }
  606.     if (iWpnId == CSW_KNIFE && g_bStorm[id])
  607.     {
  608.         if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
  609.         {
  610.             new iFlags = get_entvar(id, var_flags);
  611.             new iWaterlvl = get_entvar(id, var_waterlevel)
  612.            
  613.             if (!(iFlags & FL_ONGROUND))
  614.                 return HC_CONTINUE
  615.  
  616.             if (iFlags & FL_WATERJUMP)
  617.                 return HAM_IGNORED
  618.  
  619.             if (iWaterlvl > 1)
  620.                 return HAM_IGNORED
  621.            
  622.             new Float:flVelocity[3]
  623.             get_entvar(id , var_velocity , flVelocity)
  624.  
  625.             flVelocity[2] += 325
  626.  
  627.             set_entvar(id , var_velocity , flVelocity)
  628.  
  629.             set_entvar(id, var_gaitsequence, 6)
  630.         }
  631.        
  632.         set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_storm))
  633.     }
  634.     if (iWpnId == CSW_KNIFE && g_bLaevateinn[id])
  635.     {
  636.         if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
  637.         {
  638.             new iFlags = get_entvar(id, var_flags);
  639.             new iWaterlvl = get_entvar(id, var_waterlevel)
  640.            
  641.             if (!(iFlags & FL_ONGROUND))
  642.                 return HC_CONTINUE
  643.  
  644.             if (iFlags & FL_WATERJUMP)
  645.                 return HAM_IGNORED
  646.  
  647.             if (iWaterlvl > 1)
  648.                 return HAM_IGNORED
  649.            
  650.             new Float:flVelocity[3]
  651.             get_entvar(id , var_velocity , flVelocity)
  652.  
  653.             flVelocity[2] += 325
  654.  
  655.             set_entvar(id , var_velocity , flVelocity)
  656.  
  657.             set_entvar(id, var_gaitsequence, 6)
  658.         }
  659.        
  660.         set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_laevat))
  661.     }
  662.  
  663.     return HAM_IGNORED
  664. }
  665. public DeathMsg(msg_id, msg_dest, id)
  666. {
  667.     static szTruncatedWeapon[33], iAttacker
  668.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  669.     iAttacker = get_msg_arg_int(1)
  670.    
  671.     if(!is_user_alive(iAttacker) || iAttacker == get_msg_arg_int(2) || !is_user_alive(get_msg_arg_int(2))) // get_msg_arg_int(2) = iVictim
  672.         return
  673.    
  674.     if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iAttacker) & CSW_KNIFE)
  675.     {
  676.  
  677.         if(g_bTurbulent9[id])
  678.         {
  679.             set_msg_arg_string(4, "Turbulent9 knife")
  680.         }
  681.         else if(g_bSabers[id])
  682.         {
  683.             set_msg_arg_string(4, "Sabers knife")
  684.         }
  685.         else if(g_bPlasma[id])
  686.         {
  687.             set_msg_arg_string(4, "Plasma knife")
  688.         }
  689.         else if(g_bStorm[id])
  690.         {
  691.             set_msg_arg_string(4, "Storm knife")
  692.         }
  693.         else if(g_bLaevateinn[id])
  694.         {
  695.             set_msg_arg_string(4, "Laevateinn knife")
  696.         }
  697.     }
  698. }
  699.  
  700. stock fm_set_user_maxspeed(index, Float:speed = -1.0)
  701. {
  702.         engfunc(EngFunc_SetClientMaxspeed, index, speed);
  703.         set_pev(index, pev_maxspeed, speed);
  704.  
  705.         return 1;
  706. }  
  707.  
  708. public native_ze_open_knife_menu(id)
  709. {
  710.     Show_Knife_Menu(id)
  711. }
  712. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  713. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
  714. */
Knife plugin (warhammer)
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fakemeta_util>
  4. #include <hamsandwich>
  5.  
  6. #define _ZP
  7.  
  8. #if !defined _ZP
  9.     #tryinclude <zombieplague>
  10. #else
  11.     #tryinclude <zombie_escape>
  12.        
  13.     #define zp_get_user_zombie      ze_is_user_zombie
  14. #endif
  15.  
  16. #define PLUGIN                  "[ZP] Extra: CSO Weapon"
  17. #define VERSION                 "1.0"
  18. #define AUTHOR                  "TemplateAuthor:KORD_12.7:WeaponAuthor:PaXaN-ZOMBIE"
  19.  
  20. #pragma ctrlchar                '\'
  21. #pragma compress                1
  22.  
  23. //**********************************************
  24. //* Weapon Settings.                           *
  25. //**********************************************
  26.  
  27. #define WEAPON_REFERANCE            "weapon_knife"
  28.  
  29. #define WEAPON_MODEL_VIEW           "models/v_stormgiant2.mdl"
  30. #define WEAPON_MODEL_PLAYER         "models/p_stormgiant.mdl"
  31.  
  32. #define WEAPON_DAMAGE               random_float(250.0, 3500.0)
  33. #define WEAPON_DAMAGE_STAB          random_float(300.0, 550.0)
  34. #define WEAPON_DAMAGE_DRAW          random_float(150.0, 200.0)
  35.  
  36. #define WEAPON_DISTANCE_ATTACK          99.0
  37. #define WEAPON_DISTANCE_ATTACK_STAB     110.0
  38.  
  39. #define WEAPON_KNOCKBACK            7.0
  40. #define WEAPON_KNOCKBACK_STAB           10.0
  41.  
  42. #define SOUND_HIT               "weapons/stormgiant_hit1.wav"
  43. #define SOUND_HIT_WALL              "weapons/stormgiant_stone1.wav"
  44. #define SOUND_DRAW              "weapons/stormgiant_draw.wav"
  45. #define SOUND_STAB_MISS             "weapons/stormgiant_stab_miss.wav"
  46.  
  47. #define ANIM_EXTENSION              "knife"
  48.  
  49. enum
  50. {  
  51.     ANIM_IDLE,
  52.    
  53.     ANIM_DRAW_ATTACK,
  54.     ANIM_DRAW_ATTACK1,
  55.    
  56.     ANIM_DRAW,
  57.    
  58.     ANIM_SLASH_START,
  59.     ANIM_SLASH_END,
  60.     ANIM_SLASH_END2,
  61.  
  62.     ANIM_STAB_START,
  63.     ANIM_STAB_END,
  64.     ANIM_STAB_END2,
  65.    
  66.     ANIM_MSLASH1,
  67.     ANIM_MSLASH2,
  68.     ANIM_MSLASH3
  69. };
  70.  
  71. //**********************************************
  72. //* Some macroses.                             *
  73. //**********************************************
  74. #define GET_SHOOTS(%0)          get_pdata_int(%0, m_fInCheckShoots, extra_offset_weapon)
  75. #define SET_SHOOTS(%0,%1)       set_pdata_int(%0, m_fInCheckShoots, %1, extra_offset_weapon)
  76.  
  77. #define MDLL_Spawn(%0)          dllfunc(DLLFunc_Spawn, %0)
  78. #define MDLL_Touch(%0,%1)       dllfunc(DLLFunc_Touch, %0, %1)
  79.  
  80. #define SET_MODEL(%0,%1)        engfunc(EngFunc_SetModel, %0, %1)
  81. #define SET_ORIGIN(%0,%1)       engfunc(EngFunc_SetOrigin, %0, %1)
  82.  
  83. #define PRECACHE_MODEL(%0)      engfunc(EngFunc_PrecacheModel, %0)
  84. #define PRECACHE_SOUND(%0)      engfunc(EngFunc_PrecacheSound, %0)
  85. #define PRECACHE_GENERIC(%0)        engfunc(EngFunc_PrecacheGeneric, %0)
  86.  
  87. #define MODEL_INDEX(%0)         engfunc(EngFunc_ModelIndex,%0)
  88.  
  89. #define MESSAGE_BEGIN(%0,%1,%2,%3)  engfunc(EngFunc_MessageBegin, %0, %1, %2, %3)
  90. #define MESSAGE_END()           message_end()
  91.  
  92. #define WRITE_ANGLE(%0)         engfunc(EngFunc_WriteAngle, %0)
  93. #define WRITE_BYTE(%0)          write_byte(%0)
  94. #define WRITE_COORD(%0)         engfunc(EngFunc_WriteCoord, %0)
  95. #define WRITE_STRING(%0)        write_string(%0)
  96. #define WRITE_SHORT(%0)         write_short(%0)
  97.  
  98. #define INSTANCE(%0)            ((%0 == -1) ? 0 : %0)
  99.  
  100. #define BitSet(%0,%1)           (%0 |= (1 << (%1 - 1)))
  101. #define BitClear(%0,%1)         (%0 &= ~(1 << (%1 - 1)))
  102. #define BitCheck(%0,%1)         (%0 & (1 << (%1 - 1)))
  103.  
  104. //**********************************************
  105. //* PvData Offsets.                            *
  106. //**********************************************
  107.  
  108. // Linux extra offsets
  109. #define extra_offset_weapon     4
  110. #define extra_offset_player     5
  111.  
  112. new g_bitIsConnected;
  113.  
  114. #define m_rgpPlayerItems_CWeaponBox 34
  115. #define m_fInCheckShoots        39
  116. #define m_pPlayer           41
  117. #define m_flNextPrimaryAttack       46
  118. #define m_flNextSecondaryAttack     47
  119. #define m_flTimeWeaponIdle      48
  120. #define m_iDirection            60
  121. #define m_fWeaponState          74
  122. #define m_LastHitGroup          75
  123. #define m_flNextAttack          83
  124. #define m_iLastZoom             109
  125. #define m_fResumeZoom           110
  126. #define m_iFOV              363
  127. #define m_pActiveItem           373
  128. #define m_szAnimExtention       492
  129.  
  130. #define IsValidPev(%0)          (pev_valid(%0) == 2)
  131.    
  132. new IsKnife[33];
  133. new iBlood[3];
  134.  
  135. Weapon_OnPrecache()
  136. {
  137.     PRECACHE_SOUNDS_FROM_MODEL(WEAPON_MODEL_VIEW);
  138.     PRECACHE_MODEL(WEAPON_MODEL_VIEW);
  139.     PRECACHE_MODEL(WEAPON_MODEL_PLAYER);
  140.  
  141.     PRECACHE_SOUND(SOUND_HIT);
  142.     PRECACHE_SOUND(SOUND_HIT_WALL);
  143.     PRECACHE_SOUND(SOUND_DRAW);
  144.     PRECACHE_SOUND(SOUND_STAB_MISS);
  145.    
  146.     iBlood[0] = PRECACHE_MODEL("sprites/bloodspray.spr");
  147.     iBlood[1] = PRECACHE_MODEL("sprites/blood.spr");
  148.     iBlood[2] = PRECACHE_MODEL("sprites/ef_coilmg.spr");
  149. }
  150.  
  151. Weapon_OnDeploy(const iItem, const iPlayer)
  152. {
  153.     #pragma unused iItem, iPlayer
  154.  
  155.     Weapon_DefaultDeploy(iPlayer, WEAPON_MODEL_VIEW, WEAPON_MODEL_PLAYER, ANIM_DRAW_ATTACK, ANIM_EXTENSION);
  156.            
  157.     set_pdata_float(iItem, m_flTimeWeaponIdle, 0.6, extra_offset_weapon);
  158.     set_pdata_float(iPlayer, m_flNextAttack, 0.4, extra_offset_player);
  159.    
  160.     engfunc(EngFunc_EmitSound, iPlayer, CHAN_WEAPON, SOUND_DRAW, 0.9, ATTN_NORM, 0, PITCH_NORM);
  161.    
  162.     set_pev(iItem, pev_fuser3, get_gametime() + 0.2);
  163.     set_pev(iItem, pev_fuser4, get_gametime() + 0.6);
  164.     set_pev(iItem, pev_iuser1, 1);
  165. }
  166.  
  167. Weapon_OnHolster(const iItem, const iPlayer)
  168. {
  169.     #pragma unused iItem, iPlayer
  170.  
  171.     set_pev(iItem, pev_fuser1, 0.0);
  172.     set_pev(iItem, pev_fuser2, 0.0);
  173.     set_pev(iItem, pev_fuser3, 0.0);
  174.     set_pev(iItem, pev_fuser4, 0.0);
  175.    
  176.     set_pev(iItem, pev_iuser1, 0);
  177. }
  178.  
  179. Weapon_OnIdle(const iItem, const iPlayer)
  180. {
  181.     #pragma unused iItem, iPlayer
  182.    
  183.     ExecuteHamB(Ham_Weapon_ResetEmptySound, iItem);
  184.  
  185.     if (get_pdata_int(iItem, m_flTimeWeaponIdle, extra_offset_weapon) > 0.0)
  186.     {
  187.         return;
  188.     }
  189.    
  190.     Weapon_SendAnim(iPlayer, ANIM_IDLE);   
  191.     set_pdata_float(iItem, m_flTimeWeaponIdle, 10.0, extra_offset_weapon);
  192. }
  193.  
  194. Weapon_OnPrimaryAttack(const iItem, const iPlayer)
  195. {
  196.     #pragma unused iItem, iPlayer
  197.    
  198.     static szAnimation[64];
  199.  
  200.     formatex(szAnimation, charsmax(szAnimation), "ref_shoot_%s", ANIM_EXTENSION);
  201.            
  202.     Weapon_SendAnim(iPlayer, ANIM_SLASH_START);
  203.                    
  204.     set_pdata_float(iItem, m_flTimeWeaponIdle, 2.0, extra_offset_weapon);
  205.     set_pdata_float(iItem, m_flNextPrimaryAttack, 1.5, extra_offset_weapon);
  206.     set_pdata_float(iItem, m_flNextSecondaryAttack, 1.5, extra_offset_weapon);
  207.                    
  208.     Player_SetAnimation(iPlayer, szAnimation);
  209.    
  210.     set_pev(iItem ,pev_fuser1, get_gametime() + 1.0);
  211. }
  212.  
  213. public Weapon_OnSecondaryAttack(const iItem, const iPlayer)
  214. {
  215.     #pragma unused iItem, iPlayer
  216.    
  217.     static szAnimation[64];formatex(szAnimation, charsmax(szAnimation), "ref_shoot_%s", ANIM_EXTENSION);
  218.    
  219.     static Float:iTime;pev(iItem, pev_fuser3, iTime);
  220.    
  221.     if (pev(iItem, pev_iuser1) && !iTime)
  222.     {
  223.         WeaponStab(iPlayer, iItem);
  224.         set_pdata_float(iItem, m_flNextPrimaryAttack, 1.0, extra_offset_weapon);
  225.         set_pdata_float(iItem, m_flNextSecondaryAttack, 1.0, extra_offset_weapon);
  226.        
  227.         set_pev(iItem, pev_iuser1, 0);
  228.         set_pev(iItem, pev_fuser4, 0.0);
  229.     }
  230.     else
  231.     {
  232.        
  233.         Weapon_SendAnim(iPlayer, ANIM_STAB_START);
  234.        
  235.         set_pdata_float(iItem, m_flTimeWeaponIdle, 2.0, extra_offset_weapon);
  236.         set_pdata_float(iItem, m_flNextPrimaryAttack, 1.5, extra_offset_weapon);
  237.         set_pdata_float(iItem, m_flNextSecondaryAttack, 1.5, extra_offset_weapon);
  238.        
  239.         Player_SetAnimation(iPlayer, szAnimation);
  240.        
  241.         set_pev(iItem ,pev_fuser2, get_gametime() + 1.0);
  242.     }
  243. }
  244.  
  245. //*********************************************************************
  246. //*           Don't modify the code below this line unless            *
  247. //*              you know _exactly_ what you are doing!!!             *
  248. //*********************************************************************
  249.  
  250. public plugin_precache()
  251. {
  252.     Weapon_OnPrecache();
  253. }
  254.  
  255. public plugin_init()
  256. {
  257.     register_plugin(PLUGIN, VERSION, AUTHOR);
  258.    
  259.     RegisterHam(Ham_Item_Deploy,            WEAPON_REFERANCE,   "HamHook_Item_Deploy_Post",     true);
  260.     RegisterHam(Ham_Item_Holster,           WEAPON_REFERANCE,   "HamHook_Item_Holster",         false);
  261.    
  262.     RegisterHam(Ham_Weapon_WeaponIdle,      WEAPON_REFERANCE,   "HamHook_Item_WeaponIdle",      false);
  263.     RegisterHam(Ham_Weapon_PrimaryAttack,       WEAPON_REFERANCE,   "HamHook_Item_PrimaryAttack",       false);
  264.     RegisterHam(Ham_Weapon_SecondaryAttack,         WEAPON_REFERANCE,   "HamHook_Item_SecondaryAttack",     false);
  265.  
  266.     RegisterHam(Ham_Spawn,              "player",       "HamHook_Player_Spawn",         true);
  267.     RegisterHam(Ham_Killed,                 "player",       "HamHook_Player_Killed",        false);
  268.  
  269.     register_forward(FM_UpdateClientData,                   "FakeMeta_UpdateClientData_Post",   true);
  270.  
  271.     register_clcmd("GetWarHammer",                      "native_set_user_knife");
  272.     register_clcmd("DelWarHammer",                      "native_delete_user_knife");
  273. }
  274.  
  275. public plugin_natives()
  276. {
  277.     register_native("SetUserWarHammer", "native_set_user_knife", true);
  278.     register_native("DelUserWarHammer", "native_delete_user_knife", true) ;
  279. }
  280.  
  281. public native_set_user_knife(iPlayer)
  282. {
  283.     IsKnife[iPlayer] = true;
  284.     Weapon_Select(iPlayer);
  285. }
  286.  
  287. public native_delete_user_knife(iPlayer)
  288. {
  289.     IsKnife[iPlayer] = false;
  290.    
  291.     new iItem = get_pdata_cbase(iPlayer, m_pActiveItem, extra_offset_player);
  292.     if (pev_valid(iItem))
  293.     {
  294.         ExecuteHamB(Ham_Item_Deploy, iItem);
  295.     }
  296. }
  297.  
  298. //**********************************************
  299. //* Block client weapon.                       *
  300. //**********************************************
  301. public FakeMeta_UpdateClientData_Post(const iPlayer, const iSendWeapons, const CD_Handle)
  302. {
  303.     static iActiveItem;iActiveItem = get_pdata_cbase(iPlayer, m_pActiveItem, extra_offset_player);
  304.    
  305.     if(zp_get_user_zombie(iPlayer) || !IsKnife[iPlayer])
  306.     {
  307.         return FMRES_IGNORED;
  308.     }
  309.    
  310.     if (!IsValidPev(iActiveItem) || get_user_weapon(iPlayer) != CSW_KNIFE)
  311.     {
  312.         return FMRES_IGNORED;
  313.     }
  314.    
  315.     if (!IsKnife[iPlayer])
  316.     {  
  317.         return FMRES_IGNORED;
  318.     }
  319.    
  320.     static Float:iTime3;pev(iActiveItem, pev_fuser3, iTime3);
  321.    
  322.     if (iTime3 && iTime3 <= get_gametime())
  323.     {
  324.         WeaponSlashDraw(iPlayer, iActiveItem);
  325.         set_pev(iActiveItem, pev_fuser3, 0.0);
  326.     }
  327.    
  328.     static Float:iTime4;pev(iActiveItem, pev_fuser4, iTime4);
  329.    
  330.     if (iTime4 && iTime4 <= get_gametime())
  331.     {
  332.         Weapon_SendAnim(iPlayer, ANIM_DRAW);
  333.    
  334.         set_pdata_float(iActiveItem, m_flTimeWeaponIdle, 1.0, extra_offset_weapon);
  335.        
  336.         set_pev(iActiveItem, pev_fuser4, 0.0);
  337.         set_pev(iActiveItem, pev_iuser1, 0);
  338.     }
  339.    
  340.     static Float:iTime;pev(iActiveItem, pev_fuser1, iTime);
  341.    
  342.     if (iTime && iTime <= get_gametime())
  343.     {
  344.         WeaponSlash(iPlayer, iActiveItem);
  345.         set_pev(iActiveItem, pev_fuser1, 0.0);
  346.     }
  347.    
  348.     static Float:iTime2;pev(iActiveItem, pev_fuser2, iTime2);
  349.    
  350.     if (iTime2 && iTime2 <= get_gametime())
  351.     {
  352.         WeaponStab(iPlayer, iActiveItem);
  353.         set_pev(iActiveItem, pev_fuser2, 0.0);
  354.     }
  355.  
  356.     set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001);
  357.    
  358.     return FMRES_IGNORED;
  359. }
  360.  
  361. //**********************************************
  362. //* Item (weapon) hooks.                       *
  363. //**********************************************
  364.     #define _call.%0(%1,%2) \
  365.                                 \
  366.     Weapon_On%0                     \
  367.     (                           \
  368.         %1,                         \
  369.         %2                      \
  370.     )
  371.  
  372. public HamHook_Item_Deploy_Post(const iItem)
  373. {
  374.     new iPlayer;
  375.    
  376.     if (!CheckItem(iItem, iPlayer))
  377.     {
  378.         return HAM_IGNORED;
  379.     }
  380.    
  381.     _call.Deploy(iItem, iPlayer);
  382.     return HAM_IGNORED;
  383. }
  384.  
  385. public HamHook_Item_Holster(const iItem)
  386. {
  387.     new iPlayer;
  388.    
  389.     if (!CheckItem(iItem, iPlayer))
  390.     {
  391.         return HAM_IGNORED;
  392.     }
  393.    
  394.     set_pev(iPlayer, pev_viewmodel, 0);
  395.     set_pev(iPlayer, pev_weaponmodel, 0);
  396.    
  397.     _call.Holster(iItem, iPlayer);
  398.     return HAM_SUPERCEDE;
  399. }
  400.  
  401. public HamHook_Item_WeaponIdle(const iItem)
  402. {
  403.     static iPlayer;
  404.    
  405.     if (!CheckItem(iItem, iPlayer))
  406.     {
  407.         return HAM_IGNORED;
  408.     }
  409.  
  410.     _call.Idle(iItem, iPlayer);
  411.     return HAM_SUPERCEDE;
  412. }
  413.  
  414. public HamHook_Item_PrimaryAttack(const iItem)
  415. {
  416.     static iPlayer;
  417.    
  418.     if (!CheckItem(iItem, iPlayer))
  419.     {
  420.         return HAM_IGNORED;
  421.     }
  422.  
  423.     _call.PrimaryAttack(iItem, iPlayer);
  424.     return HAM_SUPERCEDE;
  425. }
  426.  
  427. public HamHook_Item_SecondaryAttack(const iItem)
  428. {
  429.     static iPlayer;
  430.    
  431.     if (!CheckItem(iItem, iPlayer))
  432.     {
  433.         return HAM_IGNORED;
  434.     }
  435.    
  436.     _call.SecondaryAttack(iItem, iPlayer);
  437.     return HAM_SUPERCEDE;
  438. }
  439.  
  440. public HamHook_Player_Spawn(iPlayer)
  441. {
  442.     if(is_user_alive(iPlayer))
  443.     {
  444.         new iItem = get_pdata_cbase(iPlayer, m_pActiveItem, extra_offset_player);
  445.  
  446.         if (pev_valid(iItem))
  447.         {
  448.             ExecuteHamB(Ham_Item_Deploy, iItem);
  449.         }
  450.     }
  451. }
  452.  
  453. public HamHook_Player_Killed(const iPlayer)
  454. {
  455.     IsKnife[iPlayer] = false;
  456. }
  457.  
  458. public WeaponSlashDraw(const iPlayer, const iItem)
  459. {
  460.     PrimarySlash_Attack(iPlayer, iItem, 0.0,0.0, false, true);
  461. }
  462.  
  463. public WeaponSlash(const iPlayer, const iItem)
  464. {
  465.     PrimarySlash_Attack(iPlayer, iItem);
  466. }
  467.  
  468. public WeaponStab(const iPlayer, const iItem)
  469. {
  470.     PrimarySlash_Attack(iPlayer, iItem, 0.0,0.0,true);
  471. }
  472.  
  473. //**********************************************
  474. //* Attack function.                           *
  475. //**********************************************
  476.  
  477. PrimarySlash_Attack(const iPlayer, const iItem, const Float: flRightScale = 1.0, const Float: flUpScale = 1.0, bool:bStab=false, bool:bDraw=false)
  478. {
  479.     new Float: Origin[3];
  480.     new Float: vecEnd[3];
  481.     new Float: vecScr[3];
  482.    
  483.     new Float: flFraction;
  484.    
  485.     new iTrace;
  486.     new iVictim;
  487.    
  488.     Weapon_GetGunPosition(iPlayer, Origin, vecScr, 0.0, flRightScale, flUpScale);
  489.    
  490.     angle_vector(vecScr, ANGLEVECTOR_FORWARD, vecScr);
  491.  
  492.     if (bDraw)
  493.     {
  494.         xs_vec_mul_scalar(vecScr, 80.0, vecEnd);
  495.     }
  496.     else
  497.     {
  498.         xs_vec_mul_scalar(vecScr, bStab ? WEAPON_DISTANCE_ATTACK_STAB:WEAPON_DISTANCE_ATTACK, vecEnd);
  499.     }
  500.  
  501.     xs_vec_add(Origin, vecEnd, vecEnd);
  502.    
  503.     engfunc(EngFunc_TraceLine, Origin, vecEnd, DONT_IGNORE_MONSTERS, iPlayer, (iTrace = create_tr2()));
  504.     get_tr2(iTrace, TR_flFraction, flFraction);
  505.    
  506.     if (!bDraw)
  507.     {
  508.         switch (bStab)
  509.         {
  510.             case false:
  511.             {
  512.                 Weapon_SendAnim(iPlayer, ANIM_SLASH_END);
  513.                        
  514.                 set_pdata_float(iItem, m_flTimeWeaponIdle, 2.0, extra_offset_weapon);
  515.             }
  516.             case true:
  517.             {
  518.                 Weapon_SendAnim(iPlayer, ANIM_STAB_END);
  519.                        
  520.                 set_pdata_float(iItem, m_flTimeWeaponIdle, 1.0, extra_offset_weapon);
  521.                 engfunc(EngFunc_EmitSound, iPlayer, CHAN_ITEM, SOUND_STAB_MISS, 0.8, ATTN_NORM, 0, PITCH_NORM);
  522.             }
  523.         }
  524.     }
  525.    
  526.     if (flFraction >= 1.0)
  527.     {
  528.         engfunc(EngFunc_TraceHull, Origin, vecEnd, DONT_IGNORE_MONSTERS, HULL_HEAD, iPlayer, iTrace);
  529.         get_tr2(iTrace, TR_flFraction, flFraction);
  530.        
  531.         if (flFraction < 1.0)
  532.         {
  533.             iVictim = INSTANCE(get_tr2(iTrace, TR_pHit));
  534.            
  535.             if (!iVictim || ExecuteHamB(Ham_IsBSPModel, iVictim))
  536.             {
  537.                 FindHullIntersection(Origin, iTrace, Float: {-16.0, -16.0, -18.0}, Float: {16.0,  16.0,  18.0}, iPlayer);
  538.             }
  539.         }
  540.     }
  541.  
  542.     get_tr2(iTrace, TR_flFraction, flFraction);
  543.    
  544.     if (flFraction < 1.0)
  545.     {
  546.         iVictim = INSTANCE(get_tr2(iTrace, TR_pHit));
  547.         new Float:iDamage;
  548.         if (bDraw)
  549.         {
  550.             iDamage = WEAPON_DAMAGE_DRAW;
  551.         }
  552.         else
  553.         {
  554.             iDamage = (bStab ? WEAPON_DAMAGE_STAB:WEAPON_DAMAGE);
  555.         }
  556.        
  557.         if(iVictim > 0 && pev(iVictim, pev_takedamage) != DAMAGE_NO && pev(iVictim, pev_solid) != SOLID_NOT)
  558.         {  
  559.             if(ExecuteHamB(Ham_IsPlayer, iVictim))
  560.             {
  561.                 engfunc(EngFunc_EmitSound, iPlayer, CHAN_ITEM, SOUND_HIT, 0.8, ATTN_NORM, 0, PITCH_NORM);
  562.                
  563.                 if(!zp_get_user_zombie(iVictim))
  564.                 {
  565.                     return;
  566.                 }
  567.                
  568.                 new Float:vecViewAngle[3]; pev(iPlayer, pev_v_angle, vecViewAngle);
  569.                 new Float:vecForward[3]; angle_vector(vecViewAngle, ANGLEVECTOR_FORWARD, vecForward);
  570.    
  571.                 FakeKnockBack(iVictim, vecForward, bStab ? WEAPON_KNOCKBACK_STAB:WEAPON_KNOCKBACK);
  572.                
  573.                 get_tr2(iTrace, TR_vecEndPos, vecEnd);
  574.                 Create_Blood(vecEnd, iBlood[0], iBlood[1], 76, 10);
  575.                 CreateExplosion(vecEnd, -10.0, iBlood[2], 2, 9, TE_EXPLFLAG_NODLIGHTS|TE_EXPLFLAG_NOPARTICLES|TE_EXPLFLAG_NOSOUND);
  576.                
  577.                 static iHitGroup;
  578.                 switch ((iHitGroup = get_tr2(iTrace, TR_iHitgroup)))
  579.                 {
  580.                     case HIT_HEAD:iDamage *= 2;
  581.                     case HIT_CHEST:iDamage *= 1;
  582.                     case HIT_STOMACH:iDamage *= 1.25;
  583.                     case HIT_LEFTARM,HIT_RIGHTARM:iDamage *= 1;
  584.                     case HIT_LEFTLEG,HIT_RIGHTLEG:iDamage *= 0.75;
  585.                 }
  586.                 set_pdata_int(iVictim, m_LastHitGroup, iHitGroup, extra_offset_player);
  587.             }
  588.            
  589.             ExecuteHamB(Ham_TakeDamage, iVictim, iItem, iPlayer, iDamage, DMG_CLUB | DMG_NEVERGIB);
  590.         }
  591.         else
  592.         {
  593.             get_tr2(iTrace, TR_vecEndPos, vecEnd);
  594.             CreateExplosion(vecEnd, -10.0, iBlood[2], 2, 9, TE_EXPLFLAG_NODLIGHTS|TE_EXPLFLAG_NOPARTICLES|TE_EXPLFLAG_NOSOUND);
  595.             engfunc(EngFunc_EmitSound, iPlayer, CHAN_ITEM, SOUND_HIT_WALL, 0.8, ATTN_NORM, 0, PITCH_NORM);
  596.         }
  597.     }
  598.  
  599.     free_tr2(iTrace);
  600. }
  601.  
  602. //**********************************************
  603. //* Create and check our custom weapon.        *
  604. //**********************************************
  605.  
  606. Weapon_SendAnim(const iPlayer, const iAnim)
  607. {
  608.     set_pev(iPlayer, pev_weaponanim, iAnim);
  609.  
  610.     MESSAGE_BEGIN(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0.0, 0.0, 0.0}, iPlayer);
  611.     WRITE_BYTE(iAnim);
  612.     WRITE_BYTE(0);
  613.     MESSAGE_END();
  614. }
  615.  
  616. stock Weapon_DefaultDeploy(const iPlayer, const szViewModel[], const szWeaponModel[], const iAnim, const szAnimExt[])
  617. {
  618.     set_pev(iPlayer, pev_viewmodel2, szViewModel);
  619.     set_pev(iPlayer, pev_weaponmodel2, szWeaponModel);
  620.     set_pev(iPlayer, pev_fov, 90.0);
  621.    
  622.     set_pdata_int(iPlayer, m_iFOV, 90, extra_offset_player);
  623.     set_pdata_int(iPlayer, m_fResumeZoom, 0, extra_offset_player);
  624.     set_pdata_int(iPlayer, m_iLastZoom, 90, extra_offset_player);
  625.    
  626.     set_pdata_string(iPlayer, m_szAnimExtention * 4, szAnimExt, -1, extra_offset_player * 4);
  627.  
  628.     Weapon_SendAnim(iPlayer, iAnim);
  629. }
  630.  
  631. stock Create_Blood(const Float:vStart[3], const iModel, const iModel2, const iColor, const iScale)
  632. {
  633.     MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY, vStart, 0);
  634.     WRITE_BYTE(TE_BLOODSPRITE);
  635.     WRITE_COORD(vStart[0])
  636.     WRITE_COORD(vStart[1])
  637.     WRITE_COORD(vStart[2])
  638.     WRITE_SHORT(iModel);
  639.     WRITE_SHORT(iModel2);
  640.     WRITE_BYTE(iColor);
  641.     WRITE_BYTE(iScale);
  642.     MESSAGE_END();
  643. }
  644.  
  645. public client_putinserver(id)
  646. {
  647.     BitSet(g_bitIsConnected, id);
  648. }
  649.  
  650. public client_disconnected(id)
  651. {
  652.     BitClear(g_bitIsConnected, id);
  653. }
  654.  
  655. bool: CheckItem(const iItem, &iPlayer)
  656. {
  657.     if (!IsValidPev(iItem))
  658.     {
  659.         return false;
  660.     }
  661.    
  662.     iPlayer = get_pdata_cbase(iItem, m_pPlayer, extra_offset_weapon);
  663.    
  664.     if (!BitCheck(g_bitIsConnected, iPlayer) || !IsValidPev(iPlayer) || zp_get_user_zombie(iPlayer) || !IsKnife[iPlayer])
  665.     {
  666.         return false;
  667.     }
  668.    
  669.     return true;
  670. }
  671.  
  672. bool: CheckItem2(const iPlayer, &iItem)
  673. {
  674.     if (!BitCheck(g_bitIsConnected, iPlayer) || !IsValidPev(iPlayer) || zp_get_user_zombie(iPlayer) || get_user_weapon(iPlayer) != CSW_KNIFE)
  675.     {
  676.         return false;
  677.     }
  678.    
  679.     iItem = get_pdata_cbase(iPlayer, m_pActiveItem, extra_offset_player);
  680.    
  681.     if (!IsValidPev(iItem) || !IsKnife[iPlayer])
  682.     {
  683.         return false;
  684.     }
  685.    
  686.     return true;
  687. }
  688.  
  689. //**********************************************
  690. //* Some usefull stocks.                       *
  691. //**********************************************
  692.  
  693. stock Weapon_GetGunPosition(const iPlayer, Float: fOrigin[3], Float: fAngles[3], Float: add_forward = 0.0, Float: add_right = 0.0, Float: add_up = 0.0)
  694. {
  695.     static Float: Forward[3], Float: Right[3], Float: Up[3];
  696.  
  697.     if (IsValidPev(iPlayer)) ExecuteHamB(Ham_Player_GetGunPosition, iPlayer, fOrigin);
  698.    
  699.     pev(iPlayer, pev_angles, fAngles);
  700.     pev(iPlayer, pev_v_angle, fAngles);
  701.    
  702.     global_get(glb_v_forward, Forward);
  703.     global_get(glb_v_right, Right);
  704.     global_get(glb_v_up, Up);
  705.    
  706.     xs_vec_mul_scalar(Forward, add_forward, Forward);
  707.     xs_vec_mul_scalar(Right, add_right, Right);
  708.     xs_vec_mul_scalar(Up, add_up, Up);
  709.    
  710.     fOrigin[0] = fOrigin[0] + Forward[0] + Right[0] + Up[0];
  711.     fOrigin[1] = fOrigin[1] + Forward[1] + Right[1] + Up[1];
  712.     fOrigin[2] = fOrigin[2] + Forward[2] + Right[2] + Up[2];
  713. }
  714.  
  715. stock FindHullIntersection(const Float: vecSrc[3], &iTrace, const Float: vecMins[3], const Float: vecMaxs[3], const iEntity)
  716. {
  717.     new iTempTrace;
  718.    
  719.     new Float: flFraction;
  720.     new Float: flThisDistance;
  721.    
  722.     new Float: vecEnd[3];
  723.     new Float: vecEndPos[3];
  724.     new Float: vecHullEnd[3];
  725.     new Float: vecMinMaxs[2][3];
  726.    
  727.     new Float: flDistance = 999999.0;
  728.    
  729.     xs_vec_copy(vecMins, vecMinMaxs[0]);
  730.     xs_vec_copy(vecMaxs, vecMinMaxs[1]);
  731.    
  732.     get_tr2(iTrace, TR_vecEndPos, vecHullEnd);
  733.    
  734.     xs_vec_sub(vecHullEnd, vecSrc, vecHullEnd);
  735.     xs_vec_mul_scalar(vecHullEnd, 2.0, vecHullEnd);
  736.     xs_vec_add(vecHullEnd, vecSrc, vecHullEnd);
  737.    
  738.     engfunc(EngFunc_TraceLine, vecSrc, vecHullEnd, DONT_IGNORE_MONSTERS, iEntity, (iTempTrace = create_tr2()));
  739.     get_tr2(iTempTrace, TR_flFraction, flFraction);
  740.    
  741.     if (flFraction < 1.0)
  742.     {
  743.         free_tr2(iTrace);
  744.        
  745.         iTrace = iTempTrace;
  746.         return;
  747.     }
  748.    
  749.     for (new j, k, i = 0; i < 2; i++)
  750.     {
  751.         for (j = 0; j < 2; j++)
  752.         {
  753.             for (k = 0; k < 2; k++)
  754.             {
  755.                 vecEnd[0] = vecHullEnd[0] + vecMinMaxs[i][0];
  756.                 vecEnd[1] = vecHullEnd[1] + vecMinMaxs[j][1];
  757.                 vecEnd[2] = vecHullEnd[2] + vecMinMaxs[k][2];
  758.                
  759.                 engfunc(EngFunc_TraceLine, vecSrc, vecEnd, DONT_IGNORE_MONSTERS, iEntity, iTempTrace);
  760.                 get_tr2(iTempTrace, TR_flFraction, flFraction);
  761.                
  762.                 if (flFraction < 1.0)
  763.                 {
  764.                     get_tr2(iTempTrace, TR_vecEndPos, vecEndPos);
  765.                     xs_vec_sub(vecEndPos, vecSrc, vecEndPos);
  766.                    
  767.                     if ((flThisDistance = xs_vec_len(vecEndPos)) < flDistance)
  768.                     {
  769.                         free_tr2(iTrace);
  770.                        
  771.                         iTrace = iTempTrace;
  772.                         flDistance = flThisDistance;
  773.                     }
  774.                 }
  775.             }
  776.         }
  777.     }
  778. }
  779.  
  780. stock CreateExplosion(const Float:Origin[3], const Float:CordZ = 0.0, const iModel, const iScale, const iFramerate, const iFlag)
  781. {
  782.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  783.     write_byte(TE_EXPLOSION);
  784.     engfunc(EngFunc_WriteCoord, Origin[0]);
  785.     engfunc(EngFunc_WriteCoord, Origin[1]);
  786.     engfunc(EngFunc_WriteCoord, Origin[2]  + CordZ);
  787.     write_short(iModel);
  788.     write_byte(iScale);
  789.     write_byte(iFramerate);
  790.     write_byte(iFlag);
  791.     message_end();
  792. }
  793.  
  794. stock FakeKnockBack(iPlayer, Float:vecDirection[3], Float:flKnockBack)
  795. {
  796.     static Float:vecVelocity[3]; pev(iPlayer, pev_velocity, vecVelocity);
  797.    
  798.     if (pev(iPlayer, pev_flags) & FL_DUCKING)
  799.     {
  800.         flKnockBack *= 0.7;
  801.     }
  802.    
  803.     vecVelocity[0] = vecDirection[0] * 500.0 * flKnockBack;
  804.     vecVelocity[1] = vecDirection[1] * 500.0 * flKnockBack;
  805.     vecVelocity[2] = 300.0;
  806.    
  807.     set_pev(iPlayer, pev_velocity, vecVelocity);
  808. }
  809.  
  810. stock Player_SetAnimation(const iPlayer, const szAnim[])
  811. {
  812.     #define ACT_RANGE_ATTACK1   28
  813.        
  814.     // Linux extra offsets
  815.     #define extra_offset_animating   4
  816.        
  817.     // CBaseAnimating
  818.     #define m_flFrameRate      36
  819.     #define m_flGroundSpeed      37
  820.     #define m_flLastEventCheck   38
  821.     #define m_fSequenceFinished   39
  822.     #define m_fSequenceLoops   40
  823.        
  824.     // CBaseMonster
  825.     #define m_Activity      73
  826.     #define m_IdealActivity      74
  827.        
  828.        // CBasePlayer
  829.     #define m_flLastAttackTime   220
  830.    
  831.     new iAnimDesired, Float: flFrameRate, Float: flGroundSpeed, bool: bLoops;
  832.          
  833.     if ((iAnimDesired = lookup_sequence(iPlayer, szAnim, flFrameRate, bLoops, flGroundSpeed)) == -1)
  834.     {
  835.         iAnimDesired = 0;
  836.     }
  837.        
  838.     new Float: flGametime = get_gametime();
  839.    
  840.     set_pev(iPlayer, pev_frame, 0.0);
  841.     set_pev(iPlayer, pev_framerate, 1.0);
  842.     set_pev(iPlayer, pev_animtime, flGametime);
  843.     set_pev(iPlayer, pev_sequence, iAnimDesired);
  844.        
  845.     set_pdata_int(iPlayer, m_fSequenceLoops, bLoops, extra_offset_animating);
  846.     set_pdata_int(iPlayer, m_fSequenceFinished, 0, extra_offset_animating);
  847.        
  848.     set_pdata_float(iPlayer, m_flFrameRate, flFrameRate, extra_offset_animating);
  849.     set_pdata_float(iPlayer, m_flGroundSpeed, flGroundSpeed, extra_offset_animating);
  850.     set_pdata_float(iPlayer, m_flLastEventCheck, flGametime , extra_offset_animating);
  851.        
  852.     set_pdata_int(iPlayer, m_Activity, ACT_RANGE_ATTACK1, extra_offset_player);
  853.     set_pdata_int(iPlayer, m_IdealActivity, ACT_RANGE_ATTACK1, extra_offset_player);  
  854.     set_pdata_float(iPlayer, m_flLastAttackTime, flGametime , extra_offset_player);
  855. }
  856.  
  857. #if !defined _ZP
  858. public zp_user_infected_post(iPlayer)
  859. {
  860.     IsKnife[iPlayer] = false;
  861. }
  862. #else
  863. public ze_user_infected_pre(iVictim, iInfector, iDamage)
  864. {
  865.     IsKnife[iVictim] = false;
  866. }
  867. #endif
  868.  
  869. public Weapon_Select(const iPlayer)
  870. {
  871.     engclient_cmd(iPlayer, WEAPON_REFERANCE);
  872.    
  873.     IsKnife[iPlayer] = true;
  874.    
  875.     emessage_begin(MSG_ONE, get_user_msgid("CurWeapon"), _, iPlayer);
  876.     ewrite_byte(1);
  877.     ewrite_byte(CSW_KNIFE);
  878.     ewrite_byte(-1);
  879.     emessage_end();
  880.    
  881.     new iItem = get_pdata_cbase(iPlayer, m_pActiveItem, extra_offset_player);
  882.  
  883.     if (pev_valid(iItem))
  884.     {
  885.         ExecuteHamB(Ham_Item_Deploy, iItem);
  886.     }
  887. }
  888.  
  889. PRECACHE_SOUNDS_FROM_MODEL(const szModelPath[])
  890. {
  891.     new iFile;
  892.    
  893.     if ((iFile = fopen(szModelPath, "rt")))
  894.     {
  895.         new szSoundPath[64];
  896.        
  897.         new iNumSeq, iSeqIndex;
  898.         new iEvent, iNumEvents, iEventIndex;
  899.        
  900.         fseek(iFile, 164, SEEK_SET);
  901.         fread(iFile, iNumSeq, BLOCK_INT);
  902.         fread(iFile, iSeqIndex, BLOCK_INT);
  903.        
  904.         for (new k, i = 0; i < iNumSeq; i++)
  905.         {
  906.             fseek(iFile, iSeqIndex + 48 + 176 * i, SEEK_SET);
  907.             fread(iFile, iNumEvents, BLOCK_INT);
  908.             fread(iFile, iEventIndex, BLOCK_INT);
  909.             fseek(iFile, iEventIndex + 176 * i, SEEK_SET);
  910.  
  911.             for (k = 0; k < iNumEvents; k++)
  912.             {
  913.                 fseek(iFile, iEventIndex + 4 + 76 * k, SEEK_SET);
  914.                 fread(iFile, iEvent, BLOCK_INT);
  915.                 fseek(iFile, 4, SEEK_CUR);
  916.                
  917.                 if (iEvent != 5004)
  918.                 {
  919.                     continue;
  920.                 }
  921.  
  922.                 fread_blocks(iFile, szSoundPath, 64, BLOCK_CHAR);
  923.                
  924.                 if (strlen(szSoundPath))
  925.                 {
  926.                     strtolower(szSoundPath);
  927.                     PRECACHE_SOUND(szSoundPath);
  928.                 }
  929.             }
  930.         }
  931.     }
  932.     fclose(iFile);
  933. }
  934. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  935. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
  936. */
Image

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 399
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#2

Post by Muhammet20 » 2 Months Ago

who converted this warhammer?
if not Raheem or Jack give me the original ZP once i will convert it to you because i think this won't work
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 529
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

#3

Post by czirimbolo » 2 Months Ago

Muhammet20 wrote:
2 Months Ago
who converted this warhammer?
if not Raheem or Jack give me the original ZP once i will convert it to you because i think this won't work
Warhammer works fine without knife menu. When I added this to knife menu, I see this knife in menu and I can even choose him. The problem is when I add second knife or more to this knife menu, server is crashing sometimes. Something must be wrong in knife menu
Image

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 399
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#4

Post by Muhammet20 » 2 Months Ago

czirimbolo wrote:
2 Months Ago
Hello,

I want to add extra knife plugin to my knife menu. Its working with one extra knife, but when I add more, the server is crashing with Segmentation Fault. Raheem or Jack can you take a look here and add knife plugin to this menu? New knife cost: 500 coins

Knife menu:
  1. #include <zombie_escape>
  2. #include <engine>
  3. #include <fun>
  4. #include <ze_vip>
  5.  
  6. #pragma tabsize 0
  7.  
  8. #define HOLYSWORD_COST 2600
  9.  
  10. // Models
  11. new const Storm_Models[][] =
  12. {
  13.     "models/v_axe.mdl",
  14.     "models/p_axe.mdl"
  15. }
  16.  
  17. new const Turbulent9_Models[][] =
  18. {
  19.     "models/v_turbulent9_knife.mdl",
  20.     "models/p_turbulent9_knife.mdl"
  21. }
  22.  
  23. new const Sabers_Models[][] =
  24. {
  25.     "models/v_laser_knife.mdl",
  26.     "models/p_laser_knife.mdl"
  27. }
  28.  
  29. new const Plasma_Models[][] =
  30. {
  31.     "models/v_stick.mdl",
  32.     "models/p_stick.mdl"
  33. }
  34.  
  35. new const Laevateinn_Models[][] =
  36. {
  37.     "models/v_black.mdl",
  38.     "models/p_black.mdl"
  39. }
  40.  
  41.  
  42.  
  43. // Sounds
  44. new const g_sound_knife[] = "items/gunpickup2.wav"
  45.  
  46. new const storm_sounds[][] =
  47. {
  48.     "zombie_escape/knife_menu/storm_sword_deploy.wav",
  49.     "zombie_escape/knife_menu/storm_sword_hit.wav",
  50.     "zombie_escape/knife_menu/storm_sword_hit.wav",
  51.     "zombie_escape/knife_menu/storm_sword_hit.wav",
  52.     "zombie_escape/knife_menu/storm_sword_hit.wav",
  53.     "zombie_escape/knife_menu/storm_sword_hitwall.wav",
  54.     "zombie_escape/knife_menu/storm_sword_slash.wav",
  55.     "zombie_escape/knife_menu/storm_sword_slash.wav",
  56.     "zombie_escape/knife_menu/storm_sword_stab.wav"
  57. }
  58.  
  59. new const turbulent9_sounds[][] =
  60. {
  61.     "zombie_escape/knife_menu/turbulent9_deploy.wav",
  62.     "zombie_escape/knife_menu/turbulent9_hit.wav",
  63.     "zombie_escape/knife_menu/turbulent9_hit.wav",
  64.     "zombie_escape/knife_menu/turbulent9_hit.wav",
  65.     "zombie_escape/knife_menu/turbulent9_hit.wav",
  66.     "zombie_escape/knife_menu/turbulent9_hitwall.wav",
  67.     "zombie_escape/knife_menu/turbulent9_slash.wav",
  68.     "zombie_escape/knife_menu/turbulent9_slash.wav",
  69.     "zombie_escape/knife_menu/turbulent9_stab.wav"
  70. }
  71.  
  72. new const sabers_sounds[][] =
  73. {
  74.     "zombie_escape/knife_menu/laser_deploy.wav",
  75.     "zombie_escape/knife_menu/laser_hit.wav",
  76.     "zombie_escape/knife_menu/laser_hit.wav",
  77.     "zombie_escape/knife_menu/laser_hit.wav",
  78.     "zombie_escape/knife_menu/laser_hit.wav",
  79.     "zombie_escape/knife_menu/laser_hitwall.wav",
  80.     "zombie_escape/knife_menu/laser_slash1.wav",
  81.     "zombie_escape/knife_menu/laser_slash2.wav",
  82.     "zombie_escape/knife_menu/laser_stab.wav"
  83. }
  84.  
  85. new const plasma_sounds[][] =
  86. {
  87.     "zombie_escape/knife_menu/plasma_deploy.wav",
  88.     "zombie_escape/knife_menu/plasma_hit.wav",
  89.     "zombie_escape/knife_menu/plasma_hit.wav",
  90.     "zombie_escape/knife_menu/plasma_hit.wav",
  91.     "zombie_escape/knife_menu/plasma_hit.wav",
  92.     "zombie_escape/knife_menu/plasma_hitwall.wav",
  93.     "zombie_escape/knife_menu/plasma_slash.wav",
  94.     "zombie_escape/knife_menu/plasma_slash.wav",
  95.     "zombie_escape/knife_menu/plasma_stab.wav"
  96. }
  97.  
  98. new const laevateinn_sounds[][] =
  99. {
  100.     "zombie_escape/knife_menu/laevateinn_deploy.wav",
  101.     "zombie_escape/knife_menu/laevateinn_hit.wav",
  102.     "zombie_escape/knife_menu/laevateinn_hit.wav",
  103.     "zombie_escape/knife_menu/laevateinn_hit.wav",
  104.     "zombie_escape/knife_menu/laevateinn_hit.wav",
  105.     "zombie_escape/knife_menu/laevateinn_hitwall.wav",
  106.     "zombie_escape/knife_menu/laevateinn_slash.wav",
  107.     "zombie_escape/knife_menu/laevateinn_slash.wav",
  108.     "zombie_escape/knife_menu/laevateinn_stab.wav"
  109. }
  110.  
  111. new const oldknife_sounds[][] =
  112. {
  113.     "weapons/knife_deploy1.wav",
  114.     "weapons/knife_hit1.wav",
  115.     "weapons/knife_hit2.wav",
  116.     "weapons/knife_hit3.wav",
  117.     "weapons/knife_hit4.wav",
  118.     "weapons/knife_hitwall1.wav",
  119.     "weapons/knife_slash1.wav",
  120.     "weapons/knife_slash2.wav",
  121.     "weapons/knife_stab.wav"
  122. }
  123.  
  124. new bool:g_bTurbulent9[33], bool:g_bSabers[33], bool:g_bPlasma[33],
  125. bool:g_bStorm[33], bool:g_bLaevateinn[33], bool:g_bNoSpeed, g_iUsedTimes[33], g_pCvarUseTimes
  126.  
  127. new cvar_speed_storm
  128. new cvar_speed_turb
  129. new cvar_speed_sabers
  130. new cvar_speed_plasma
  131. new cvar_speed_laevat
  132.  
  133. native SetUserHolySword(id)
  134. native DelUserHolySword(id)
  135.  
  136. public plugin_precache()
  137. {
  138.     new i
  139.  
  140.     for (i = 0; i <= charsmax(Storm_Models); i++)
  141.         precache_model(Storm_Models[i])
  142.  
  143.     for (i = 0; i <= charsmax(Turbulent9_Models); i++)
  144.         precache_model(Turbulent9_Models[i])
  145.  
  146.     for (i = 0; i <= charsmax(Sabers_Models); i++)
  147.         precache_model(Sabers_Models[i])
  148.  
  149.     for (i = 0; i <= charsmax(Plasma_Models); i++)
  150.         precache_model(Plasma_Models[i])
  151.  
  152.     for (i = 0; i <= charsmax(Laevateinn_Models); i++)
  153.         precache_model(Laevateinn_Models[i])
  154.  
  155.     for (i = 0; i <= charsmax(storm_sounds); i++)
  156.         precache_sound(storm_sounds[i])
  157.  
  158.     for (i = 0; i <= charsmax(turbulent9_sounds); i++)
  159.         precache_sound(turbulent9_sounds[i])
  160.  
  161.     for (i = 0; i <= charsmax(sabers_sounds); i++)
  162.         precache_sound(sabers_sounds[i])       
  163.  
  164.     for (i = 0; i <= charsmax(plasma_sounds); i++)
  165.         precache_sound(plasma_sounds[i])
  166.  
  167.     for (i = 0; i <= charsmax(laevateinn_sounds); i++)
  168.         precache_sound(laevateinn_sounds[i])
  169.  
  170.     precache_sound(g_sound_knife)
  171. }
  172.  
  173. public plugin_natives()
  174. {
  175.     register_native("ze_open_knife_menu", "native_ze_open_knife_menu", 1)
  176. }
  177.  
  178. public plugin_init()
  179. {
  180.     register_plugin("[ZE] Addon: Knife Menu", "1.3", "Mark")
  181.  
  182.     register_forward(FM_EmitSound, "fw_EmitSound")
  183.     register_forward(FM_PlayerPreThink, "fw_PlayerPreThink");
  184.  
  185.     register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
  186.     RegisterHookChain(RG_CBasePlayer_ResetMaxSpeed, "Fw_RestMaxSpeed_Post", 1)
  187.    
  188.     g_pCvarUseTimes = register_cvar("ze_knife_menu_use_times", "1000")
  189.  
  190.     register_message(get_user_msgid("DeathMsg"), "DeathMsg")
  191.  
  192.     register_clcmd("say /km", "Show_Knife_Menu")
  193.    
  194.     cvar_speed_storm = register_cvar("ze_storm_speed", "285.0")
  195.     cvar_speed_turb = register_cvar("ze_turb_speed", "285.0")
  196.     cvar_speed_sabers = register_cvar("ze_sabers_speed", "285.0")    
  197.     cvar_speed_plasma = register_cvar("ze_plasma_speed", "295.0")  
  198.     cvar_speed_laevat = register_cvar("ze_laevat_speed", "305.0")  
  199. }
  200.  
  201. public ze_user_humanized(id)
  202. {
  203.     g_iUsedTimes[id] = 0
  204. }
  205.  
  206. /*public ze_user_infected(Victim)
  207. {
  208.     g_bStorm[Victim] = false
  209.     g_bTurbulent9[Victim] = false  
  210.     g_bSabers[Victim] = false  
  211.     g_bPlasma[Victim] = false
  212.     g_bLaevateinn[Victim] = false
  213.     g_iUsedTimes[Victim] = 0
  214. }*/
  215.  
  216. public client_putinserver(id)
  217. {  
  218.     DelUserHolySword(id)
  219.     g_bStorm[id] = false
  220.     g_bTurbulent9[id] = false  
  221.     g_bSabers[id] = false  
  222.     g_bPlasma[id] = false
  223.     g_bLaevateinn[id] = false
  224.     g_iUsedTimes[id] = 0
  225. }
  226.  
  227. public client_disconnected(id)
  228. {
  229.     DelUserHolySword(id)   
  230.     g_bStorm[id] = false
  231.     g_bTurbulent9[id] = false
  232.     g_bSabers[id] = false  
  233.     g_bPlasma[id] = false
  234.     g_bLaevateinn[id] = false
  235.     g_iUsedTimes[id] = 0
  236. }
  237.  
  238. public ze_game_started()
  239. {
  240.     g_bNoSpeed = true
  241. }
  242.  
  243. public ze_zombie_release()
  244. {
  245.     g_bNoSpeed = false
  246.    
  247.     // call the reset speed function ;)
  248.     for(new id = 1; id <= 32; id++)
  249.     {
  250.         if (!is_user_alive(id))
  251.             continue;
  252.        
  253.         rg_reset_maxspeed(id)
  254.     }
  255. }
  256.  
  257. public Show_Knife_Menu(id)
  258. {
  259.     if (!is_user_connected(id))
  260.         return PLUGIN_CONTINUE
  261.  
  262.     if (ze_is_user_zombie(id))
  263.     {
  264.         ze_colored_print(id, "!tZombies can't open knife menu!y.")
  265.         return PLUGIN_HANDLED
  266.     }
  267.  
  268.     if (g_iUsedTimes[id] >= get_pcvar_num(g_pCvarUseTimes))
  269.     {
  270.         ze_colored_print(id, "!tYou can only open knife menu !y[!g%dx!y] per round!", get_pcvar_num(g_pCvarUseTimes))
  271.         return PLUGIN_HANDLED
  272.     }
  273.  
  274.     if (!is_user_alive(id))
  275.     {
  276.         ze_colored_print(id, "!tDead can't open knife menu!y.")
  277.         return PLUGIN_HANDLED
  278.     }
  279.  
  280.     Knife_Menu(id)
  281.     return PLUGIN_CONTINUE
  282. }
  283.  
  284. public Knife_Menu(id)
  285. {
  286.     new iMenu = menu_create("\rChoose Your Knife\w:^n^n- [ \ySpeed \rActivates \yon Zombie Release!\w ]^n\w- [ \r9 \yknives in Total!\w ] ^n-", "Menu_Handler")
  287.     menu_additem(iMenu, "\yAxe \w[ \r285 Speed\w ]", "", 0)
  288.     menu_additem(iMenu, "\yTurbulent-9 \w[ \r285 Speed\w ]", "", 0)
  289.     menu_additem(iMenu, "\ySabers \w[ \r285 Speed\w ]", "", 0)
  290.  
  291.     if (ze_get_vip_flags(id) & VIP_A)
  292.     {
  293.         menu_additem(iMenu, "\yCrowbar \w[ \rVIP\w ] [ \r295 Speed\w ]", "", 0)            
  294.     }
  295.    
  296.     if (ze_get_vip_flags(id) & VIP_F)
  297.     {
  298.         menu_additem(iMenu, "\yBlack Sword \w[ \rSVIP\w ] [ \r305 Speed\w ]", "", 0)
  299.         menu_additem(iMenu, "\yHolySword (SVIP) \w[\r2600 \ycoins\w]", "", 0)          
  300.     }
  301.         menu_setprop(iMenu,MPROP_EXITNAME,"Close")
  302.         menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL)
  303.         menu_display(id, iMenu, 0) 
  304. }
  305.  
  306. public Menu_Handler(id, iMenu, iKey)
  307. {
  308.     if(!is_user_alive(id) || ze_is_user_zombie(id))
  309.         return PLUGIN_HANDLED
  310.        
  311.     switch(iKey)
  312.     {
  313.         case 0: // Storm
  314.         {
  315.         DelUserHolySword(id)
  316.             g_bTurbulent9[id] = false
  317.             g_bSabers[id] = false
  318.             g_bPlasma[id] = false
  319.             g_bStorm[id] = true
  320.             g_bLaevateinn[id] = false
  321.             g_iUsedTimes[id] = 0
  322.             rg_remove_item(id, "weapon_knife")
  323.             rg_give_item(id, "weapon_knife", GT_APPEND)
  324.             //engclient_cmd(id, "weapon_knife")
  325.             //g_iUsedTimes[id]++
  326.             //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
  327.            
  328.         }
  329.         case 1: // Turbulent
  330.         {
  331.         DelUserHolySword(id)       
  332.             g_bTurbulent9[id] = true
  333.             g_bSabers[id] = false
  334.             g_bPlasma[id] = false
  335.             g_bStorm[id] = false
  336.             g_bLaevateinn[id] = false
  337.             g_iUsedTimes[id] = 0       
  338.             rg_remove_item(id, "weapon_knife")
  339.             rg_give_item(id, "weapon_knife", GT_APPEND)
  340.             //engclient_cmd(id, "weapon_knife")
  341.             //g_iUsedTimes[id]++
  342.             //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
  343.            
  344.         }
  345.         case 2: // Sabers
  346.         {
  347.         DelUserHolySword(id)       
  348.             g_bTurbulent9[id] = false
  349.             g_bSabers[id] = true
  350.             g_bPlasma[id] = false
  351.             g_bStorm[id] = false
  352.             g_bLaevateinn[id] = false  
  353.             g_iUsedTimes[id] = 0       
  354.             rg_remove_item(id, "weapon_knife")
  355.             rg_give_item(id, "weapon_knife", GT_APPEND)
  356.             //engclient_cmd(id, "weapon_knife")
  357.             //g_iUsedTimes[id]++
  358.             //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
  359.            
  360.         }                                
  361.         case 3: // Plasma
  362.         {
  363.         DelUserHolySword(id)       
  364.             g_bTurbulent9[id] = false
  365.             g_bSabers[id] = false
  366.             g_bPlasma[id] = true
  367.             g_bStorm[id] = false
  368.             g_bLaevateinn[id] = false
  369.             g_iUsedTimes[id] = 0       
  370.             rg_remove_item(id, "weapon_knife")
  371.             rg_give_item(id, "weapon_knife", GT_APPEND)
  372.             //engclient_cmd(id, "weapon_knife")
  373.             //g_iUsedTimes[id]++
  374.             //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
  375.            
  376.         }
  377.         case 4: // Laevateinn
  378.         {
  379.         DelUserHolySword(id)       
  380.             g_bTurbulent9[id] = false
  381.             g_bSabers[id] = false
  382.             g_bPlasma[id] = false
  383.             g_bStorm[id] = false
  384.             g_bLaevateinn[id] = true   
  385.             g_iUsedTimes[id] = 0           
  386.             rg_remove_item(id, "weapon_knife")
  387.             rg_give_item(id, "weapon_knife", GT_APPEND)
  388.             //engclient_cmd(id, "weapon_knife")
  389.             //g_iUsedTimes[id]++
  390.             //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
  391.            
  392.         }  
  393.         case 5: // Holysword
  394.         {      
  395.     if (ze_get_escape_coins(id) < HOLYSWORD_COST)
  396.     {
  397.         //ze_set_escape_coins(id,ze_get_escape_coins(id)+HOLYSWORD_COST); //return coins
  398.         return PLUGIN_HANDLED;
  399.     }
  400.     ze_set_escape_coins(id,ze_get_escape_coins(id) - HOLYSWORD_COST);
  401.    
  402.         SetUserHolySword(id)       
  403.             g_bTurbulent9[id] = false
  404.             g_bSabers[id] = false
  405.             g_bPlasma[id] = false
  406.             g_bStorm[id] = false
  407.             g_bLaevateinn[id] = false  
  408.             g_iUsedTimes[id] = 0       
  409.             rg_remove_item(id, "weapon_knife")
  410.             rg_give_item(id, "weapon_knife", GT_APPEND)
  411.             //engclient_cmd(id, "weapon_knife")
  412.             //g_iUsedTimes[id]++
  413.             //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
  414.            
  415.         }          
  416.     }
  417.  
  418.     menu_destroy(iMenu)
  419.     return PLUGIN_HANDLED
  420. }
  421.  
  422. public fw_EmitSound(id, channel, const sound[])
  423. {
  424.     if(!is_user_alive(id) || ze_is_user_zombie(id))
  425.         return FMRES_IGNORED
  426.        
  427.     new i
  428.     for (i = 0; i <= charsmax(turbulent9_sounds); i++)
  429.     for (i = 0; i <= charsmax(sabers_sounds); i++)
  430.     for (i = 0; i <= charsmax(plasma_sounds); i++)
  431.     for (i = 0; i <= charsmax(storm_sounds); i++)
  432.     for (i = 0; i <= charsmax(laevateinn_sounds); i++)
  433.  
  434.     {
  435.         if(equal(sound, oldknife_sounds[i]))
  436.         {
  437.  
  438.             if ((g_bTurbulent9[id]))
  439.             {
  440.                 emit_sound(id, channel, turbulent9_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  441.                 return FMRES_SUPERCEDE
  442.             }
  443.             else if ((g_bSabers[id]))
  444.             {
  445.                 emit_sound(id, channel, sabers_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  446.                 return FMRES_SUPERCEDE
  447.             }
  448.             else if ((g_bPlasma[id]) && (ze_get_vip_flags(id) & VIP_A))
  449.             {
  450.                 emit_sound(id, channel, plasma_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  451.                 return FMRES_SUPERCEDE
  452.             }
  453.             else if ((g_bStorm[id]))
  454.             {
  455.                 emit_sound(id, channel, storm_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  456.                 return FMRES_SUPERCEDE
  457.             }
  458.             else if ((g_bLaevateinn[id]) && (ze_get_vip_flags(id) & VIP_F))
  459.             {
  460.                 emit_sound(id, channel, laevateinn_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  461.                 return FMRES_SUPERCEDE
  462.             }
  463.             else if (!g_bTurbulent9[id] || !g_bSabers[id] || !g_bPlasma[id] || !g_bStorm[id] || !g_bLaevateinn[id])
  464.             {
  465.                 emit_sound(id, channel, oldknife_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  466.                 return FMRES_SUPERCEDE
  467.             }
  468.         }
  469.     }
  470.     return FMRES_IGNORED
  471. }
  472.  
  473. public CurrentWeapon(id)
  474. {
  475.     if(!is_user_alive(id) || ze_is_user_zombie(id))
  476.         return
  477.        
  478.     if(get_user_weapon(id) & CSW_KNIFE)
  479.     {
  480.  
  481.         if((g_bTurbulent9[id]))
  482.         {
  483.             cs_set_player_view_model(id, CSW_KNIFE, Turbulent9_Models[0])
  484.             cs_set_player_weap_model(id, CSW_KNIFE, Turbulent9_Models[1])
  485.         }
  486.         else if((g_bSabers[id]))
  487.         {
  488.             cs_set_player_view_model(id, CSW_KNIFE, Sabers_Models[0])
  489.             cs_set_player_weap_model(id, CSW_KNIFE, Sabers_Models[1])
  490.         }
  491.         else if((g_bPlasma[id]) && (ze_get_vip_flags(id) & VIP_A))
  492.         {
  493.             cs_set_player_view_model(id, CSW_KNIFE, Plasma_Models[0])
  494.             cs_set_player_weap_model(id, CSW_KNIFE, Plasma_Models[1])
  495.         }
  496.         else if((g_bStorm[id]) && (ze_get_vip_flags(id) & VIP_A))
  497.         {
  498.             cs_set_player_view_model(id, CSW_KNIFE, Storm_Models[0])
  499.             cs_set_player_weap_model(id, CSW_KNIFE, Storm_Models[1])
  500.         }
  501.         else if((g_bLaevateinn[id]) && (ze_get_vip_flags(id) & VIP_A))
  502.         {
  503.             cs_set_player_view_model(id, CSW_KNIFE, Laevateinn_Models[0])
  504.             cs_set_player_weap_model(id, CSW_KNIFE, Laevateinn_Models[1])
  505.         }  
  506.     }
  507. }
  508.  
  509. public Fw_RestMaxSpeed_Post(id)
  510. {
  511.     if (g_bNoSpeed)
  512.         return
  513.        
  514.     set_task(0.1, "DelayLoad", id)
  515.    
  516. }
  517.  
  518. public DelayLoad(id)
  519. {
  520.     new iWpnId = (get_user_weapon(id))
  521.    
  522.     if (iWpnId == CSW_KNIFE && g_bTurbulent9[id])
  523.     {
  524.         if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
  525.         {
  526.             new iFlags = get_entvar(id, var_flags);
  527.             new iWaterlvl = get_entvar(id, var_waterlevel)
  528.            
  529.             if (!(iFlags & FL_ONGROUND))
  530.                 return HC_CONTINUE
  531.  
  532.             if (iFlags & FL_WATERJUMP)
  533.                 return HAM_IGNORED
  534.  
  535.             if (iWaterlvl > 1)
  536.                 return HAM_IGNORED
  537.            
  538.             new Float:flVelocity[3]
  539.             get_entvar(id , var_velocity , flVelocity)
  540.  
  541.             flVelocity[2] += 325
  542.  
  543.             set_entvar(id , var_velocity , flVelocity)
  544.  
  545.             set_entvar(id, var_gaitsequence, 6)
  546.         }
  547.        
  548.         set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_turb))
  549.     }
  550.     if (iWpnId == CSW_KNIFE && g_bSabers[id])
  551.     {
  552.         if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
  553.         {
  554.             new iFlags = get_entvar(id, var_flags);
  555.             new iWaterlvl = get_entvar(id, var_waterlevel)
  556.            
  557.             if (!(iFlags & FL_ONGROUND))
  558.                 return HC_CONTINUE
  559.  
  560.             if (iFlags & FL_WATERJUMP)
  561.                 return HAM_IGNORED
  562.  
  563.             if (iWaterlvl > 1)
  564.                 return HAM_IGNORED
  565.            
  566.             new Float:flVelocity[3]
  567.             get_entvar(id , var_velocity , flVelocity)
  568.  
  569.             flVelocity[2] += 325
  570.  
  571.             set_entvar(id , var_velocity , flVelocity)
  572.  
  573.             set_entvar(id, var_gaitsequence, 6)
  574.         }
  575.        
  576.         set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_sabers))
  577.     }
  578.     if (iWpnId == CSW_KNIFE && g_bPlasma[id])
  579.     {
  580.         if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
  581.         {
  582.             new iFlags = get_entvar(id, var_flags);
  583.             new iWaterlvl = get_entvar(id, var_waterlevel)
  584.            
  585.             if (!(iFlags & FL_ONGROUND))
  586.                 return HC_CONTINUE
  587.  
  588.             if (iFlags & FL_WATERJUMP)
  589.                 return HAM_IGNORED
  590.  
  591.             if (iWaterlvl > 1)
  592.                 return HAM_IGNORED
  593.            
  594.             new Float:flVelocity[3]
  595.             get_entvar(id , var_velocity , flVelocity)
  596.  
  597.             flVelocity[2] += 325
  598.  
  599.             set_entvar(id , var_velocity , flVelocity)
  600.  
  601.             set_entvar(id, var_gaitsequence, 6)
  602.         }
  603.        
  604.         set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_plasma))
  605.     }
  606.     if (iWpnId == CSW_KNIFE && g_bStorm[id])
  607.     {
  608.         if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
  609.         {
  610.             new iFlags = get_entvar(id, var_flags);
  611.             new iWaterlvl = get_entvar(id, var_waterlevel)
  612.            
  613.             if (!(iFlags & FL_ONGROUND))
  614.                 return HC_CONTINUE
  615.  
  616.             if (iFlags & FL_WATERJUMP)
  617.                 return HAM_IGNORED
  618.  
  619.             if (iWaterlvl > 1)
  620.                 return HAM_IGNORED
  621.            
  622.             new Float:flVelocity[3]
  623.             get_entvar(id , var_velocity , flVelocity)
  624.  
  625.             flVelocity[2] += 325
  626.  
  627.             set_entvar(id , var_velocity , flVelocity)
  628.  
  629.             set_entvar(id, var_gaitsequence, 6)
  630.         }
  631.        
  632.         set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_storm))
  633.     }
  634.     if (iWpnId == CSW_KNIFE && g_bLaevateinn[id])
  635.     {
  636.         if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
  637.         {
  638.             new iFlags = get_entvar(id, var_flags);
  639.             new iWaterlvl = get_entvar(id, var_waterlevel)
  640.            
  641.             if (!(iFlags & FL_ONGROUND))
  642.                 return HC_CONTINUE
  643.  
  644.             if (iFlags & FL_WATERJUMP)
  645.                 return HAM_IGNORED
  646.  
  647.             if (iWaterlvl > 1)
  648.                 return HAM_IGNORED
  649.            
  650.             new Float:flVelocity[3]
  651.             get_entvar(id , var_velocity , flVelocity)
  652.  
  653.             flVelocity[2] += 325
  654.  
  655.             set_entvar(id , var_velocity , flVelocity)
  656.  
  657.             set_entvar(id, var_gaitsequence, 6)
  658.         }
  659.        
  660.         set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_laevat))
  661.     }
  662.  
  663.     return HAM_IGNORED
  664. }
  665. public DeathMsg(msg_id, msg_dest, id)
  666. {
  667.     static szTruncatedWeapon[33], iAttacker
  668.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  669.     iAttacker = get_msg_arg_int(1)
  670.    
  671.     if(!is_user_alive(iAttacker) || iAttacker == get_msg_arg_int(2) || !is_user_alive(get_msg_arg_int(2))) // get_msg_arg_int(2) = iVictim
  672.         return
  673.    
  674.     if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iAttacker) & CSW_KNIFE)
  675.     {
  676.  
  677.         if(g_bTurbulent9[id])
  678.         {
  679.             set_msg_arg_string(4, "Turbulent9 knife")
  680.         }
  681.         else if(g_bSabers[id])
  682.         {
  683.             set_msg_arg_string(4, "Sabers knife")
  684.         }
  685.         else if(g_bPlasma[id])
  686.         {
  687.             set_msg_arg_string(4, "Plasma knife")
  688.         }
  689.         else if(g_bStorm[id])
  690.         {
  691.             set_msg_arg_string(4, "Storm knife")
  692.         }
  693.         else if(g_bLaevateinn[id])
  694.         {
  695.             set_msg_arg_string(4, "Laevateinn knife")
  696.         }
  697.     }
  698. }
  699.  
  700. stock fm_set_user_maxspeed(index, Float:speed = -1.0)
  701. {
  702.         engfunc(EngFunc_SetClientMaxspeed, index, speed);
  703.         set_pev(index, pev_maxspeed, speed);
  704.  
  705.         return 1;
  706. }  
  707.  
  708. public native_ze_open_knife_menu(id)
  709. {
  710.     Show_Knife_Menu(id)
  711. }
  712. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  713. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
  714. */
Knife plugin (warhammer)
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fakemeta_util>
  4. #include <hamsandwich>
  5.  
  6. #define _ZP
  7.  
  8. #if !defined _ZP
  9.     #tryinclude <zombieplague>
  10. #else
  11.     #tryinclude <zombie_escape>
  12.        
  13.     #define zp_get_user_zombie      ze_is_user_zombie
  14. #endif
  15.  
  16. #define PLUGIN                  "[ZP] Extra: CSO Weapon"
  17. #define VERSION                 "1.0"
  18. #define AUTHOR                  "TemplateAuthor:KORD_12.7:WeaponAuthor:PaXaN-ZOMBIE"
  19.  
  20. #pragma ctrlchar                '\'
  21. #pragma compress                1
  22.  
  23. //**********************************************
  24. //* Weapon Settings.                           *
  25. //**********************************************
  26.  
  27. #define WEAPON_REFERANCE            "weapon_knife"
  28.  
  29. #define WEAPON_MODEL_VIEW           "models/v_stormgiant2.mdl"
  30. #define WEAPON_MODEL_PLAYER         "models/p_stormgiant.mdl"
  31.  
  32. #define WEAPON_DAMAGE               random_float(250.0, 3500.0)
  33. #define WEAPON_DAMAGE_STAB          random_float(300.0, 550.0)
  34. #define WEAPON_DAMAGE_DRAW          random_float(150.0, 200.0)
  35.  
  36. #define WEAPON_DISTANCE_ATTACK          99.0
  37. #define WEAPON_DISTANCE_ATTACK_STAB     110.0
  38.  
  39. #define WEAPON_KNOCKBACK            7.0
  40. #define WEAPON_KNOCKBACK_STAB           10.0
  41.  
  42. #define SOUND_HIT               "weapons/stormgiant_hit1.wav"
  43. #define SOUND_HIT_WALL              "weapons/stormgiant_stone1.wav"
  44. #define SOUND_DRAW              "weapons/stormgiant_draw.wav"
  45. #define SOUND_STAB_MISS             "weapons/stormgiant_stab_miss.wav"
  46.  
  47. #define ANIM_EXTENSION              "knife"
  48.  
  49. enum
  50. {  
  51.     ANIM_IDLE,
  52.    
  53.     ANIM_DRAW_ATTACK,
  54.     ANIM_DRAW_ATTACK1,
  55.    
  56.     ANIM_DRAW,
  57.    
  58.     ANIM_SLASH_START,
  59.     ANIM_SLASH_END,
  60.     ANIM_SLASH_END2,
  61.  
  62.     ANIM_STAB_START,
  63.     ANIM_STAB_END,
  64.     ANIM_STAB_END2,
  65.    
  66.     ANIM_MSLASH1,
  67.     ANIM_MSLASH2,
  68.     ANIM_MSLASH3
  69. };
  70.  
  71. //**********************************************
  72. //* Some macroses.                             *
  73. //**********************************************
  74. #define GET_SHOOTS(%0)          get_pdata_int(%0, m_fInCheckShoots, extra_offset_weapon)
  75. #define SET_SHOOTS(%0,%1)       set_pdata_int(%0, m_fInCheckShoots, %1, extra_offset_weapon)
  76.  
  77. #define MDLL_Spawn(%0)          dllfunc(DLLFunc_Spawn, %0)
  78. #define MDLL_Touch(%0,%1)       dllfunc(DLLFunc_Touch, %0, %1)
  79.  
  80. #define SET_MODEL(%0,%1)        engfunc(EngFunc_SetModel, %0, %1)
  81. #define SET_ORIGIN(%0,%1)       engfunc(EngFunc_SetOrigin, %0, %1)
  82.  
  83. #define PRECACHE_MODEL(%0)      engfunc(EngFunc_PrecacheModel, %0)
  84. #define PRECACHE_SOUND(%0)      engfunc(EngFunc_PrecacheSound, %0)
  85. #define PRECACHE_GENERIC(%0)        engfunc(EngFunc_PrecacheGeneric, %0)
  86.  
  87. #define MODEL_INDEX(%0)         engfunc(EngFunc_ModelIndex,%0)
  88.  
  89. #define MESSAGE_BEGIN(%0,%1,%2,%3)  engfunc(EngFunc_MessageBegin, %0, %1, %2, %3)
  90. #define MESSAGE_END()           message_end()
  91.  
  92. #define WRITE_ANGLE(%0)         engfunc(EngFunc_WriteAngle, %0)
  93. #define WRITE_BYTE(%0)          write_byte(%0)
  94. #define WRITE_COORD(%0)         engfunc(EngFunc_WriteCoord, %0)
  95. #define WRITE_STRING(%0)        write_string(%0)
  96. #define WRITE_SHORT(%0)         write_short(%0)
  97.  
  98. #define INSTANCE(%0)            ((%0 == -1) ? 0 : %0)
  99.  
  100. #define BitSet(%0,%1)           (%0 |= (1 << (%1 - 1)))
  101. #define BitClear(%0,%1)         (%0 &= ~(1 << (%1 - 1)))
  102. #define BitCheck(%0,%1)         (%0 & (1 << (%1 - 1)))
  103.  
  104. //**********************************************
  105. //* PvData Offsets.                            *
  106. //**********************************************
  107.  
  108. // Linux extra offsets
  109. #define extra_offset_weapon     4
  110. #define extra_offset_player     5
  111.  
  112. new g_bitIsConnected;
  113.  
  114. #define m_rgpPlayerItems_CWeaponBox 34
  115. #define m_fInCheckShoots        39
  116. #define m_pPlayer           41
  117. #define m_flNextPrimaryAttack       46
  118. #define m_flNextSecondaryAttack     47
  119. #define m_flTimeWeaponIdle      48
  120. #define m_iDirection            60
  121. #define m_fWeaponState          74
  122. #define m_LastHitGroup          75
  123. #define m_flNextAttack          83
  124. #define m_iLastZoom             109
  125. #define m_fResumeZoom           110
  126. #define m_iFOV              363
  127. #define m_pActiveItem           373
  128. #define m_szAnimExtention       492
  129.  
  130. #define IsValidPev(%0)          (pev_valid(%0) == 2)
  131.    
  132. new IsKnife[33];
  133. new iBlood[3];
  134.  
  135. Weapon_OnPrecache()
  136. {
  137.     PRECACHE_SOUNDS_FROM_MODEL(WEAPON_MODEL_VIEW);
  138.     PRECACHE_MODEL(WEAPON_MODEL_VIEW);
  139.     PRECACHE_MODEL(WEAPON_MODEL_PLAYER);
  140.  
  141.     PRECACHE_SOUND(SOUND_HIT);
  142.     PRECACHE_SOUND(SOUND_HIT_WALL);
  143.     PRECACHE_SOUND(SOUND_DRAW);
  144.     PRECACHE_SOUND(SOUND_STAB_MISS);
  145.    
  146.     iBlood[0] = PRECACHE_MODEL("sprites/bloodspray.spr");
  147.     iBlood[1] = PRECACHE_MODEL("sprites/blood.spr");
  148.     iBlood[2] = PRECACHE_MODEL("sprites/ef_coilmg.spr");
  149. }
  150.  
  151. Weapon_OnDeploy(const iItem, const iPlayer)
  152. {
  153.     #pragma unused iItem, iPlayer
  154.  
  155.     Weapon_DefaultDeploy(iPlayer, WEAPON_MODEL_VIEW, WEAPON_MODEL_PLAYER, ANIM_DRAW_ATTACK, ANIM_EXTENSION);
  156.            
  157.     set_pdata_float(iItem, m_flTimeWeaponIdle, 0.6, extra_offset_weapon);
  158.     set_pdata_float(iPlayer, m_flNextAttack, 0.4, extra_offset_player);
  159.    
  160.     engfunc(EngFunc_EmitSound, iPlayer, CHAN_WEAPON, SOUND_DRAW, 0.9, ATTN_NORM, 0, PITCH_NORM);
  161.    
  162.     set_pev(iItem, pev_fuser3, get_gametime() + 0.2);
  163.     set_pev(iItem, pev_fuser4, get_gametime() + 0.6);
  164.     set_pev(iItem, pev_iuser1, 1);
  165. }
  166.  
  167. Weapon_OnHolster(const iItem, const iPlayer)
  168. {
  169.     #pragma unused iItem, iPlayer
  170.  
  171.     set_pev(iItem, pev_fuser1, 0.0);
  172.     set_pev(iItem, pev_fuser2, 0.0);
  173.     set_pev(iItem, pev_fuser3, 0.0);
  174.     set_pev(iItem, pev_fuser4, 0.0);
  175.    
  176.     set_pev(iItem, pev_iuser1, 0);
  177. }
  178.  
  179. Weapon_OnIdle(const iItem, const iPlayer)
  180. {
  181.     #pragma unused iItem, iPlayer
  182.    
  183.     ExecuteHamB(Ham_Weapon_ResetEmptySound, iItem);
  184.  
  185.     if (get_pdata_int(iItem, m_flTimeWeaponIdle, extra_offset_weapon) > 0.0)
  186.     {
  187.         return;
  188.     }
  189.    
  190.     Weapon_SendAnim(iPlayer, ANIM_IDLE);   
  191.     set_pdata_float(iItem, m_flTimeWeaponIdle, 10.0, extra_offset_weapon);
  192. }
  193.  
  194. Weapon_OnPrimaryAttack(const iItem, const iPlayer)
  195. {
  196.     #pragma unused iItem, iPlayer
  197.    
  198.     static szAnimation[64];
  199.  
  200.     formatex(szAnimation, charsmax(szAnimation), "ref_shoot_%s", ANIM_EXTENSION);
  201.            
  202.     Weapon_SendAnim(iPlayer, ANIM_SLASH_START);
  203.                    
  204.     set_pdata_float(iItem, m_flTimeWeaponIdle, 2.0, extra_offset_weapon);
  205.     set_pdata_float(iItem, m_flNextPrimaryAttack, 1.5, extra_offset_weapon);
  206.     set_pdata_float(iItem, m_flNextSecondaryAttack, 1.5, extra_offset_weapon);
  207.                    
  208.     Player_SetAnimation(iPlayer, szAnimation);
  209.    
  210.     set_pev(iItem ,pev_fuser1, get_gametime() + 1.0);
  211. }
  212.  
  213. public Weapon_OnSecondaryAttack(const iItem, const iPlayer)
  214. {
  215.     #pragma unused iItem, iPlayer
  216.    
  217.     static szAnimation[64];formatex(szAnimation, charsmax(szAnimation), "ref_shoot_%s", ANIM_EXTENSION);
  218.    
  219.     static Float:iTime;pev(iItem, pev_fuser3, iTime);
  220.    
  221.     if (pev(iItem, pev_iuser1) && !iTime)
  222.     {
  223.         WeaponStab(iPlayer, iItem);
  224.         set_pdata_float(iItem, m_flNextPrimaryAttack, 1.0, extra_offset_weapon);
  225.         set_pdata_float(iItem, m_flNextSecondaryAttack, 1.0, extra_offset_weapon);
  226.        
  227.         set_pev(iItem, pev_iuser1, 0);
  228.         set_pev(iItem, pev_fuser4, 0.0);
  229.     }
  230.     else
  231.     {
  232.        
  233.         Weapon_SendAnim(iPlayer, ANIM_STAB_START);
  234.        
  235.         set_pdata_float(iItem, m_flTimeWeaponIdle, 2.0, extra_offset_weapon);
  236.         set_pdata_float(iItem, m_flNextPrimaryAttack, 1.5, extra_offset_weapon);
  237.         set_pdata_float(iItem, m_flNextSecondaryAttack, 1.5, extra_offset_weapon);
  238.        
  239.         Player_SetAnimation(iPlayer, szAnimation);
  240.        
  241.         set_pev(iItem ,pev_fuser2, get_gametime() + 1.0);
  242.     }
  243. }
  244.  
  245. //*********************************************************************
  246. //*           Don't modify the code below this line unless            *
  247. //*              you know _exactly_ what you are doing!!!             *
  248. //*********************************************************************
  249.  
  250. public plugin_precache()
  251. {
  252.     Weapon_OnPrecache();
  253. }
  254.  
  255. public plugin_init()
  256. {
  257.     register_plugin(PLUGIN, VERSION, AUTHOR);
  258.    
  259.     RegisterHam(Ham_Item_Deploy,            WEAPON_REFERANCE,   "HamHook_Item_Deploy_Post",     true);
  260.     RegisterHam(Ham_Item_Holster,           WEAPON_REFERANCE,   "HamHook_Item_Holster",         false);
  261.    
  262.     RegisterHam(Ham_Weapon_WeaponIdle,      WEAPON_REFERANCE,   "HamHook_Item_WeaponIdle",      false);
  263.     RegisterHam(Ham_Weapon_PrimaryAttack,       WEAPON_REFERANCE,   "HamHook_Item_PrimaryAttack",       false);
  264.     RegisterHam(Ham_Weapon_SecondaryAttack,         WEAPON_REFERANCE,   "HamHook_Item_SecondaryAttack",     false);
  265.  
  266.     RegisterHam(Ham_Spawn,              "player",       "HamHook_Player_Spawn",         true);
  267.     RegisterHam(Ham_Killed,                 "player",       "HamHook_Player_Killed",        false);
  268.  
  269.     register_forward(FM_UpdateClientData,                   "FakeMeta_UpdateClientData_Post",   true);
  270.  
  271.     register_clcmd("GetWarHammer",                      "native_set_user_knife");
  272.     register_clcmd("DelWarHammer",                      "native_delete_user_knife");
  273. }
  274.  
  275. public plugin_natives()
  276. {
  277.     register_native("SetUserWarHammer", "native_set_user_knife", true);
  278.     register_native("DelUserWarHammer", "native_delete_user_knife", true) ;
  279. }
  280.  
  281. public native_set_user_knife(iPlayer)
  282. {
  283.     IsKnife[iPlayer] = true;
  284.     Weapon_Select(iPlayer);
  285. }
  286.  
  287. public native_delete_user_knife(iPlayer)
  288. {
  289.     IsKnife[iPlayer] = false;
  290.    
  291.     new iItem = get_pdata_cbase(iPlayer, m_pActiveItem, extra_offset_player);
  292.     if (pev_valid(iItem))
  293.     {
  294.         ExecuteHamB(Ham_Item_Deploy, iItem);
  295.     }
  296. }
  297.  
  298. //**********************************************
  299. //* Block client weapon.                       *
  300. //**********************************************
  301. public FakeMeta_UpdateClientData_Post(const iPlayer, const iSendWeapons, const CD_Handle)
  302. {
  303.     static iActiveItem;iActiveItem = get_pdata_cbase(iPlayer, m_pActiveItem, extra_offset_player);
  304.    
  305.     if(zp_get_user_zombie(iPlayer) || !IsKnife[iPlayer])
  306.     {
  307.         return FMRES_IGNORED;
  308.     }
  309.    
  310.     if (!IsValidPev(iActiveItem) || get_user_weapon(iPlayer) != CSW_KNIFE)
  311.     {
  312.         return FMRES_IGNORED;
  313.     }
  314.    
  315.     if (!IsKnife[iPlayer])
  316.     {  
  317.         return FMRES_IGNORED;
  318.     }
  319.    
  320.     static Float:iTime3;pev(iActiveItem, pev_fuser3, iTime3);
  321.    
  322.     if (iTime3 && iTime3 <= get_gametime())
  323.     {
  324.         WeaponSlashDraw(iPlayer, iActiveItem);
  325.         set_pev(iActiveItem, pev_fuser3, 0.0);
  326.     }
  327.    
  328.     static Float:iTime4;pev(iActiveItem, pev_fuser4, iTime4);
  329.    
  330.     if (iTime4 && iTime4 <= get_gametime())
  331.     {
  332.         Weapon_SendAnim(iPlayer, ANIM_DRAW);
  333.    
  334.         set_pdata_float(iActiveItem, m_flTimeWeaponIdle, 1.0, extra_offset_weapon);
  335.        
  336.         set_pev(iActiveItem, pev_fuser4, 0.0);
  337.         set_pev(iActiveItem, pev_iuser1, 0);
  338.     }
  339.    
  340.     static Float:iTime;pev(iActiveItem, pev_fuser1, iTime);
  341.    
  342.     if (iTime && iTime <= get_gametime())
  343.     {
  344.         WeaponSlash(iPlayer, iActiveItem);
  345.         set_pev(iActiveItem, pev_fuser1, 0.0);
  346.     }
  347.    
  348.     static Float:iTime2;pev(iActiveItem, pev_fuser2, iTime2);
  349.    
  350.     if (iTime2 && iTime2 <= get_gametime())
  351.     {
  352.         WeaponStab(iPlayer, iActiveItem);
  353.         set_pev(iActiveItem, pev_fuser2, 0.0);
  354.     }
  355.  
  356.     set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001);
  357.    
  358.     return FMRES_IGNORED;
  359. }
  360.  
  361. //**********************************************
  362. //* Item (weapon) hooks.                       *
  363. //**********************************************
  364.     #define _call.%0(%1,%2) \
  365.                                 \
  366.     Weapon_On%0                     \
  367.     (                           \
  368.         %1,                         \
  369.         %2                      \
  370.     )
  371.  
  372. public HamHook_Item_Deploy_Post(const iItem)
  373. {
  374.     new iPlayer;
  375.    
  376.     if (!CheckItem(iItem, iPlayer))
  377.     {
  378.         return HAM_IGNORED;
  379.     }
  380.    
  381.     _call.Deploy(iItem, iPlayer);
  382.     return HAM_IGNORED;
  383. }
  384.  
  385. public HamHook_Item_Holster(const iItem)
  386. {
  387.     new iPlayer;
  388.    
  389.     if (!CheckItem(iItem, iPlayer))
  390.     {
  391.         return HAM_IGNORED;
  392.     }
  393.    
  394.     set_pev(iPlayer, pev_viewmodel, 0);
  395.     set_pev(iPlayer, pev_weaponmodel, 0);
  396.    
  397.     _call.Holster(iItem, iPlayer);
  398.     return HAM_SUPERCEDE;
  399. }
  400.  
  401. public HamHook_Item_WeaponIdle(const iItem)
  402. {
  403.     static iPlayer;
  404.    
  405.     if (!CheckItem(iItem, iPlayer))
  406.     {
  407.         return HAM_IGNORED;
  408.     }
  409.  
  410.     _call.Idle(iItem, iPlayer);
  411.     return HAM_SUPERCEDE;
  412. }
  413.  
  414. public HamHook_Item_PrimaryAttack(const iItem)
  415. {
  416.     static iPlayer;
  417.    
  418.     if (!CheckItem(iItem, iPlayer))
  419.     {
  420.         return HAM_IGNORED;
  421.     }
  422.  
  423.     _call.PrimaryAttack(iItem, iPlayer);
  424.     return HAM_SUPERCEDE;
  425. }
  426.  
  427. public HamHook_Item_SecondaryAttack(const iItem)
  428. {
  429.     static iPlayer;
  430.    
  431.     if (!CheckItem(iItem, iPlayer))
  432.     {
  433.         return HAM_IGNORED;
  434.     }
  435.    
  436.     _call.SecondaryAttack(iItem, iPlayer);
  437.     return HAM_SUPERCEDE;
  438. }
  439.  
  440. public HamHook_Player_Spawn(iPlayer)
  441. {
  442.     if(is_user_alive(iPlayer))
  443.     {
  444.         new iItem = get_pdata_cbase(iPlayer, m_pActiveItem, extra_offset_player);
  445.  
  446.         if (pev_valid(iItem))
  447.         {
  448.             ExecuteHamB(Ham_Item_Deploy, iItem);
  449.         }
  450.     }
  451. }
  452.  
  453. public HamHook_Player_Killed(const iPlayer)
  454. {
  455.     IsKnife[iPlayer] = false;
  456. }
  457.  
  458. public WeaponSlashDraw(const iPlayer, const iItem)
  459. {
  460.     PrimarySlash_Attack(iPlayer, iItem, 0.0,0.0, false, true);
  461. }
  462.  
  463. public WeaponSlash(const iPlayer, const iItem)
  464. {
  465.     PrimarySlash_Attack(iPlayer, iItem);
  466. }
  467.  
  468. public WeaponStab(const iPlayer, const iItem)
  469. {
  470.     PrimarySlash_Attack(iPlayer, iItem, 0.0,0.0,true);
  471. }
  472.  
  473. //**********************************************
  474. //* Attack function.                           *
  475. //**********************************************
  476.  
  477. PrimarySlash_Attack(const iPlayer, const iItem, const Float: flRightScale = 1.0, const Float: flUpScale = 1.0, bool:bStab=false, bool:bDraw=false)
  478. {
  479.     new Float: Origin[3];
  480.     new Float: vecEnd[3];
  481.     new Float: vecScr[3];
  482.    
  483.     new Float: flFraction;
  484.    
  485.     new iTrace;
  486.     new iVictim;
  487.    
  488.     Weapon_GetGunPosition(iPlayer, Origin, vecScr, 0.0, flRightScale, flUpScale);
  489.    
  490.     angle_vector(vecScr, ANGLEVECTOR_FORWARD, vecScr);
  491.  
  492.     if (bDraw)
  493.     {
  494.         xs_vec_mul_scalar(vecScr, 80.0, vecEnd);
  495.     }
  496.     else
  497.     {
  498.         xs_vec_mul_scalar(vecScr, bStab ? WEAPON_DISTANCE_ATTACK_STAB:WEAPON_DISTANCE_ATTACK, vecEnd);
  499.     }
  500.  
  501.     xs_vec_add(Origin, vecEnd, vecEnd);
  502.    
  503.     engfunc(EngFunc_TraceLine, Origin, vecEnd, DONT_IGNORE_MONSTERS, iPlayer, (iTrace = create_tr2()));
  504.     get_tr2(iTrace, TR_flFraction, flFraction);
  505.    
  506.     if (!bDraw)
  507.     {
  508.         switch (bStab)
  509.         {
  510.             case false:
  511.             {
  512.                 Weapon_SendAnim(iPlayer, ANIM_SLASH_END);
  513.                        
  514.                 set_pdata_float(iItem, m_flTimeWeaponIdle, 2.0, extra_offset_weapon);
  515.             }
  516.             case true:
  517.             {
  518.                 Weapon_SendAnim(iPlayer, ANIM_STAB_END);
  519.                        
  520.                 set_pdata_float(iItem, m_flTimeWeaponIdle, 1.0, extra_offset_weapon);
  521.                 engfunc(EngFunc_EmitSound, iPlayer, CHAN_ITEM, SOUND_STAB_MISS, 0.8, ATTN_NORM, 0, PITCH_NORM);
  522.             }
  523.         }
  524.     }
  525.    
  526.     if (flFraction >= 1.0)
  527.     {
  528.         engfunc(EngFunc_TraceHull, Origin, vecEnd, DONT_IGNORE_MONSTERS, HULL_HEAD, iPlayer, iTrace);
  529.         get_tr2(iTrace, TR_flFraction, flFraction);
  530.        
  531.         if (flFraction < 1.0)
  532.         {
  533.             iVictim = INSTANCE(get_tr2(iTrace, TR_pHit));
  534.            
  535.             if (!iVictim || ExecuteHamB(Ham_IsBSPModel, iVictim))
  536.             {
  537.                 FindHullIntersection(Origin, iTrace, Float: {-16.0, -16.0, -18.0}, Float: {16.0,  16.0,  18.0}, iPlayer);
  538.             }
  539.         }
  540.     }
  541.  
  542.     get_tr2(iTrace, TR_flFraction, flFraction);
  543.    
  544.     if (flFraction < 1.0)
  545.     {
  546.         iVictim = INSTANCE(get_tr2(iTrace, TR_pHit));
  547.         new Float:iDamage;
  548.         if (bDraw)
  549.         {
  550.             iDamage = WEAPON_DAMAGE_DRAW;
  551.         }
  552.         else
  553.         {
  554.             iDamage = (bStab ? WEAPON_DAMAGE_STAB:WEAPON_DAMAGE);
  555.         }
  556.        
  557.         if(iVictim > 0 && pev(iVictim, pev_takedamage) != DAMAGE_NO && pev(iVictim, pev_solid) != SOLID_NOT)
  558.         {  
  559.             if(ExecuteHamB(Ham_IsPlayer, iVictim))
  560.             {
  561.                 engfunc(EngFunc_EmitSound, iPlayer, CHAN_ITEM, SOUND_HIT, 0.8, ATTN_NORM, 0, PITCH_NORM);
  562.                
  563.                 if(!zp_get_user_zombie(iVictim))
  564.                 {
  565.                     return;
  566.                 }
  567.                
  568.                 new Float:vecViewAngle[3]; pev(iPlayer, pev_v_angle, vecViewAngle);
  569.                 new Float:vecForward[3]; angle_vector(vecViewAngle, ANGLEVECTOR_FORWARD, vecForward);
  570.    
  571.                 FakeKnockBack(iVictim, vecForward, bStab ? WEAPON_KNOCKBACK_STAB:WEAPON_KNOCKBACK);
  572.                
  573.                 get_tr2(iTrace, TR_vecEndPos, vecEnd);
  574.                 Create_Blood(vecEnd, iBlood[0], iBlood[1], 76, 10);
  575.                 CreateExplosion(vecEnd, -10.0, iBlood[2], 2, 9, TE_EXPLFLAG_NODLIGHTS|TE_EXPLFLAG_NOPARTICLES|TE_EXPLFLAG_NOSOUND);
  576.                
  577.                 static iHitGroup;
  578.                 switch ((iHitGroup = get_tr2(iTrace, TR_iHitgroup)))
  579.                 {
  580.                     case HIT_HEAD:iDamage *= 2;
  581.                     case HIT_CHEST:iDamage *= 1;
  582.                     case HIT_STOMACH:iDamage *= 1.25;
  583.                     case HIT_LEFTARM,HIT_RIGHTARM:iDamage *= 1;
  584.                     case HIT_LEFTLEG,HIT_RIGHTLEG:iDamage *= 0.75;
  585.                 }
  586.                 set_pdata_int(iVictim, m_LastHitGroup, iHitGroup, extra_offset_player);
  587.             }
  588.            
  589.             ExecuteHamB(Ham_TakeDamage, iVictim, iItem, iPlayer, iDamage, DMG_CLUB | DMG_NEVERGIB);
  590.         }
  591.         else
  592.         {
  593.             get_tr2(iTrace, TR_vecEndPos, vecEnd);
  594.             CreateExplosion(vecEnd, -10.0, iBlood[2], 2, 9, TE_EXPLFLAG_NODLIGHTS|TE_EXPLFLAG_NOPARTICLES|TE_EXPLFLAG_NOSOUND);
  595.             engfunc(EngFunc_EmitSound, iPlayer, CHAN_ITEM, SOUND_HIT_WALL, 0.8, ATTN_NORM, 0, PITCH_NORM);
  596.         }
  597.     }
  598.  
  599.     free_tr2(iTrace);
  600. }
  601.  
  602. //**********************************************
  603. //* Create and check our custom weapon.        *
  604. //**********************************************
  605.  
  606. Weapon_SendAnim(const iPlayer, const iAnim)
  607. {
  608.     set_pev(iPlayer, pev_weaponanim, iAnim);
  609.  
  610.     MESSAGE_BEGIN(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0.0, 0.0, 0.0}, iPlayer);
  611.     WRITE_BYTE(iAnim);
  612.     WRITE_BYTE(0);
  613.     MESSAGE_END();
  614. }
  615.  
  616. stock Weapon_DefaultDeploy(const iPlayer, const szViewModel[], const szWeaponModel[], const iAnim, const szAnimExt[])
  617. {
  618.     set_pev(iPlayer, pev_viewmodel2, szViewModel);
  619.     set_pev(iPlayer, pev_weaponmodel2, szWeaponModel);
  620.     set_pev(iPlayer, pev_fov, 90.0);
  621.    
  622.     set_pdata_int(iPlayer, m_iFOV, 90, extra_offset_player);
  623.     set_pdata_int(iPlayer, m_fResumeZoom, 0, extra_offset_player);
  624.     set_pdata_int(iPlayer, m_iLastZoom, 90, extra_offset_player);
  625.    
  626.     set_pdata_string(iPlayer, m_szAnimExtention * 4, szAnimExt, -1, extra_offset_player * 4);
  627.  
  628.     Weapon_SendAnim(iPlayer, iAnim);
  629. }
  630.  
  631. stock Create_Blood(const Float:vStart[3], const iModel, const iModel2, const iColor, const iScale)
  632. {
  633.     MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY, vStart, 0);
  634.     WRITE_BYTE(TE_BLOODSPRITE);
  635.     WRITE_COORD(vStart[0])
  636.     WRITE_COORD(vStart[1])
  637.     WRITE_COORD(vStart[2])
  638.     WRITE_SHORT(iModel);
  639.     WRITE_SHORT(iModel2);
  640.     WRITE_BYTE(iColor);
  641.     WRITE_BYTE(iScale);
  642.     MESSAGE_END();
  643. }
  644.  
  645. public client_putinserver(id)
  646. {
  647.     BitSet(g_bitIsConnected, id);
  648. }
  649.  
  650. public client_disconnected(id)
  651. {
  652.     BitClear(g_bitIsConnected, id);
  653. }
  654.  
  655. bool: CheckItem(const iItem, &iPlayer)
  656. {
  657.     if (!IsValidPev(iItem))
  658.     {
  659.         return false;
  660.     }
  661.    
  662.     iPlayer = get_pdata_cbase(iItem, m_pPlayer, extra_offset_weapon);
  663.    
  664.     if (!BitCheck(g_bitIsConnected, iPlayer) || !IsValidPev(iPlayer) || zp_get_user_zombie(iPlayer) || !IsKnife[iPlayer])
  665.     {
  666.         return false;
  667.     }
  668.    
  669.     return true;
  670. }
  671.  
  672. bool: CheckItem2(const iPlayer, &iItem)
  673. {
  674.     if (!BitCheck(g_bitIsConnected, iPlayer) || !IsValidPev(iPlayer) || zp_get_user_zombie(iPlayer) || get_user_weapon(iPlayer) != CSW_KNIFE)
  675.     {
  676.         return false;
  677.     }
  678.    
  679.     iItem = get_pdata_cbase(iPlayer, m_pActiveItem, extra_offset_player);
  680.    
  681.     if (!IsValidPev(iItem) || !IsKnife[iPlayer])
  682.     {
  683.         return false;
  684.     }
  685.    
  686.     return true;
  687. }
  688.  
  689. //**********************************************
  690. //* Some usefull stocks.                       *
  691. //**********************************************
  692.  
  693. stock Weapon_GetGunPosition(const iPlayer, Float: fOrigin[3], Float: fAngles[3], Float: add_forward = 0.0, Float: add_right = 0.0, Float: add_up = 0.0)
  694. {
  695.     static Float: Forward[3], Float: Right[3], Float: Up[3];
  696.  
  697.     if (IsValidPev(iPlayer)) ExecuteHamB(Ham_Player_GetGunPosition, iPlayer, fOrigin);
  698.    
  699.     pev(iPlayer, pev_angles, fAngles);
  700.     pev(iPlayer, pev_v_angle, fAngles);
  701.    
  702.     global_get(glb_v_forward, Forward);
  703.     global_get(glb_v_right, Right);
  704.     global_get(glb_v_up, Up);
  705.    
  706.     xs_vec_mul_scalar(Forward, add_forward, Forward);
  707.     xs_vec_mul_scalar(Right, add_right, Right);
  708.     xs_vec_mul_scalar(Up, add_up, Up);
  709.    
  710.     fOrigin[0] = fOrigin[0] + Forward[0] + Right[0] + Up[0];
  711.     fOrigin[1] = fOrigin[1] + Forward[1] + Right[1] + Up[1];
  712.     fOrigin[2] = fOrigin[2] + Forward[2] + Right[2] + Up[2];
  713. }
  714.  
  715. stock FindHullIntersection(const Float: vecSrc[3], &iTrace, const Float: vecMins[3], const Float: vecMaxs[3], const iEntity)
  716. {
  717.     new iTempTrace;
  718.    
  719.     new Float: flFraction;
  720.     new Float: flThisDistance;
  721.    
  722.     new Float: vecEnd[3];
  723.     new Float: vecEndPos[3];
  724.     new Float: vecHullEnd[3];
  725.     new Float: vecMinMaxs[2][3];
  726.    
  727.     new Float: flDistance = 999999.0;
  728.    
  729.     xs_vec_copy(vecMins, vecMinMaxs[0]);
  730.     xs_vec_copy(vecMaxs, vecMinMaxs[1]);
  731.    
  732.     get_tr2(iTrace, TR_vecEndPos, vecHullEnd);
  733.    
  734.     xs_vec_sub(vecHullEnd, vecSrc, vecHullEnd);
  735.     xs_vec_mul_scalar(vecHullEnd, 2.0, vecHullEnd);
  736.     xs_vec_add(vecHullEnd, vecSrc, vecHullEnd);
  737.    
  738.     engfunc(EngFunc_TraceLine, vecSrc, vecHullEnd, DONT_IGNORE_MONSTERS, iEntity, (iTempTrace = create_tr2()));
  739.     get_tr2(iTempTrace, TR_flFraction, flFraction);
  740.    
  741.     if (flFraction < 1.0)
  742.     {
  743.         free_tr2(iTrace);
  744.        
  745.         iTrace = iTempTrace;
  746.         return;
  747.     }
  748.    
  749.     for (new j, k, i = 0; i < 2; i++)
  750.     {
  751.         for (j = 0; j < 2; j++)
  752.         {
  753.             for (k = 0; k < 2; k++)
  754.             {
  755.                 vecEnd[0] = vecHullEnd[0] + vecMinMaxs[i][0];
  756.                 vecEnd[1] = vecHullEnd[1] + vecMinMaxs[j][1];
  757.                 vecEnd[2] = vecHullEnd[2] + vecMinMaxs[k][2];
  758.                
  759.                 engfunc(EngFunc_TraceLine, vecSrc, vecEnd, DONT_IGNORE_MONSTERS, iEntity, iTempTrace);
  760.                 get_tr2(iTempTrace, TR_flFraction, flFraction);
  761.                
  762.                 if (flFraction < 1.0)
  763.                 {
  764.                     get_tr2(iTempTrace, TR_vecEndPos, vecEndPos);
  765.                     xs_vec_sub(vecEndPos, vecSrc, vecEndPos);
  766.                    
  767.                     if ((flThisDistance = xs_vec_len(vecEndPos)) < flDistance)
  768.                     {
  769.                         free_tr2(iTrace);
  770.                        
  771.                         iTrace = iTempTrace;
  772.                         flDistance = flThisDistance;
  773.                     }
  774.                 }
  775.             }
  776.         }
  777.     }
  778. }
  779.  
  780. stock CreateExplosion(const Float:Origin[3], const Float:CordZ = 0.0, const iModel, const iScale, const iFramerate, const iFlag)
  781. {
  782.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  783.     write_byte(TE_EXPLOSION);
  784.     engfunc(EngFunc_WriteCoord, Origin[0]);
  785.     engfunc(EngFunc_WriteCoord, Origin[1]);
  786.     engfunc(EngFunc_WriteCoord, Origin[2]  + CordZ);
  787.     write_short(iModel);
  788.     write_byte(iScale);
  789.     write_byte(iFramerate);
  790.     write_byte(iFlag);
  791.     message_end();
  792. }
  793.  
  794. stock FakeKnockBack(iPlayer, Float:vecDirection[3], Float:flKnockBack)
  795. {
  796.     static Float:vecVelocity[3]; pev(iPlayer, pev_velocity, vecVelocity);
  797.    
  798.     if (pev(iPlayer, pev_flags) & FL_DUCKING)
  799.     {
  800.         flKnockBack *= 0.7;
  801.     }
  802.    
  803.     vecVelocity[0] = vecDirection[0] * 500.0 * flKnockBack;
  804.     vecVelocity[1] = vecDirection[1] * 500.0 * flKnockBack;
  805.     vecVelocity[2] = 300.0;
  806.    
  807.     set_pev(iPlayer, pev_velocity, vecVelocity);
  808. }
  809.  
  810. stock Player_SetAnimation(const iPlayer, const szAnim[])
  811. {
  812.     #define ACT_RANGE_ATTACK1   28
  813.        
  814.     // Linux extra offsets
  815.     #define extra_offset_animating   4
  816.        
  817.     // CBaseAnimating
  818.     #define m_flFrameRate      36
  819.     #define m_flGroundSpeed      37
  820.     #define m_flLastEventCheck   38
  821.     #define m_fSequenceFinished   39
  822.     #define m_fSequenceLoops   40
  823.        
  824.     // CBaseMonster
  825.     #define m_Activity      73
  826.     #define m_IdealActivity      74
  827.        
  828.        // CBasePlayer
  829.     #define m_flLastAttackTime   220
  830.    
  831.     new iAnimDesired, Float: flFrameRate, Float: flGroundSpeed, bool: bLoops;
  832.          
  833.     if ((iAnimDesired = lookup_sequence(iPlayer, szAnim, flFrameRate, bLoops, flGroundSpeed)) == -1)
  834.     {
  835.         iAnimDesired = 0;
  836.     }
  837.        
  838.     new Float: flGametime = get_gametime();
  839.    
  840.     set_pev(iPlayer, pev_frame, 0.0);
  841.     set_pev(iPlayer, pev_framerate, 1.0);
  842.     set_pev(iPlayer, pev_animtime, flGametime);
  843.     set_pev(iPlayer, pev_sequence, iAnimDesired);
  844.        
  845.     set_pdata_int(iPlayer, m_fSequenceLoops, bLoops, extra_offset_animating);
  846.     set_pdata_int(iPlayer, m_fSequenceFinished, 0, extra_offset_animating);
  847.        
  848.     set_pdata_float(iPlayer, m_flFrameRate, flFrameRate, extra_offset_animating);
  849.     set_pdata_float(iPlayer, m_flGroundSpeed, flGroundSpeed, extra_offset_animating);
  850.     set_pdata_float(iPlayer, m_flLastEventCheck, flGametime , extra_offset_animating);
  851.        
  852.     set_pdata_int(iPlayer, m_Activity, ACT_RANGE_ATTACK1, extra_offset_player);
  853.     set_pdata_int(iPlayer, m_IdealActivity, ACT_RANGE_ATTACK1, extra_offset_player);  
  854.     set_pdata_float(iPlayer, m_flLastAttackTime, flGametime , extra_offset_player);
  855. }
  856.  
  857. #if !defined _ZP
  858. public zp_user_infected_post(iPlayer)
  859. {
  860.     IsKnife[iPlayer] = false;
  861. }
  862. #else
  863. public ze_user_infected_pre(iVictim, iInfector, iDamage)
  864. {
  865.     IsKnife[iVictim] = false;
  866. }
  867. #endif
  868.  
  869. public Weapon_Select(const iPlayer)
  870. {
  871.     engclient_cmd(iPlayer, WEAPON_REFERANCE);
  872.    
  873.     IsKnife[iPlayer] = true;
  874.    
  875.     emessage_begin(MSG_ONE, get_user_msgid("CurWeapon"), _, iPlayer);
  876.     ewrite_byte(1);
  877.     ewrite_byte(CSW_KNIFE);
  878.     ewrite_byte(-1);
  879.     emessage_end();
  880.    
  881.     new iItem = get_pdata_cbase(iPlayer, m_pActiveItem, extra_offset_player);
  882.  
  883.     if (pev_valid(iItem))
  884.     {
  885.         ExecuteHamB(Ham_Item_Deploy, iItem);
  886.     }
  887. }
  888.  
  889. PRECACHE_SOUNDS_FROM_MODEL(const szModelPath[])
  890. {
  891.     new iFile;
  892.    
  893.     if ((iFile = fopen(szModelPath, "rt")))
  894.     {
  895.         new szSoundPath[64];
  896.        
  897.         new iNumSeq, iSeqIndex;
  898.         new iEvent, iNumEvents, iEventIndex;
  899.        
  900.         fseek(iFile, 164, SEEK_SET);
  901.         fread(iFile, iNumSeq, BLOCK_INT);
  902.         fread(iFile, iSeqIndex, BLOCK_INT);
  903.        
  904.         for (new k, i = 0; i < iNumSeq; i++)
  905.         {
  906.             fseek(iFile, iSeqIndex + 48 + 176 * i, SEEK_SET);
  907.             fread(iFile, iNumEvents, BLOCK_INT);
  908.             fread(iFile, iEventIndex, BLOCK_INT);
  909.             fseek(iFile, iEventIndex + 176 * i, SEEK_SET);
  910.  
  911.             for (k = 0; k < iNumEvents; k++)
  912.             {
  913.                 fseek(iFile, iEventIndex + 4 + 76 * k, SEEK_SET);
  914.                 fread(iFile, iEvent, BLOCK_INT);
  915.                 fseek(iFile, 4, SEEK_CUR);
  916.                
  917.                 if (iEvent != 5004)
  918.                 {
  919.                     continue;
  920.                 }
  921.  
  922.                 fread_blocks(iFile, szSoundPath, 64, BLOCK_CHAR);
  923.                
  924.                 if (strlen(szSoundPath))
  925.                 {
  926.                     strtolower(szSoundPath);
  927.                     PRECACHE_SOUND(szSoundPath);
  928.                 }
  929.             }
  930.         }
  931.     }
  932.     fclose(iFile);
  933. }
  934. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  935. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
  936. */
this is it(knife menu):

Code: Select all

#include <zombie_escape>
#include <engine>
#include <fun>
#include <ze_vip>
 
#pragma tabsize 0
 
#define HOLYSWORD_COST 2600
#define WARHAMMER_COST 500
 
// Models
new const Storm_Models[][] =
{
    "models/v_axe.mdl",
    "models/p_axe.mdl"
}
 
new const Turbulent9_Models[][] =
{
    "models/v_turbulent9_knife.mdl",
    "models/p_turbulent9_knife.mdl"
}
 
new const Sabers_Models[][] =
{
    "models/v_laser_knife.mdl",
    "models/p_laser_knife.mdl"
}
 
new const Plasma_Models[][] =
{
    "models/v_stick.mdl",
    "models/p_stick.mdl"
}
 
new const Laevateinn_Models[][] =
{
    "models/v_black.mdl",
    "models/p_black.mdl"
}
 
 
 
// Sounds
new const g_sound_knife[] = "items/gunpickup2.wav"
 
new const storm_sounds[][] =
{
    "zombie_escape/knife_menu/storm_sword_deploy.wav",
    "zombie_escape/knife_menu/storm_sword_hit.wav",
    "zombie_escape/knife_menu/storm_sword_hit.wav",
    "zombie_escape/knife_menu/storm_sword_hit.wav",
    "zombie_escape/knife_menu/storm_sword_hit.wav",
    "zombie_escape/knife_menu/storm_sword_hitwall.wav",
    "zombie_escape/knife_menu/storm_sword_slash.wav",
    "zombie_escape/knife_menu/storm_sword_slash.wav",
    "zombie_escape/knife_menu/storm_sword_stab.wav"
}
 
new const turbulent9_sounds[][] =
{
    "zombie_escape/knife_menu/turbulent9_deploy.wav",
    "zombie_escape/knife_menu/turbulent9_hit.wav",
    "zombie_escape/knife_menu/turbulent9_hit.wav",
    "zombie_escape/knife_menu/turbulent9_hit.wav",
    "zombie_escape/knife_menu/turbulent9_hit.wav",
    "zombie_escape/knife_menu/turbulent9_hitwall.wav",
    "zombie_escape/knife_menu/turbulent9_slash.wav",
    "zombie_escape/knife_menu/turbulent9_slash.wav",
    "zombie_escape/knife_menu/turbulent9_stab.wav"
}
 
new const sabers_sounds[][] =
{
    "zombie_escape/knife_menu/laser_deploy.wav",
    "zombie_escape/knife_menu/laser_hit.wav",
    "zombie_escape/knife_menu/laser_hit.wav",
    "zombie_escape/knife_menu/laser_hit.wav",
    "zombie_escape/knife_menu/laser_hit.wav",
    "zombie_escape/knife_menu/laser_hitwall.wav",
    "zombie_escape/knife_menu/laser_slash1.wav",
    "zombie_escape/knife_menu/laser_slash2.wav",
    "zombie_escape/knife_menu/laser_stab.wav"
}
 
new const plasma_sounds[][] =
{
    "zombie_escape/knife_menu/plasma_deploy.wav",
    "zombie_escape/knife_menu/plasma_hit.wav",
    "zombie_escape/knife_menu/plasma_hit.wav",
    "zombie_escape/knife_menu/plasma_hit.wav",
    "zombie_escape/knife_menu/plasma_hit.wav",
    "zombie_escape/knife_menu/plasma_hitwall.wav",
    "zombie_escape/knife_menu/plasma_slash.wav",
    "zombie_escape/knife_menu/plasma_slash.wav",
    "zombie_escape/knife_menu/plasma_stab.wav"
}
 
new const laevateinn_sounds[][] =
{
    "zombie_escape/knife_menu/laevateinn_deploy.wav",
    "zombie_escape/knife_menu/laevateinn_hit.wav",
    "zombie_escape/knife_menu/laevateinn_hit.wav",
    "zombie_escape/knife_menu/laevateinn_hit.wav",
    "zombie_escape/knife_menu/laevateinn_hit.wav",
    "zombie_escape/knife_menu/laevateinn_hitwall.wav",
    "zombie_escape/knife_menu/laevateinn_slash.wav",
    "zombie_escape/knife_menu/laevateinn_slash.wav",
    "zombie_escape/knife_menu/laevateinn_stab.wav"
}
 
new const oldknife_sounds[][] =
{
    "weapons/knife_deploy1.wav",
    "weapons/knife_hit1.wav",
    "weapons/knife_hit2.wav",
    "weapons/knife_hit3.wav",
    "weapons/knife_hit4.wav",
    "weapons/knife_hitwall1.wav",
    "weapons/knife_slash1.wav",
    "weapons/knife_slash2.wav",
    "weapons/knife_stab.wav"
}
 
new bool:g_bTurbulent9[33], bool:g_bSabers[33], bool:g_bPlasma[33],
bool:g_bStorm[33], bool:g_bLaevateinn[33], bool:g_bNoSpeed, g_iUsedTimes[33], g_pCvarUseTimes
 
new cvar_speed_storm
new cvar_speed_turb
new cvar_speed_sabers
new cvar_speed_plasma
new cvar_speed_laevat
 
native SetUserHolySword(id)
native DelUserHolySword(id)
native SetUserWarHammer(id)
public plugin_precache()
{
    new i
 
    for (i = 0; i <= charsmax(Storm_Models); i++)
        precache_model(Storm_Models[i])
 
    for (i = 0; i <= charsmax(Turbulent9_Models); i++)
        precache_model(Turbulent9_Models[i])
 
    for (i = 0; i <= charsmax(Sabers_Models); i++)
        precache_model(Sabers_Models[i])
 
    for (i = 0; i <= charsmax(Plasma_Models); i++)
        precache_model(Plasma_Models[i])
 
    for (i = 0; i <= charsmax(Laevateinn_Models); i++)
        precache_model(Laevateinn_Models[i])
 
    for (i = 0; i <= charsmax(storm_sounds); i++)
        precache_sound(storm_sounds[i])
 
    for (i = 0; i <= charsmax(turbulent9_sounds); i++)
        precache_sound(turbulent9_sounds[i])
 
    for (i = 0; i <= charsmax(sabers_sounds); i++)
        precache_sound(sabers_sounds[i])       
 
    for (i = 0; i <= charsmax(plasma_sounds); i++)
        precache_sound(plasma_sounds[i])
 
    for (i = 0; i <= charsmax(laevateinn_sounds); i++)
        precache_sound(laevateinn_sounds[i])
 
    precache_sound(g_sound_knife)
}
 
public plugin_natives()
{
    register_native("ze_open_knife_menu", "native_ze_open_knife_menu", 1)
}
 
public plugin_init()
{
    register_plugin("[ZE] Addon: Knife Menu", "1.3", "Mark")
 
    register_forward(FM_EmitSound, "fw_EmitSound")
    register_forward(FM_PlayerPreThink, "fw_PlayerPreThink");
 
    register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
    RegisterHookChain(RG_CBasePlayer_ResetMaxSpeed, "Fw_RestMaxSpeed_Post", 1)
   
    g_pCvarUseTimes = register_cvar("ze_knife_menu_use_times", "1000")
 
    register_message(get_user_msgid("DeathMsg"), "DeathMsg")
 
    register_clcmd("say /km", "Show_Knife_Menu")
   
    cvar_speed_storm = register_cvar("ze_storm_speed", "285.0")
    cvar_speed_turb = register_cvar("ze_turb_speed", "285.0")
    cvar_speed_sabers = register_cvar("ze_sabers_speed", "285.0")    
    cvar_speed_plasma = register_cvar("ze_plasma_speed", "295.0")  
    cvar_speed_laevat = register_cvar("ze_laevat_speed", "305.0")  
}
 
public ze_user_humanized(id)
{
    g_iUsedTimes[id] = 0
}
 
/*public ze_user_infected(Victim)
{
    g_bStorm[Victim] = false
    g_bTurbulent9[Victim] = false  
    g_bSabers[Victim] = false  
    g_bPlasma[Victim] = false
    g_bLaevateinn[Victim] = false
    g_iUsedTimes[Victim] = 0
}*/
 
public client_putinserver(id)
{  
    DelUserHolySword(id)
    g_bStorm[id] = false
    g_bTurbulent9[id] = false  
    g_bSabers[id] = false  
    g_bPlasma[id] = false
    g_bLaevateinn[id] = false
    g_iUsedTimes[id] = 0
}
 
public client_disconnected(id)
{
    DelUserHolySword(id)   
    g_bStorm[id] = false
    g_bTurbulent9[id] = false
    g_bSabers[id] = false  
    g_bPlasma[id] = false
    g_bLaevateinn[id] = false
    g_iUsedTimes[id] = 0
}
 
public ze_game_started()
{
    g_bNoSpeed = true
}
 
public ze_zombie_release()
{
    g_bNoSpeed = false
   
    // call the reset speed function ;)
    for(new id = 1; id <= 32; id++)
    {
        if (!is_user_alive(id))
            continue;
       
        rg_reset_maxspeed(id)
    }
}
 
public Show_Knife_Menu(id)
{
    if (!is_user_connected(id))
        return PLUGIN_CONTINUE
 
    if (ze_is_user_zombie(id))
    {
        ze_colored_print(id, "!tZombies can't open knife menu!y.")
        return PLUGIN_HANDLED
    }
 
    if (g_iUsedTimes[id] >= get_pcvar_num(g_pCvarUseTimes))
    {
        ze_colored_print(id, "!tYou can only open knife menu !y[!g%dx!y] per round!", get_pcvar_num(g_pCvarUseTimes))
        return PLUGIN_HANDLED
    }
 
    if (!is_user_alive(id))
    {
        ze_colored_print(id, "!tDead can't open knife menu!y.")
        return PLUGIN_HANDLED
    }
 
    Knife_Menu(id)
    return PLUGIN_CONTINUE
}
 
public Knife_Menu(id)
{
    new iMenu = menu_create("\rChoose Your Knife\w:^n^n- [ \ySpeed \rActivates \yon Zombie Release!\w ]^n\w- [ \r9 \yknives in Total!\w ] ^n-", "Menu_Handler")
    menu_additem(iMenu, "\yAxe \w[ \r285 Speed\w ]", "", 0)
    menu_additem(iMenu, "\yTurbulent-9 \w[ \r285 Speed\w ]", "", 0)
    menu_additem(iMenu, "\ySabers \w[ \r285 Speed\w ]", "", 0) 
    menu_additem(iMenu, "\yWarhammer", "", 0)

    if (ze_get_vip_flags(id) & VIP_A)
    {
        menu_additem(iMenu, "\yCrowbar \w[ \rVIP\w ] [ \r295 Speed\w ]", "", 0)            
    }
   
    if (ze_get_vip_flags(id) & VIP_F)
    {
        menu_additem(iMenu, "\yBlack Sword \w[ \rSVIP\w ] [ \r305 Speed\w ]", "", 0)
        menu_additem(iMenu, "\yHolySword (SVIP) \w[\r2600 \ycoins\w]", "", 0)          
    }
        menu_setprop(iMenu,MPROP_EXITNAME,"Close")
        menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL)
        menu_display(id, iMenu, 0) 
}
 
public Menu_Handler(id, iMenu, iKey)
{
    if(!is_user_alive(id) || ze_is_user_zombie(id))
        return PLUGIN_HANDLED
       
    switch(iKey)
    {
        case 0: // Storm
        {
        DelUserHolySword(id)
            g_bTurbulent9[id] = false
            g_bSabers[id] = false
            g_bPlasma[id] = false
            g_bStorm[id] = true
            g_bLaevateinn[id] = false
            g_iUsedTimes[id] = 0
            rg_remove_item(id, "weapon_knife")
            rg_give_item(id, "weapon_knife", GT_APPEND)
            //engclient_cmd(id, "weapon_knife")
            //g_iUsedTimes[id]++
            //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
           
        }
        case 1: // Turbulent
        {
        DelUserHolySword(id)       
            g_bTurbulent9[id] = true
            g_bSabers[id] = false
            g_bPlasma[id] = false
            g_bStorm[id] = false
            g_bLaevateinn[id] = false
            g_iUsedTimes[id] = 0       
            rg_remove_item(id, "weapon_knife")
            rg_give_item(id, "weapon_knife", GT_APPEND)
            //engclient_cmd(id, "weapon_knife")
            //g_iUsedTimes[id]++
            //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
           
        }
        case 2: // Sabers
        {
        DelUserHolySword(id)       
            g_bTurbulent9[id] = false
            g_bSabers[id] = true
            g_bPlasma[id] = false
            g_bStorm[id] = false
            g_bLaevateinn[id] = false  
            g_iUsedTimes[id] = 0       
            rg_remove_item(id, "weapon_knife")
            rg_give_item(id, "weapon_knife", GT_APPEND)
            //engclient_cmd(id, "weapon_knife")
            //g_iUsedTimes[id]++
            //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
           
        }                                
        case 3: // Plasma
        {
        DelUserHolySword(id)       
            g_bTurbulent9[id] = false
            g_bSabers[id] = false
            g_bPlasma[id] = true
            g_bStorm[id] = false
            g_bLaevateinn[id] = false
            g_iUsedTimes[id] = 0       
            rg_remove_item(id, "weapon_knife")
            rg_give_item(id, "weapon_knife", GT_APPEND)
            //engclient_cmd(id, "weapon_knife")
            //g_iUsedTimes[id]++
            //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
           
        }
        case 4: // Warhammer
        {
		if (ze_get_escape_coins(id) < WARHAMMER_COST)
		{
			ze_set_escape_coins(id,ze_get_escape_coins(id)+WARHAMMER_COST); //return coins
			return PLUGIN_HANDLED;
		}
		ze_set_escape_coins(id,ze_get_escape_coins(id) - WARHAMMER_COST);
		SetUserWarHammer(id)
        }
        case 5: // Laevateinn
        {
        DelUserHolySword(id)       
            g_bTurbulent9[id] = false
            g_bSabers[id] = false
            g_bPlasma[id] = false
            g_bStorm[id] = false
            g_bLaevateinn[id] = true   
            g_iUsedTimes[id] = 0           
            rg_remove_item(id, "weapon_knife")
            rg_give_item(id, "weapon_knife", GT_APPEND)
            //engclient_cmd(id, "weapon_knife")
            //g_iUsedTimes[id]++
            //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
           
        }  
        case 6: // Holysword
        {      
    if (ze_get_escape_coins(id) < HOLYSWORD_COST)
    {
        //ze_set_escape_coins(id,ze_get_escape_coins(id)+HOLYSWORD_COST); //return coins
        return PLUGIN_HANDLED;
    }
    ze_set_escape_coins(id,ze_get_escape_coins(id) - HOLYSWORD_COST);
   
        SetUserHolySword(id)       
            g_bTurbulent9[id] = false
            g_bSabers[id] = false
            g_bPlasma[id] = false
            g_bStorm[id] = false
            g_bLaevateinn[id] = false  
            g_iUsedTimes[id] = 0       
            rg_remove_item(id, "weapon_knife")
            rg_give_item(id, "weapon_knife", GT_APPEND)
            //engclient_cmd(id, "weapon_knife")
            //g_iUsedTimes[id]++
            //emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
           
        }          
    }
 
    menu_destroy(iMenu)
    return PLUGIN_HANDLED
}
 
public fw_EmitSound(id, channel, const sound[])
{
    if(!is_user_alive(id) || ze_is_user_zombie(id))
        return FMRES_IGNORED
       
    new i
    for (i = 0; i <= charsmax(turbulent9_sounds); i++)
    for (i = 0; i <= charsmax(sabers_sounds); i++)
    for (i = 0; i <= charsmax(plasma_sounds); i++)
    for (i = 0; i <= charsmax(storm_sounds); i++)
    for (i = 0; i <= charsmax(laevateinn_sounds); i++)
 
    {
        if(equal(sound, oldknife_sounds[i]))
        {
 
            if ((g_bTurbulent9[id]))
            {
                emit_sound(id, channel, turbulent9_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if ((g_bSabers[id]))
            {
                emit_sound(id, channel, sabers_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if ((g_bPlasma[id]) && (ze_get_vip_flags(id) & VIP_A))
            {
                emit_sound(id, channel, plasma_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if ((g_bStorm[id]))
            {
                emit_sound(id, channel, storm_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if ((g_bLaevateinn[id]) && (ze_get_vip_flags(id) & VIP_F))
            {
                emit_sound(id, channel, laevateinn_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            else if (!g_bTurbulent9[id] || !g_bSabers[id] || !g_bPlasma[id] || !g_bStorm[id] || !g_bLaevateinn[id])
            {
                emit_sound(id, channel, oldknife_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
        }
    }
    return FMRES_IGNORED
}
 
public CurrentWeapon(id)
{
    if(!is_user_alive(id) || ze_is_user_zombie(id))
        return
       
    if(get_user_weapon(id) & CSW_KNIFE)
    {
 
        if((g_bTurbulent9[id]))
        {
            cs_set_player_view_model(id, CSW_KNIFE, Turbulent9_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Turbulent9_Models[1])
        }
        else if((g_bSabers[id]))
        {
            cs_set_player_view_model(id, CSW_KNIFE, Sabers_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Sabers_Models[1])
        }
        else if((g_bPlasma[id]) && (ze_get_vip_flags(id) & VIP_A))
        {
            cs_set_player_view_model(id, CSW_KNIFE, Plasma_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Plasma_Models[1])
        }
        else if((g_bStorm[id]) && (ze_get_vip_flags(id) & VIP_A))
        {
            cs_set_player_view_model(id, CSW_KNIFE, Storm_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Storm_Models[1])
        }
        else if((g_bLaevateinn[id]) && (ze_get_vip_flags(id) & VIP_A))
        {
            cs_set_player_view_model(id, CSW_KNIFE, Laevateinn_Models[0])
            cs_set_player_weap_model(id, CSW_KNIFE, Laevateinn_Models[1])
        }  
    }
}
 
public Fw_RestMaxSpeed_Post(id)
{
    if (g_bNoSpeed)
        return
       
    set_task(0.1, "DelayLoad", id)
   
}
 
public DelayLoad(id)
{
    new iWpnId = (get_user_weapon(id))
   
    if (iWpnId == CSW_KNIFE && g_bTurbulent9[id])
    {
        if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
        {
            new iFlags = get_entvar(id, var_flags);
            new iWaterlvl = get_entvar(id, var_waterlevel)
           
            if (!(iFlags & FL_ONGROUND))
                return HC_CONTINUE
 
            if (iFlags & FL_WATERJUMP)
                return HAM_IGNORED
 
            if (iWaterlvl > 1)
                return HAM_IGNORED
           
            new Float:flVelocity[3]
            get_entvar(id , var_velocity , flVelocity)
 
            flVelocity[2] += 325
 
            set_entvar(id , var_velocity , flVelocity)
 
            set_entvar(id, var_gaitsequence, 6)
        }
       
        set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_turb))
    }
    if (iWpnId == CSW_KNIFE && g_bSabers[id])
    {
        if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
        {
            new iFlags = get_entvar(id, var_flags);
            new iWaterlvl = get_entvar(id, var_waterlevel)
           
            if (!(iFlags & FL_ONGROUND))
                return HC_CONTINUE
 
            if (iFlags & FL_WATERJUMP)
                return HAM_IGNORED
 
            if (iWaterlvl > 1)
                return HAM_IGNORED
           
            new Float:flVelocity[3]
            get_entvar(id , var_velocity , flVelocity)
 
            flVelocity[2] += 325
 
            set_entvar(id , var_velocity , flVelocity)
 
            set_entvar(id, var_gaitsequence, 6)
        }
       
        set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_sabers))
    }
    if (iWpnId == CSW_KNIFE && g_bPlasma[id])
    {
        if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
        {
            new iFlags = get_entvar(id, var_flags);
            new iWaterlvl = get_entvar(id, var_waterlevel)
           
            if (!(iFlags & FL_ONGROUND))
                return HC_CONTINUE
 
            if (iFlags & FL_WATERJUMP)
                return HAM_IGNORED
 
            if (iWaterlvl > 1)
                return HAM_IGNORED
           
            new Float:flVelocity[3]
            get_entvar(id , var_velocity , flVelocity)
 
            flVelocity[2] += 325
 
            set_entvar(id , var_velocity , flVelocity)
 
            set_entvar(id, var_gaitsequence, 6)
        }
       
        set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_plasma))
    }
    if (iWpnId == CSW_KNIFE && g_bStorm[id])
    {
        if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
        {
            new iFlags = get_entvar(id, var_flags);
            new iWaterlvl = get_entvar(id, var_waterlevel)
           
            if (!(iFlags & FL_ONGROUND))
                return HC_CONTINUE
 
            if (iFlags & FL_WATERJUMP)
                return HAM_IGNORED
 
            if (iWaterlvl > 1)
                return HAM_IGNORED
           
            new Float:flVelocity[3]
            get_entvar(id , var_velocity , flVelocity)
 
            flVelocity[2] += 325
 
            set_entvar(id , var_velocity , flVelocity)
 
            set_entvar(id, var_gaitsequence, 6)
        }
       
        set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_storm))
    }
    if (iWpnId == CSW_KNIFE && g_bLaevateinn[id])
    {
        if ((get_entvar(id, var_button) & IN_JUMP) && !(get_entvar(id, var_oldbuttons) & IN_JUMP))
        {
            new iFlags = get_entvar(id, var_flags);
            new iWaterlvl = get_entvar(id, var_waterlevel)
           
            if (!(iFlags & FL_ONGROUND))
                return HC_CONTINUE
 
            if (iFlags & FL_WATERJUMP)
                return HAM_IGNORED
 
            if (iWaterlvl > 1)
                return HAM_IGNORED
           
            new Float:flVelocity[3]
            get_entvar(id , var_velocity , flVelocity)
 
            flVelocity[2] += 325
 
            set_entvar(id , var_velocity , flVelocity)
 
            set_entvar(id, var_gaitsequence, 6)
        }
       
        set_entvar(id, var_maxspeed, get_pcvar_float(cvar_speed_laevat))
    }
 
    return HAM_IGNORED
}
public DeathMsg(msg_id, msg_dest, id)
{
    static szTruncatedWeapon[33], iAttacker
    get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
    iAttacker = get_msg_arg_int(1)
   
    if(!is_user_alive(iAttacker) || iAttacker == get_msg_arg_int(2) || !is_user_alive(get_msg_arg_int(2))) // get_msg_arg_int(2) = iVictim
        return
   
    if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iAttacker) & CSW_KNIFE)
    {
 
        if(g_bTurbulent9[id])
        {
            set_msg_arg_string(4, "Turbulent9 knife")
        }
        else if(g_bSabers[id])
        {
            set_msg_arg_string(4, "Sabers knife")
        }
        else if(g_bPlasma[id])
        {
            set_msg_arg_string(4, "Plasma knife")
        }
        else if(g_bStorm[id])
        {
            set_msg_arg_string(4, "Storm knife")
        }
        else if(g_bLaevateinn[id])
        {
            set_msg_arg_string(4, "Laevateinn knife")
        }
    }
}
 
stock fm_set_user_maxspeed(index, Float:speed = -1.0)
{
        engfunc(EngFunc_SetClientMaxspeed, index, speed);
        set_pev(index, pev_maxspeed, speed);
 
        return 1;
}  
 
public native_ze_open_knife_menu(id)
{
    Show_Knife_Menu(id)
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.