Convert Plugin ZP Knife Menu

Unpaid Requests, Public Plugins
User avatar
alexnovac18
Member
Member
Romania
Posts: 28
Joined: 5 years ago
Location: Romania
Contact:

#21

Post by alexnovac18 » 4 years ago

not work.. server shout down.. same you can run..

Muhammet20
Veteran Member
Veteran Member
Posts: 408
Joined: 5 years ago
Contact:

#22

Post by Muhammet20 » 4 years ago

alexnovac18 wrote: 4 years ago not work.. server shout down.. same you can run..
sorry bro :(
if i can help i will

User avatar
alexnovac18
Member
Member
Romania
Posts: 28
Joined: 5 years ago
Location: Romania
Contact:

#23

Post by alexnovac18 » 4 years ago

Muhammet20 wrote: 4 years ago
alexnovac18 wrote: 4 years ago not work.. server shout down.. same you can run..
sorry bro :(
if i can help i will
its ok bro.. if you want, i give you server cs 1.6 for testing this plugin , ftp full acces + gameCP

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#24

Post by Raheem » 4 years ago

Can you tell me when it crashes? What action you did then it crashes?
He who fails to plan is planning to fail

User avatar
alexnovac18
Member
Member
Romania
Posts: 28
Joined: 5 years ago
Location: Romania
Contact:

#25

Post by alexnovac18 » 4 years ago

Raheem wrote: 4 years ago Can you tell me when it crashes? What action you did then it crashes?
immediately goes shut down server, i changed map, after 10 seconds to infect, the server shuts down...

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#26

Post by Raheem » 4 years ago

Upload models, sounds required so i can test it.
He who fails to plan is planning to fail

User avatar
alexnovac18
Member
Member
Romania
Posts: 28
Joined: 5 years ago
Location: Romania
Contact:

#27

Post by alexnovac18 » 4 years ago

Raheem wrote: 4 years ago Upload models, sounds required so i can test it.
zp_knife_menu.zip
(2.65 MiB) Downloaded 414 times
zp_knife_menu.zip
(2.65 MiB) Downloaded 414 times

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#28

Post by Raheem » 4 years ago

Here is the fixed one:

  1. #include <zombie_escape>
  2. #include <engine>
  3. #include <fun>
  4.  
  5. #define PLUGIN    "Choose knifes"
  6. #define VERSION    "1.0"
  7. #define AUTHOR    "CHyC/4e/l"
  8.  
  9. #define VIP ADMIN_LEVEL_H
  10. #define MAXPLAYERS 32
  11.  
  12. new combat_v_model[] = "models/zb/v_combat_knife.mdl"
  13. new combat_p_model[] = "models/zb/p_combat_knife.mdl"
  14.  
  15. new strong_v_model[] = "models/zb/v_strong_knife.mdl"
  16. new strong_p_model[] = "models/zb/p_strong_knife.mdl"
  17.  
  18. new axe_v_model[] = "models/zb/v_axe_knife.mdl"
  19. new axe_p_model[] = "models/zb/p_axe_knife.mdl"
  20.  
  21. new katana_v_model[] = "models/zb/v_katana_knife.mdl"  
  22. new katana_p_model[] = "models/zb/p_katana_knife.mdl"
  23.  
  24. new hammer_v_model[] = "models/zb/v_hammer_knife.mdl"  
  25. new hammer_p_model[] = "models/zb/p_hammer_knife.mdl"  
  26.  
  27. const m_pPlayer = 41
  28. const m_flNextPrimaryAttack = 46
  29. const m_flNextSecondaryAttack = 47
  30. const m_flTimeWeaponIdle = 48
  31.  
  32. new g_hasSpeed[33], SayText
  33. new bool:g_WasShowed[MAXPLAYERS + 1]
  34. new g_knife_combat[33], cvar_knife_combat_jump, cvar_knife_combat_spd, cvar_knife_combat_dmg, cvar_knife_combat_knock, cvar_knife_combat_spd_attack2
  35. new g_knife_strong[33], cvar_knife_strong_jump, cvar_knife_strong_spd, cvar_knife_strong_dmg, cvar_knife_strong_knock, cvar_knife_strong_spd_attack2
  36. new g_knife_axe[33], cvar_knife_axe_jump, cvar_knife_axe_spd, cvar_knife_axe_dmg, cvar_knife_axe_knock, cvar_knife_axe_spd_attack2
  37. new g_knife_katana[33], cvar_knife_katana_jump, cvar_knife_katana_spd, cvar_knife_katana_dmg, cvar_knife_katana_knock, cvar_knife_katana_spd_attack2
  38. new g_knife_hammer[33], cvar_knife_hammer_jump, cvar_knife_hammer_spd, cvar_knife_hammer_dmg, cvar_knife_hammer_knock, cvar_hammer_spd_attack2
  39.  
  40. new const g_sound_knife[] = { "items/gunpickup2.wav" }
  41.  
  42. new const combat_sounds[][] =
  43. {
  44.     "zmwpn/zb_knife/combat_deploy.wav",
  45.     "zmwpn/zb_knife/combat_hit.wav" ,
  46.     "zmwpn/zb_knife/combat_hit.wav" ,
  47.     "zmwpn/zb_knife/combat_hit.wav" ,
  48.     "zmwpn/zb_knife/combat_hit.wav" ,
  49.     "zmwpn/zb_knife/combat_hitwall.wav",
  50.     "zmwpn/zb_knife/combat_slash.wav",
  51.     "zmwpn/zb_knife/combat_slash.wav",
  52.     "zmwpn/zb_knife/combat_stab.wav"
  53. }
  54.  
  55. new const strong_sounds[][] =
  56. {
  57.     "zmwpn/zb_knife/strong_deploy.wav",
  58.     "zmwpn/zb_knife/strong_hit.wav",
  59.     "zmwpn/zb_knife/strong_hit.wav",
  60.     "zmwpn/zb_knife/strong_hit.wav",
  61.     "zmwpn/zb_knife/strong_hit.wav",
  62.     "zmwpn/zb_knife/strong_hitwall.wav",
  63.     "zmwpn/zb_knife/strong_slash.wav",
  64.     "zmwpn/zb_knife/strong_slash.wav",
  65.     "zmwpn/zb_knife/strong_stab.wav"
  66. }
  67.  
  68. new const axe_sounds[][] =
  69. {
  70.     "zmwpn/zb_knife/axe_deploy.wav",
  71.     "zmwpn/zb_knife/axe_hit.wav",
  72.     "zmwpn/zb_knife/axe_hit.wav",
  73.     "zmwpn/zb_knife/axe_hit.wav",
  74.     "zmwpn/zb_knife/axe_hit.wav",
  75.     "zmwpn/zb_knife/axe_hitwall.wav",
  76.     "zmwpn/zb_knife/axe_slash.wav",
  77.     "zmwpn/zb_knife/axe_slash.wav",
  78.     "zmwpn/zb_knife/axe_stab.wav"
  79. }
  80.  
  81. new const katana_sounds[][] =
  82. {
  83.     "zmwpn/zb_knife/katana_deploy.wav",
  84.     "zmwpn/zb_knife/katana_hit.wav",
  85.     "zmwpn/zb_knife/katana_hit.wav",
  86.     "zmwpn/zb_knife/katana_hit.wav",
  87.     "zmwpn/zb_knife/katana_hit.wav",
  88.     "zmwpn/zb_knife/katana_hitwall.wav",
  89.     "zmwpn/zb_knife/katana_slash.wav",
  90.     "zmwpn/zb_knife/katana_slash.wav",
  91.     "zmwpn/zb_knife/katana_stab.wav"
  92. }
  93.  
  94. new const hammer_sounds[][] =
  95. {
  96.     "zmwpn/zb_knife/hammer_deploy.wav",
  97.     "zmwpn/zb_knife/hammer_hit.wav",
  98.     "zmwpn/zb_knife/hammer_hit.wav",
  99.     "zmwpn/zb_knife/hammer_hit.wav",
  100.     "zmwpn/zb_knife/hammer_hit.wav",
  101.     "zmwpn/zb_knife/hammer_hitwall.wav",
  102.     "zmwpn/zb_knife/hammer_slash.wav",
  103.     "zmwpn/zb_knife/hammer_slash.wav",
  104.     "zmwpn/zb_knife/hammer_stab.wav"
  105. }
  106.  
  107. new const oldknife_sounds[][] =
  108. {
  109.     "weapons/knife_deploy1.wav",
  110.     "weapons/knife_hit1.wav",
  111.     "weapons/knife_hit2.wav",
  112.     "weapons/knife_hit3.wav",
  113.     "weapons/knife_hit4.wav",
  114.     "weapons/knife_hitwall1.wav",
  115.     "weapons/knife_slash1.wav",
  116.     "weapons/knife_slash2.wav",
  117.     "weapons/knife_stab.wav"
  118. }
  119. new g_freezetime
  120. public plugin_init()
  121. {
  122.     register_plugin(PLUGIN , VERSION , AUTHOR);
  123.     register_cvar("ze_addon_knife", VERSION, FCVAR_SERVER);
  124.     SayText = get_user_msgid("SayText")  
  125.  
  126.     register_clcmd("say /knife","knife_menu",ADMIN_ALL,"knife_menu")
  127.     register_clcmd("/knife","knife_menu",ADMIN_ALL,"knife_menu")
  128.     register_clcmd("combat", "give_combat")
  129.     register_clcmd("strong", "give_strong")
  130.     register_clcmd("axe", "give_axe")
  131.     register_clcmd("katana", "give_katana")
  132.     register_clcmd("hammer", "give_hammer")
  133.  
  134.     register_event("CurWeapon","checkWeapon","be","1=1");
  135.     register_event("Damage" , "event_Damage" , "b" , "2>0");
  136.  
  137.     register_forward(FM_PlayerPreThink, "fw_PlayerPreThink");
  138.     register_forward(FM_EmitSound, "fw_EmitSound");
  139.  
  140.     register_message(get_user_msgid("DeathMsg"), "message_DeathMsg");
  141.  
  142.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
  143.     RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "fw_Knife_SecondaryAttack_Post", 1)
  144.  
  145.     cvar_knife_combat_jump= register_cvar("ze_knife_combat_jump", "270.0");
  146.     cvar_knife_combat_spd = register_cvar("ze_knife_combat_spd", "310.0");
  147.     cvar_knife_combat_dmg = register_cvar("ze_knife_combat_dmg" , "4.0");
  148.     cvar_knife_combat_knock = register_cvar("ze_knife_combat_knock" , "6.0");
  149.     cvar_knife_combat_spd_attack2 = register_cvar("ze_knife_combat_spd_attack2" , "1.2");
  150.  
  151.     cvar_knife_strong_jump= register_cvar("ze_knife_strong_jump", "265.0");
  152.     cvar_knife_strong_spd = register_cvar("ze_knife_strong_spd", "255.0");
  153.     cvar_knife_strong_dmg = register_cvar("ze_knife_strong_dmg" , "12.0");
  154.     cvar_knife_strong_knock = register_cvar("ze_knife_strong_knock" , "7.0");
  155.     cvar_knife_strong_spd_attack2 = register_cvar("ze_knife_strong_spd_attack2" , "1.6");
  156.  
  157.     cvar_knife_axe_jump= register_cvar("ze_knife_axe_jump", "335.0");
  158.     cvar_knife_axe_spd = register_cvar("ze_knife_axe_spd", "250.0");
  159.     cvar_knife_axe_dmg = register_cvar("ze_knife_axe_dmg" , "5.0");
  160.     cvar_knife_axe_knock = register_cvar("ze_knife_axe_knock" , "6.0");
  161.     cvar_knife_axe_spd_attack2 = register_cvar("ze_knife_axe_spd_attack2" , "1.4");
  162.  
  163.     cvar_knife_katana_jump= register_cvar("ze_knife_katana_jump", "275.0");
  164.     cvar_knife_katana_spd = register_cvar("ze_knife_katana_spd", "265.0");
  165.     cvar_knife_katana_dmg = register_cvar("ze_knife_katana_dmg" , "5.0");
  166.     cvar_knife_katana_knock = register_cvar("ze_knife_katana_knock" , "15.0");
  167.     cvar_knife_katana_spd_attack2 = register_cvar("ze_knife_katana_spd_attack2" , "1.2");
  168.  
  169.     cvar_knife_hammer_jump= register_cvar("ze_knife_hammer_jump", "335.0");
  170.     cvar_knife_hammer_spd= register_cvar("ze_knife_hammer_spd", "315.0");
  171.     cvar_knife_hammer_dmg = register_cvar("ze_knife_hammer_dmg" , "15.0");
  172.     cvar_knife_hammer_knock = register_cvar("ze_knife_hammer_knock" , "15.0");
  173.     cvar_hammer_spd_attack2 = register_cvar("ze_knife_hammer_spd_attack2" , "1.8");
  174.  
  175.         register_event("HLTV", "event_newround", "a", "1=0", "2=0")
  176.     register_logevent("roundstart",2,"1=Round_Start")
  177. }
  178.  
  179. public client_connect(id)
  180. {
  181.     g_knife_combat[id] = false
  182.     g_knife_strong[id] = false
  183.     g_knife_axe[id] = false
  184.     g_knife_katana[id] = false
  185.     g_knife_hammer[id] = false
  186.     g_hasSpeed[id] = false
  187. }
  188.  
  189. public client_disconnected(id)
  190. {
  191.     g_knife_combat[id] = false
  192.     g_knife_strong[id] = false
  193.     g_knife_axe[id] = false
  194.     g_knife_katana[id] = false
  195.     g_knife_hammer[id] = false
  196.     g_hasSpeed[id] = false
  197. }
  198.  
  199. public plugin_precache()
  200. {
  201.     precache_model(combat_v_model)
  202.     precache_model(combat_p_model)
  203.     precache_model(strong_v_model)
  204.     precache_model(strong_p_model)
  205.     precache_model(axe_v_model)
  206.     precache_model(axe_p_model)
  207.     precache_model(katana_v_model)
  208.     precache_model(katana_p_model)
  209.     precache_model(hammer_v_model)
  210.     precache_model(hammer_p_model)
  211.  
  212.     precache_sound(g_sound_knife)
  213.  
  214.     for(new i = 0; i < sizeof combat_sounds; i++)
  215.         precache_sound(combat_sounds[i])
  216.  
  217.     for(new i = 0; i < sizeof strong_sounds; i++)
  218.         precache_sound(strong_sounds[i])
  219.  
  220.     for(new i = 0; i < sizeof axe_sounds; i++)
  221.         precache_sound(axe_sounds[i])  
  222.  
  223.     for(new i = 0; i < sizeof katana_sounds; i++)
  224.         precache_sound(katana_sounds[i])
  225.  
  226.     for(new i = 0; i < sizeof hammer_sounds; i++)
  227.         precache_sound(hammer_sounds[i])
  228. }
  229. public event_newround(id)
  230. {
  231.     g_freezetime = true
  232.    
  233.         for (new i; i < MAXPLAYERS + 1; i++)
  234.             g_WasShowed[i] = false
  235. }
  236. public roundstart(id)
  237. {
  238.     g_freezetime = false
  239. }
  240. public knife_menu(id)
  241. {
  242.         if (g_WasShowed[id])
  243.         {
  244.         print_col_chat(id, "^1[^4ZE^1] Knife menu mozete da koristite samo jednom u rundi!")
  245.         return PLUGIN_HANDLED
  246.     }
  247.     else if(is_user_alive(id) && !ze_is_user_zombie(id))
  248.     {
  249.         my_menu(id)
  250.     }
  251.     return PLUGIN_HANDLED
  252. }
  253. public my_menu(id)
  254. {
  255.     new menu = menu_create("\yChose your knife!", "menu_handler");
  256.     menu_additem(menu, "\wCombat \y[ Speed ]", "1", 0);
  257.     menu_additem(menu, "\wStrong \y[ Damage ]", "2", 0);
  258.     menu_additem(menu, "\wAxe \y[ Jump ]", "3", 0);
  259.     menu_additem(menu, "\wKatana \y[ Knockback ]", "4", 0);
  260.     menu_additem(menu, "\wHammer \r[ VIP | Boost ]", "5", 0);
  261.    
  262.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
  263.    
  264.     menu_display(id, menu, 0);    
  265. }
  266. public menu_handler(id, menu, item)
  267. {
  268.     if( item == MENU_EXIT )
  269.     {
  270.             menu_destroy(menu);
  271.             return PLUGIN_HANDLED;    
  272.     }
  273.    
  274.     new data[6], iName[64];
  275.     new access, callback;
  276.    
  277.     menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
  278.    
  279.     new key = str_to_num(data);
  280.    
  281.     switch(key)
  282.     {
  283.         case 1:
  284.         {
  285.             give_combat(id)
  286.             menu_destroy(menu);
  287.             return PLUGIN_HANDLED
  288.         }
  289.         case 2:
  290.         {
  291.             give_strong(id)
  292.             menu_destroy(menu);
  293.             return PLUGIN_HANDLED
  294.         }
  295.         case 3:
  296.         {
  297.             give_axe(id)
  298.             menu_destroy(menu);
  299.             return PLUGIN_HANDLED
  300.         }
  301.         case 4:
  302.         {
  303.             give_katana(id)
  304.             menu_destroy(menu);
  305.             return PLUGIN_HANDLED
  306.         }
  307.         case 5:
  308.         {
  309.             give_hammer(id)
  310.             menu_destroy(menu);
  311.             return PLUGIN_HANDLED
  312.         }
  313.     }
  314.     menu_destroy(menu);
  315.     return PLUGIN_HANDLED
  316. }
  317. public give_combat(id)
  318. {
  319.     g_knife_combat[id] = true  
  320.     g_knife_strong[id] = false
  321.     g_knife_axe[id] = false
  322.     g_knife_katana[id] = false 
  323.     g_knife_hammer[id] = false
  324.     g_hasSpeed[id] =  true
  325.     g_WasShowed[id] = true
  326.  
  327.     engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
  328. }
  329. public give_strong(id)
  330. {
  331.     g_knife_combat[id] = false 
  332.     g_knife_strong[id] = true  
  333.     g_knife_axe[id] = false
  334.     g_knife_katana[id] = false 
  335.     g_knife_hammer[id] = false
  336.     g_hasSpeed[id] = true
  337.     g_WasShowed[id] = true
  338.  
  339.     engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
  340. }
  341. public give_axe(id)
  342. {
  343.     g_knife_combat[id] = false 
  344.     g_knife_strong[id] = false 
  345.     g_knife_axe[id] = true
  346.     g_knife_katana[id] = false 
  347.     g_knife_hammer[id] = false
  348.     g_hasSpeed[id] = true
  349.     g_WasShowed[id] = true
  350.  
  351.     engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
  352. }
  353. public give_katana(id)
  354. {
  355.     g_knife_combat[id] = false 
  356.     g_knife_strong[id] = false 
  357.     g_knife_axe[id] = false
  358.     g_knife_katana[id] = true  
  359.     g_knife_hammer[id] = false
  360.     g_hasSpeed[id] = true
  361.     g_WasShowed[id] = true
  362.  
  363.     engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
  364. }
  365. public give_hammer(id)
  366. {
  367.     if (get_user_flags(id) & VIP)
  368.     {
  369.         g_knife_combat[id] = false 
  370.         g_knife_strong[id] = false 
  371.         g_knife_axe[id] = false
  372.         g_knife_katana[id] = false
  373.         g_knife_hammer[id] = true
  374.         g_hasSpeed[id] =  true
  375.         g_WasShowed[id] = true
  376.  
  377.         engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
  378.     }
  379.     else
  380.     {
  381.         client_cmd(id, "/knife")
  382.         g_WasShowed[id] = true
  383.     }
  384. }
  385. public checkWeapon(id)
  386. {
  387.     new plrWeapId
  388.    
  389.     plrWeapId = get_user_weapon(id)
  390.    
  391.     if (plrWeapId == CSW_KNIFE && (g_knife_combat[id] || g_knife_strong[id] || g_knife_axe[id] || g_knife_katana[id] || g_knife_hammer[id]))
  392.     {
  393.         checkModel(id)
  394.     }
  395. }
  396. public checkModel(id)
  397. {
  398.     if (!is_user_connected(id) || ze_is_user_zombie(id))
  399.         return PLUGIN_HANDLED
  400.        
  401.     if(g_knife_combat[id])
  402.     {
  403.         set_pev(id, pev_viewmodel2, combat_v_model)
  404.         set_pev(id, pev_weaponmodel2, combat_p_model)
  405.     }
  406.     if(g_knife_strong[id])
  407.     {
  408.         set_pev(id, pev_viewmodel2, strong_v_model)
  409.         set_pev(id, pev_weaponmodel2, strong_p_model)
  410.     }
  411.     if(g_knife_axe[id])
  412.     {
  413.         set_pev(id, pev_viewmodel2, axe_v_model)
  414.         set_pev(id, pev_weaponmodel2, axe_p_model)
  415.     }
  416.     if(g_knife_katana[id])
  417.     {
  418.         set_pev(id, pev_viewmodel2, katana_v_model)
  419.         set_pev(id, pev_weaponmodel2, katana_p_model)
  420.     }
  421.     if(g_knife_hammer[id])
  422.     {
  423.         set_pev(id, pev_viewmodel2, hammer_v_model)
  424.         set_pev(id, pev_weaponmodel2, hammer_p_model)
  425.     }
  426.     return PLUGIN_HANDLED
  427. }
  428. public fw_EmitSound(id, channel, const sound[])
  429. {
  430.     if(!is_user_alive(id) || ze_is_user_zombie(id))
  431.         return FMRES_IGNORED
  432.        
  433.     for(new i = 0; i < sizeof combat_sounds; i++)
  434.     for(new i = 0; i < sizeof strong_sounds; i++)
  435.     for(new i = 0; i < sizeof axe_sounds; i++)
  436.     for(new i = 0; i < sizeof katana_sounds; i++)
  437.     for(new i = 0; i < sizeof hammer_sounds; i++)
  438.     {
  439.         if(equal(sound, oldknife_sounds[i]))
  440.         {
  441.             if (g_knife_combat[id])
  442.             {
  443.                 emit_sound(id, channel, combat_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  444.                 return FMRES_SUPERCEDE
  445.             }
  446.             if (g_knife_strong[id])
  447.             {
  448.                 emit_sound(id, channel, strong_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  449.                 return FMRES_SUPERCEDE
  450.             }
  451.             if (g_knife_axe[id])
  452.             {
  453.                 emit_sound(id, channel, axe_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  454.                 return FMRES_SUPERCEDE
  455.             }
  456.             if (g_knife_katana[id])
  457.             {
  458.                 emit_sound(id, channel, katana_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  459.                 return FMRES_SUPERCEDE
  460.             }
  461.             if (g_knife_hammer[id])
  462.             {
  463.                 emit_sound(id, channel, hammer_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  464.                 return FMRES_SUPERCEDE
  465.             }
  466.             if (!g_knife_combat[id] || !g_knife_strong[id] || !g_knife_axe[id] || !g_knife_katana[id] || !g_knife_hammer[id])
  467.             {
  468.                 emit_sound(id, channel, oldknife_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  469.                 return FMRES_SUPERCEDE
  470.             }
  471.         }
  472.     }
  473.     return FMRES_IGNORED
  474. }
  475. public message_DeathMsg(msg_id, msg_dest, id)
  476. {
  477.     static szTruncatedWeapon[33], iattacker, ivictim
  478.    
  479.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  480.    
  481.     iattacker = get_msg_arg_int(1)
  482.     ivictim = get_msg_arg_int(2)
  483.    
  484.     if(!is_user_connected(iattacker) || iattacker == ivictim)
  485.         return PLUGIN_CONTINUE
  486.  
  487.     if (!ze_is_user_zombie(iattacker))
  488.     {
  489.         if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
  490.         {
  491.             if(g_knife_combat[iattacker])
  492.                 set_msg_arg_string(4, "Combat knife")
  493.         }
  494.    
  495.         if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
  496.         {
  497.             if(g_knife_strong[iattacker])
  498.                 set_msg_arg_string(4, "Strong knife")
  499.         }
  500.  
  501.         if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
  502.         {
  503.             if(g_knife_axe[iattacker])
  504.                 set_msg_arg_string(4, "Axe knife")
  505.         }
  506.  
  507.         if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
  508.         {
  509.             if(g_knife_katana[iattacker])
  510.                 set_msg_arg_string(4, "Katana knife")
  511.         }
  512.  
  513.         if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
  514.         {
  515.             if(g_knife_hammer[iattacker])
  516.                 set_msg_arg_string(4, "Ice knife")
  517.         }
  518.     }
  519.     return PLUGIN_CONTINUE
  520. }
  521.  
  522. stock print_col_chat(const id, const input[], any:...)  
  523. {  
  524.     new count = 1, players[32];  
  525.         static msg[191];  
  526.         vformat(msg, 190, input, 3);  
  527.         replace_all(msg, 190, "!g", "^4"); // Green Color  
  528.         replace_all(msg, 190, "!y", "^1"); // Default Color
  529.         replace_all(msg, 190, "!t", "^3"); // Team Color  
  530.         if (id) players[0] = id; else get_players(players, count, "ch");  
  531.         {  
  532.             for ( new i = 0; i < count; i++ )  
  533.             {  
  534.                     if ( is_user_connected(players[i]) )  
  535.                     {  
  536.                         message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i]);  
  537.                         write_byte(players[i]);  
  538.                         write_string(msg);  
  539.                         message_end();  
  540.                     }  
  541.             }  
  542.         }  
  543. }  
  544.  
  545. public fw_PlayerPreThink(id)
  546. {
  547.     if(!is_user_alive(id) || ze_is_user_zombie(id))
  548.         return FMRES_IGNORED
  549.  
  550.     new temp[2], weapon = get_user_weapon(id, temp[0], temp[1])
  551.  
  552.     if (weapon == CSW_KNIFE && g_knife_combat[id] && !g_freezetime)
  553.     {
  554.         g_hasSpeed[id] = true
  555.         set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_combat_spd))
  556.     }
  557.  
  558.     if(weapon == CSW_KNIFE && g_knife_combat[id])        
  559.         if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
  560.         {
  561.             new flags = pev(id, pev_flags)
  562.             new waterlvl = pev(id, pev_waterlevel)
  563.            
  564.             if (!(flags & FL_ONGROUND))
  565.                 return FMRES_IGNORED
  566.  
  567.             if (flags & FL_WATERJUMP)
  568.                 return FMRES_IGNORED
  569.  
  570.             if (waterlvl > 1)
  571.                 return FMRES_IGNORED
  572.            
  573.             new Float:fVelocity[3]
  574.             pev(id, pev_velocity, fVelocity)
  575.            
  576.             fVelocity[2] += get_pcvar_num(cvar_knife_combat_jump)
  577.            
  578.             set_pev(id, pev_velocity, fVelocity)
  579.             set_pev(id, pev_gaitsequence, 6)
  580.         }
  581.     if (weapon == CSW_KNIFE && g_knife_strong[id])
  582.     {
  583.         g_hasSpeed[id] = true
  584.         set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_strong_spd))
  585.  
  586.         if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
  587.         {
  588.             new flags = pev(id, pev_flags)
  589.             new waterlvl = pev(id, pev_waterlevel)
  590.            
  591.             if (!(flags & FL_ONGROUND))
  592.                 return FMRES_IGNORED
  593.  
  594.             if (flags & FL_WATERJUMP)
  595.                 return FMRES_IGNORED
  596.  
  597.             if (waterlvl > 1)
  598.                 return FMRES_IGNORED
  599.            
  600.             new Float:fVelocity[3]
  601.             pev(id, pev_velocity, fVelocity)
  602.            
  603.             fVelocity[2] += get_pcvar_num(cvar_knife_strong_jump)
  604.            
  605.             set_pev(id, pev_velocity, fVelocity)
  606.             set_pev(id, pev_gaitsequence, 6)
  607.         }
  608.     }
  609.     if (weapon == CSW_KNIFE && g_knife_axe[id])
  610.     {
  611.         g_hasSpeed[id] = true
  612.         set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_axe_spd))
  613.  
  614.         if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
  615.         {
  616.             new flags = pev(id, pev_flags)
  617.             new waterlvl = pev(id, pev_waterlevel)
  618.            
  619.             if (!(flags & FL_ONGROUND))
  620.                 return FMRES_IGNORED
  621.  
  622.             if (flags & FL_WATERJUMP)
  623.                 return FMRES_IGNORED
  624.  
  625.             if (waterlvl > 1)
  626.                 return FMRES_IGNORED
  627.            
  628.             new Float:fVelocity[3]
  629.             pev(id, pev_velocity, fVelocity)
  630.            
  631.             fVelocity[2] += get_pcvar_num(cvar_knife_axe_jump)
  632.            
  633.             set_pev(id, pev_velocity, fVelocity)
  634.             set_pev(id, pev_gaitsequence, 6)
  635.         }
  636.     }
  637.     if (weapon == CSW_KNIFE && g_knife_katana[id])
  638.     {
  639.         g_hasSpeed[id] = true
  640.         set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_katana_spd))
  641.  
  642.         if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
  643.         {
  644.             new flags = pev(id, pev_flags)
  645.             new waterlvl = pev(id, pev_waterlevel)
  646.            
  647.             if (!(flags & FL_ONGROUND))
  648.                 return FMRES_IGNORED
  649.  
  650.             if (flags & FL_WATERJUMP)
  651.                 return FMRES_IGNORED
  652.  
  653.             if (waterlvl > 1)
  654.                 return FMRES_IGNORED
  655.            
  656.             new Float:fVelocity[3]
  657.             pev(id, pev_velocity, fVelocity)
  658.            
  659.             fVelocity[2] += get_pcvar_num(cvar_knife_katana_jump)
  660.            
  661.             set_pev(id, pev_velocity, fVelocity)
  662.             set_pev(id, pev_gaitsequence, 6)
  663.         }
  664.     }
  665.     if (weapon == CSW_KNIFE && g_knife_hammer[id])
  666.     {
  667.         g_hasSpeed[id] = true
  668.         set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_hammer_spd))
  669.  
  670.         if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
  671.         {
  672.             new flags = pev(id, pev_flags)
  673.             new waterlvl = pev(id, pev_waterlevel)
  674.            
  675.             if (!(flags & FL_ONGROUND))
  676.                 return FMRES_IGNORED
  677.  
  678.             if (flags & FL_WATERJUMP)
  679.                 return FMRES_IGNORED
  680.  
  681.             if (waterlvl > 1)
  682.                 return FMRES_IGNORED
  683.            
  684.             new Float:fVelocity[3]
  685.             pev(id, pev_velocity, fVelocity)
  686.            
  687.             fVelocity[2] += get_pcvar_num(cvar_knife_hammer_jump)
  688.            
  689.             set_pev(id, pev_velocity, fVelocity)
  690.             set_pev(id, pev_gaitsequence, 6)
  691.         }
  692.     }
  693.     return FMRES_IGNORED
  694. }  
  695.  
  696. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  697. {
  698.     if(!is_user_connected(attacker))
  699.         return HAM_IGNORED
  700.    
  701.     if(ze_is_user_zombie(attacker))
  702.         return HAM_IGNORED
  703.  
  704.     new weapon = get_user_weapon(attacker)
  705.  
  706.     if (weapon == CSW_KNIFE && g_knife_combat[attacker])
  707.     {  
  708.         SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_combat_dmg))
  709.     }
  710.     if (weapon == CSW_KNIFE && g_knife_strong[attacker])
  711.     {  
  712.         SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_strong_dmg))
  713.     }
  714.     if (weapon == CSW_KNIFE && g_knife_axe[attacker])
  715.     {  
  716.         SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_axe_dmg))
  717.     }
  718.     if (weapon == CSW_KNIFE && g_knife_katana[attacker])
  719.     {  
  720.         SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_katana_dmg))
  721.     }
  722.        
  723.     if (weapon == CSW_KNIFE && g_knife_hammer[attacker])
  724.     {    
  725.         SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_hammer_dmg))
  726.     }
  727.  
  728.     return HAM_IGNORED
  729. }
  730.  
  731. public fw_Knife_SecondaryAttack_Post(knife)
  732. {    
  733.         static id
  734.         id = get_pdata_cbase(knife, m_pPlayer, 4)
  735.  
  736.         if(ze_is_user_zombie(id))
  737.         return HAM_IGNORED
  738.    
  739.         if(is_user_connected(id) && g_knife_combat[id])
  740.         {
  741.             static Float:flRate
  742.             flRate = get_pcvar_float(cvar_knife_combat_spd_attack2)
  743.          
  744.             set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
  745.             set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
  746.             set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
  747.         }
  748.  
  749.         if(is_user_connected(id) && g_knife_strong[id])
  750.         {
  751.             static Float:flRate
  752.             flRate = get_pcvar_float(cvar_knife_strong_spd_attack2)
  753.              
  754.             set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
  755.             set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
  756.             set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
  757.         }
  758.  
  759.         if(is_user_connected(id) && g_knife_axe[id])
  760.         {
  761.             static Float:flRate
  762.             flRate = get_pcvar_float(cvar_knife_axe_spd_attack2)
  763.                  
  764.             set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
  765.             set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
  766.             set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
  767.         }
  768.  
  769.         if(is_user_connected(id) && g_knife_katana[id])
  770.         {
  771.             static Float:flRate
  772.             flRate = get_pcvar_float(cvar_knife_katana_spd_attack2)
  773.                  
  774.             set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
  775.             set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
  776.             set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
  777.         }
  778.  
  779.         if(is_user_connected(id) && g_knife_hammer[id])
  780.         {
  781.             static Float:flRate
  782.             flRate = get_pcvar_float(cvar_hammer_spd_attack2)
  783.              
  784.             set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
  785.             set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
  786.             set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
  787.         }  
  788.    
  789.         return HAM_IGNORED
  790. }
  791.  
  792. public event_Damage(id)
  793. {
  794.     new weapon , attacker = get_user_attacker(id , weapon);
  795.  
  796.     if(!is_user_alive(attacker))
  797.         return PLUGIN_CONTINUE;
  798.  
  799.     if(weapon == CSW_KNIFE && g_knife_combat[attacker])
  800.     {
  801.         new Float:vec[3];
  802.         new Float:oldvelo[3];
  803.         get_user_velocity(id, oldvelo);
  804.         create_velocity_vector(id , attacker , vec);
  805.         vec[0] += oldvelo[0];
  806.         vec[1] += oldvelo[1];
  807.         set_user_velocity(id , vec);
  808.     }
  809.  
  810.     if(weapon == CSW_KNIFE && g_knife_strong[attacker])
  811.     {
  812.         new Float:vec[3];
  813.         new Float:oldvelo[3];
  814.         get_user_velocity(id, oldvelo);
  815.         create_velocity_vector(id , attacker , vec);
  816.         vec[0] += oldvelo[0];
  817.         vec[1] += oldvelo[1];
  818.         set_user_velocity(id , vec);
  819.     }
  820.  
  821.     if(weapon == CSW_KNIFE && g_knife_axe[attacker])
  822.     {
  823.         new Float:vec[3];
  824.         new Float:oldvelo[3];
  825.         get_user_velocity(id, oldvelo);
  826.         create_velocity_vector(id , attacker , vec);
  827.         vec[0] += oldvelo[0];
  828.         vec[1] += oldvelo[1];
  829.         set_user_velocity(id , vec);
  830.     }
  831.  
  832.     if(weapon == CSW_KNIFE && g_knife_katana[attacker])
  833.     {
  834.         new Float:vec[3];
  835.         new Float:oldvelo[3];
  836.         get_user_velocity(id, oldvelo);
  837.         create_velocity_vector(id , attacker , vec);
  838.         vec[0] += oldvelo[0];
  839.         vec[1] += oldvelo[1];
  840.         set_user_velocity(id , vec);
  841.     }
  842.  
  843.     if(weapon == CSW_KNIFE && g_knife_hammer[attacker])
  844.     {
  845.         new Float:vec[3];
  846.         new Float:oldvelo[3];
  847.         get_user_velocity(id, oldvelo);
  848.         create_velocity_vector(id , attacker , vec);
  849.         vec[0] += oldvelo[0];
  850.         vec[1] += oldvelo[1];
  851.         set_user_velocity(id , vec);
  852.     }
  853.  
  854.     return PLUGIN_CONTINUE;
  855. }
  856.  
  857. stock create_velocity_vector(victim,attacker,Float:velocity[3])
  858. {
  859.     if(!ze_is_user_zombie(victim) || !is_user_alive(attacker))
  860.         return 0;
  861.  
  862.     new Float:vicorigin[3];
  863.     new Float:attorigin[3];
  864.     entity_get_vector(victim   , EV_VEC_origin , vicorigin);
  865.     entity_get_vector(attacker , EV_VEC_origin , attorigin);
  866.  
  867.     new Float:origin2[3]
  868.     origin2[0] = vicorigin[0] - attorigin[0];
  869.     origin2[1] = vicorigin[1] - attorigin[1];
  870.  
  871.     new Float:largestnum = 0.0;
  872.  
  873.     if(floatabs(origin2[0])>largestnum) largestnum = floatabs(origin2[0]);
  874.     if(floatabs(origin2[1])>largestnum) largestnum = floatabs(origin2[1]);
  875.  
  876.     origin2[0] /= largestnum;
  877.     origin2[1] /= largestnum;
  878.  
  879.     if (g_knife_combat[attacker])
  880.     {
  881.         velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_combat_knock) * 3000) ) / get_entity_distance(victim , attacker);
  882.         velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_combat_knock) * 3000) ) / get_entity_distance(victim , attacker);
  883.     }
  884.  
  885.     if (g_knife_strong[attacker])
  886.     {
  887.         velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_strong_knock) * 3000) ) / get_entity_distance(victim , attacker);
  888.         velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_strong_knock) * 3000) ) / get_entity_distance(victim , attacker);
  889.     }
  890.  
  891.     if (g_knife_axe[attacker])
  892.     {
  893.         velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_axe_knock) * 3000) ) / get_entity_distance(victim , attacker);
  894.         velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_axe_knock) * 3000) ) / get_entity_distance(victim , attacker);
  895.     }
  896.  
  897.     if (g_knife_katana[attacker])
  898.     {
  899.         velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_katana_knock) * 3000) ) / get_entity_distance(victim , attacker);
  900.         velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_katana_knock) * 3000) ) / get_entity_distance(victim , attacker);
  901.     }
  902.  
  903.     if (g_knife_hammer[attacker])
  904.     {
  905.         velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_hammer_knock) * 3000) ) / get_entity_distance(victim , attacker);
  906.         velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_hammer_knock) * 3000) ) / get_entity_distance(victim , attacker);
  907.     }
  908.  
  909.     if(velocity[0] <= 20.0 || velocity[1] <= 20.0)
  910.         velocity[2] = random_float(200.0 , 275.0);
  911.  
  912.     return 1;
  913. }
  914.  
  915. public client_putinserver(id)
  916. {
  917.     switch(random_num(0, 0))
  918.     {
  919.         case 0:
  920.         {
  921.             g_knife_combat[id] = true
  922.             g_hasSpeed[id] = true
  923.         }
  924.  
  925.     }
  926. }

The problem was in:
    1.     if (!is_user_connected(id) && ze_is_user_zombie(id))
    2.         return PLUGIN_HANDLED
Should be:
    1.     if (!is_user_connected(id) || ze_is_user_zombie(id))
    2.         return PLUGIN_HANDLED
Now it's working for me, and anyway you will get another issue that with this humans will be able to run during the freeze time. We already have knife menu in the gameplay section you can use it instead as it's fixed version: viewtopic.php?f=15&t=88
He who fails to plan is planning to fail

Muhammet20
Veteran Member
Veteran Member
Posts: 408
Joined: 5 years ago
Contact:

#29

Post by Muhammet20 » 4 years ago

Raheem wrote: 4 years ago Here is the fixed one:

  1. #include <zombie_escape>
  2. #include <engine>
  3. #include <fun>
  4.  
  5. #define PLUGIN    "Choose knifes"
  6. #define VERSION    "1.0"
  7. #define AUTHOR    "CHyC/4e/l"
  8.  
  9. #define VIP ADMIN_LEVEL_H
  10. #define MAXPLAYERS 32
  11.  
  12. new combat_v_model[] = "models/zb/v_combat_knife.mdl"
  13. new combat_p_model[] = "models/zb/p_combat_knife.mdl"
  14.  
  15. new strong_v_model[] = "models/zb/v_strong_knife.mdl"
  16. new strong_p_model[] = "models/zb/p_strong_knife.mdl"
  17.  
  18. new axe_v_model[] = "models/zb/v_axe_knife.mdl"
  19. new axe_p_model[] = "models/zb/p_axe_knife.mdl"
  20.  
  21. new katana_v_model[] = "models/zb/v_katana_knife.mdl"  
  22. new katana_p_model[] = "models/zb/p_katana_knife.mdl"
  23.  
  24. new hammer_v_model[] = "models/zb/v_hammer_knife.mdl"  
  25. new hammer_p_model[] = "models/zb/p_hammer_knife.mdl"  
  26.  
  27. const m_pPlayer = 41
  28. const m_flNextPrimaryAttack = 46
  29. const m_flNextSecondaryAttack = 47
  30. const m_flTimeWeaponIdle = 48
  31.  
  32. new g_hasSpeed[33], SayText
  33. new bool:g_WasShowed[MAXPLAYERS + 1]
  34. new g_knife_combat[33], cvar_knife_combat_jump, cvar_knife_combat_spd, cvar_knife_combat_dmg, cvar_knife_combat_knock, cvar_knife_combat_spd_attack2
  35. new g_knife_strong[33], cvar_knife_strong_jump, cvar_knife_strong_spd, cvar_knife_strong_dmg, cvar_knife_strong_knock, cvar_knife_strong_spd_attack2
  36. new g_knife_axe[33], cvar_knife_axe_jump, cvar_knife_axe_spd, cvar_knife_axe_dmg, cvar_knife_axe_knock, cvar_knife_axe_spd_attack2
  37. new g_knife_katana[33], cvar_knife_katana_jump, cvar_knife_katana_spd, cvar_knife_katana_dmg, cvar_knife_katana_knock, cvar_knife_katana_spd_attack2
  38. new g_knife_hammer[33], cvar_knife_hammer_jump, cvar_knife_hammer_spd, cvar_knife_hammer_dmg, cvar_knife_hammer_knock, cvar_hammer_spd_attack2
  39.  
  40. new const g_sound_knife[] = { "items/gunpickup2.wav" }
  41.  
  42. new const combat_sounds[][] =
  43. {
  44.     "zmwpn/zb_knife/combat_deploy.wav",
  45.     "zmwpn/zb_knife/combat_hit.wav" ,
  46.     "zmwpn/zb_knife/combat_hit.wav" ,
  47.     "zmwpn/zb_knife/combat_hit.wav" ,
  48.     "zmwpn/zb_knife/combat_hit.wav" ,
  49.     "zmwpn/zb_knife/combat_hitwall.wav",
  50.     "zmwpn/zb_knife/combat_slash.wav",
  51.     "zmwpn/zb_knife/combat_slash.wav",
  52.     "zmwpn/zb_knife/combat_stab.wav"
  53. }
  54.  
  55. new const strong_sounds[][] =
  56. {
  57.     "zmwpn/zb_knife/strong_deploy.wav",
  58.     "zmwpn/zb_knife/strong_hit.wav",
  59.     "zmwpn/zb_knife/strong_hit.wav",
  60.     "zmwpn/zb_knife/strong_hit.wav",
  61.     "zmwpn/zb_knife/strong_hit.wav",
  62.     "zmwpn/zb_knife/strong_hitwall.wav",
  63.     "zmwpn/zb_knife/strong_slash.wav",
  64.     "zmwpn/zb_knife/strong_slash.wav",
  65.     "zmwpn/zb_knife/strong_stab.wav"
  66. }
  67.  
  68. new const axe_sounds[][] =
  69. {
  70.     "zmwpn/zb_knife/axe_deploy.wav",
  71.     "zmwpn/zb_knife/axe_hit.wav",
  72.     "zmwpn/zb_knife/axe_hit.wav",
  73.     "zmwpn/zb_knife/axe_hit.wav",
  74.     "zmwpn/zb_knife/axe_hit.wav",
  75.     "zmwpn/zb_knife/axe_hitwall.wav",
  76.     "zmwpn/zb_knife/axe_slash.wav",
  77.     "zmwpn/zb_knife/axe_slash.wav",
  78.     "zmwpn/zb_knife/axe_stab.wav"
  79. }
  80.  
  81. new const katana_sounds[][] =
  82. {
  83.     "zmwpn/zb_knife/katana_deploy.wav",
  84.     "zmwpn/zb_knife/katana_hit.wav",
  85.     "zmwpn/zb_knife/katana_hit.wav",
  86.     "zmwpn/zb_knife/katana_hit.wav",
  87.     "zmwpn/zb_knife/katana_hit.wav",
  88.     "zmwpn/zb_knife/katana_hitwall.wav",
  89.     "zmwpn/zb_knife/katana_slash.wav",
  90.     "zmwpn/zb_knife/katana_slash.wav",
  91.     "zmwpn/zb_knife/katana_stab.wav"
  92. }
  93.  
  94. new const hammer_sounds[][] =
  95. {
  96.     "zmwpn/zb_knife/hammer_deploy.wav",
  97.     "zmwpn/zb_knife/hammer_hit.wav",
  98.     "zmwpn/zb_knife/hammer_hit.wav",
  99.     "zmwpn/zb_knife/hammer_hit.wav",
  100.     "zmwpn/zb_knife/hammer_hit.wav",
  101.     "zmwpn/zb_knife/hammer_hitwall.wav",
  102.     "zmwpn/zb_knife/hammer_slash.wav",
  103.     "zmwpn/zb_knife/hammer_slash.wav",
  104.     "zmwpn/zb_knife/hammer_stab.wav"
  105. }
  106.  
  107. new const oldknife_sounds[][] =
  108. {
  109.     "weapons/knife_deploy1.wav",
  110.     "weapons/knife_hit1.wav",
  111.     "weapons/knife_hit2.wav",
  112.     "weapons/knife_hit3.wav",
  113.     "weapons/knife_hit4.wav",
  114.     "weapons/knife_hitwall1.wav",
  115.     "weapons/knife_slash1.wav",
  116.     "weapons/knife_slash2.wav",
  117.     "weapons/knife_stab.wav"
  118. }
  119. new g_freezetime
  120. public plugin_init()
  121. {
  122.     register_plugin(PLUGIN , VERSION , AUTHOR);
  123.     register_cvar("ze_addon_knife", VERSION, FCVAR_SERVER);
  124.     SayText = get_user_msgid("SayText")  
  125.  
  126.     register_clcmd("say /knife","knife_menu",ADMIN_ALL,"knife_menu")
  127.     register_clcmd("/knife","knife_menu",ADMIN_ALL,"knife_menu")
  128.     register_clcmd("combat", "give_combat")
  129.     register_clcmd("strong", "give_strong")
  130.     register_clcmd("axe", "give_axe")
  131.     register_clcmd("katana", "give_katana")
  132.     register_clcmd("hammer", "give_hammer")
  133.  
  134.     register_event("CurWeapon","checkWeapon","be","1=1");
  135.     register_event("Damage" , "event_Damage" , "b" , "2>0");
  136.  
  137.     register_forward(FM_PlayerPreThink, "fw_PlayerPreThink");
  138.     register_forward(FM_EmitSound, "fw_EmitSound");
  139.  
  140.     register_message(get_user_msgid("DeathMsg"), "message_DeathMsg");
  141.  
  142.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
  143.     RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "fw_Knife_SecondaryAttack_Post", 1)
  144.  
  145.     cvar_knife_combat_jump= register_cvar("ze_knife_combat_jump", "270.0");
  146.     cvar_knife_combat_spd = register_cvar("ze_knife_combat_spd", "310.0");
  147.     cvar_knife_combat_dmg = register_cvar("ze_knife_combat_dmg" , "4.0");
  148.     cvar_knife_combat_knock = register_cvar("ze_knife_combat_knock" , "6.0");
  149.     cvar_knife_combat_spd_attack2 = register_cvar("ze_knife_combat_spd_attack2" , "1.2");
  150.  
  151.     cvar_knife_strong_jump= register_cvar("ze_knife_strong_jump", "265.0");
  152.     cvar_knife_strong_spd = register_cvar("ze_knife_strong_spd", "255.0");
  153.     cvar_knife_strong_dmg = register_cvar("ze_knife_strong_dmg" , "12.0");
  154.     cvar_knife_strong_knock = register_cvar("ze_knife_strong_knock" , "7.0");
  155.     cvar_knife_strong_spd_attack2 = register_cvar("ze_knife_strong_spd_attack2" , "1.6");
  156.  
  157.     cvar_knife_axe_jump= register_cvar("ze_knife_axe_jump", "335.0");
  158.     cvar_knife_axe_spd = register_cvar("ze_knife_axe_spd", "250.0");
  159.     cvar_knife_axe_dmg = register_cvar("ze_knife_axe_dmg" , "5.0");
  160.     cvar_knife_axe_knock = register_cvar("ze_knife_axe_knock" , "6.0");
  161.     cvar_knife_axe_spd_attack2 = register_cvar("ze_knife_axe_spd_attack2" , "1.4");
  162.  
  163.     cvar_knife_katana_jump= register_cvar("ze_knife_katana_jump", "275.0");
  164.     cvar_knife_katana_spd = register_cvar("ze_knife_katana_spd", "265.0");
  165.     cvar_knife_katana_dmg = register_cvar("ze_knife_katana_dmg" , "5.0");
  166.     cvar_knife_katana_knock = register_cvar("ze_knife_katana_knock" , "15.0");
  167.     cvar_knife_katana_spd_attack2 = register_cvar("ze_knife_katana_spd_attack2" , "1.2");
  168.  
  169.     cvar_knife_hammer_jump= register_cvar("ze_knife_hammer_jump", "335.0");
  170.     cvar_knife_hammer_spd= register_cvar("ze_knife_hammer_spd", "315.0");
  171.     cvar_knife_hammer_dmg = register_cvar("ze_knife_hammer_dmg" , "15.0");
  172.     cvar_knife_hammer_knock = register_cvar("ze_knife_hammer_knock" , "15.0");
  173.     cvar_hammer_spd_attack2 = register_cvar("ze_knife_hammer_spd_attack2" , "1.8");
  174.  
  175.         register_event("HLTV", "event_newround", "a", "1=0", "2=0")
  176.     register_logevent("roundstart",2,"1=Round_Start")
  177. }
  178.  
  179. public client_connect(id)
  180. {
  181.     g_knife_combat[id] = false
  182.     g_knife_strong[id] = false
  183.     g_knife_axe[id] = false
  184.     g_knife_katana[id] = false
  185.     g_knife_hammer[id] = false
  186.     g_hasSpeed[id] = false
  187. }
  188.  
  189. public client_disconnected(id)
  190. {
  191.     g_knife_combat[id] = false
  192.     g_knife_strong[id] = false
  193.     g_knife_axe[id] = false
  194.     g_knife_katana[id] = false
  195.     g_knife_hammer[id] = false
  196.     g_hasSpeed[id] = false
  197. }
  198.  
  199. public plugin_precache()
  200. {
  201.     precache_model(combat_v_model)
  202.     precache_model(combat_p_model)
  203.     precache_model(strong_v_model)
  204.     precache_model(strong_p_model)
  205.     precache_model(axe_v_model)
  206.     precache_model(axe_p_model)
  207.     precache_model(katana_v_model)
  208.     precache_model(katana_p_model)
  209.     precache_model(hammer_v_model)
  210.     precache_model(hammer_p_model)
  211.  
  212.     precache_sound(g_sound_knife)
  213.  
  214.     for(new i = 0; i < sizeof combat_sounds; i++)
  215.         precache_sound(combat_sounds[i])
  216.  
  217.     for(new i = 0; i < sizeof strong_sounds; i++)
  218.         precache_sound(strong_sounds[i])
  219.  
  220.     for(new i = 0; i < sizeof axe_sounds; i++)
  221.         precache_sound(axe_sounds[i])  
  222.  
  223.     for(new i = 0; i < sizeof katana_sounds; i++)
  224.         precache_sound(katana_sounds[i])
  225.  
  226.     for(new i = 0; i < sizeof hammer_sounds; i++)
  227.         precache_sound(hammer_sounds[i])
  228. }
  229. public event_newround(id)
  230. {
  231.     g_freezetime = true
  232.    
  233.         for (new i; i < MAXPLAYERS + 1; i++)
  234.             g_WasShowed[i] = false
  235. }
  236. public roundstart(id)
  237. {
  238.     g_freezetime = false
  239. }
  240. public knife_menu(id)
  241. {
  242.         if (g_WasShowed[id])
  243.         {
  244.         print_col_chat(id, "^1[^4ZE^1] Knife menu mozete da koristite samo jednom u rundi!")
  245.         return PLUGIN_HANDLED
  246.     }
  247.     else if(is_user_alive(id) && !ze_is_user_zombie(id))
  248.     {
  249.         my_menu(id)
  250.     }
  251.     return PLUGIN_HANDLED
  252. }
  253. public my_menu(id)
  254. {
  255.     new menu = menu_create("\yChose your knife!", "menu_handler");
  256.     menu_additem(menu, "\wCombat \y[ Speed ]", "1", 0);
  257.     menu_additem(menu, "\wStrong \y[ Damage ]", "2", 0);
  258.     menu_additem(menu, "\wAxe \y[ Jump ]", "3", 0);
  259.     menu_additem(menu, "\wKatana \y[ Knockback ]", "4", 0);
  260.     menu_additem(menu, "\wHammer \r[ VIP | Boost ]", "5", 0);
  261.    
  262.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
  263.    
  264.     menu_display(id, menu, 0);    
  265. }
  266. public menu_handler(id, menu, item)
  267. {
  268.     if( item == MENU_EXIT )
  269.     {
  270.             menu_destroy(menu);
  271.             return PLUGIN_HANDLED;    
  272.     }
  273.    
  274.     new data[6], iName[64];
  275.     new access, callback;
  276.    
  277.     menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
  278.    
  279.     new key = str_to_num(data);
  280.    
  281.     switch(key)
  282.     {
  283.         case 1:
  284.         {
  285.             give_combat(id)
  286.             menu_destroy(menu);
  287.             return PLUGIN_HANDLED
  288.         }
  289.         case 2:
  290.         {
  291.             give_strong(id)
  292.             menu_destroy(menu);
  293.             return PLUGIN_HANDLED
  294.         }
  295.         case 3:
  296.         {
  297.             give_axe(id)
  298.             menu_destroy(menu);
  299.             return PLUGIN_HANDLED
  300.         }
  301.         case 4:
  302.         {
  303.             give_katana(id)
  304.             menu_destroy(menu);
  305.             return PLUGIN_HANDLED
  306.         }
  307.         case 5:
  308.         {
  309.             give_hammer(id)
  310.             menu_destroy(menu);
  311.             return PLUGIN_HANDLED
  312.         }
  313.     }
  314.     menu_destroy(menu);
  315.     return PLUGIN_HANDLED
  316. }
  317. public give_combat(id)
  318. {
  319.     g_knife_combat[id] = true  
  320.     g_knife_strong[id] = false
  321.     g_knife_axe[id] = false
  322.     g_knife_katana[id] = false 
  323.     g_knife_hammer[id] = false
  324.     g_hasSpeed[id] =  true
  325.     g_WasShowed[id] = true
  326.  
  327.     engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
  328. }
  329. public give_strong(id)
  330. {
  331.     g_knife_combat[id] = false 
  332.     g_knife_strong[id] = true  
  333.     g_knife_axe[id] = false
  334.     g_knife_katana[id] = false 
  335.     g_knife_hammer[id] = false
  336.     g_hasSpeed[id] = true
  337.     g_WasShowed[id] = true
  338.  
  339.     engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
  340. }
  341. public give_axe(id)
  342. {
  343.     g_knife_combat[id] = false 
  344.     g_knife_strong[id] = false 
  345.     g_knife_axe[id] = true
  346.     g_knife_katana[id] = false 
  347.     g_knife_hammer[id] = false
  348.     g_hasSpeed[id] = true
  349.     g_WasShowed[id] = true
  350.  
  351.     engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
  352. }
  353. public give_katana(id)
  354. {
  355.     g_knife_combat[id] = false 
  356.     g_knife_strong[id] = false 
  357.     g_knife_axe[id] = false
  358.     g_knife_katana[id] = true  
  359.     g_knife_hammer[id] = false
  360.     g_hasSpeed[id] = true
  361.     g_WasShowed[id] = true
  362.  
  363.     engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
  364. }
  365. public give_hammer(id)
  366. {
  367.     if (get_user_flags(id) & VIP)
  368.     {
  369.         g_knife_combat[id] = false 
  370.         g_knife_strong[id] = false 
  371.         g_knife_axe[id] = false
  372.         g_knife_katana[id] = false
  373.         g_knife_hammer[id] = true
  374.         g_hasSpeed[id] =  true
  375.         g_WasShowed[id] = true
  376.  
  377.         engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
  378.     }
  379.     else
  380.     {
  381.         client_cmd(id, "/knife")
  382.         g_WasShowed[id] = true
  383.     }
  384. }
  385. public checkWeapon(id)
  386. {
  387.     new plrWeapId
  388.    
  389.     plrWeapId = get_user_weapon(id)
  390.    
  391.     if (plrWeapId == CSW_KNIFE && (g_knife_combat[id] || g_knife_strong[id] || g_knife_axe[id] || g_knife_katana[id] || g_knife_hammer[id]))
  392.     {
  393.         checkModel(id)
  394.     }
  395. }
  396. public checkModel(id)
  397. {
  398.     if (!is_user_connected(id) || ze_is_user_zombie(id))
  399.         return PLUGIN_HANDLED
  400.        
  401.     if(g_knife_combat[id])
  402.     {
  403.         set_pev(id, pev_viewmodel2, combat_v_model)
  404.         set_pev(id, pev_weaponmodel2, combat_p_model)
  405.     }
  406.     if(g_knife_strong[id])
  407.     {
  408.         set_pev(id, pev_viewmodel2, strong_v_model)
  409.         set_pev(id, pev_weaponmodel2, strong_p_model)
  410.     }
  411.     if(g_knife_axe[id])
  412.     {
  413.         set_pev(id, pev_viewmodel2, axe_v_model)
  414.         set_pev(id, pev_weaponmodel2, axe_p_model)
  415.     }
  416.     if(g_knife_katana[id])
  417.     {
  418.         set_pev(id, pev_viewmodel2, katana_v_model)
  419.         set_pev(id, pev_weaponmodel2, katana_p_model)
  420.     }
  421.     if(g_knife_hammer[id])
  422.     {
  423.         set_pev(id, pev_viewmodel2, hammer_v_model)
  424.         set_pev(id, pev_weaponmodel2, hammer_p_model)
  425.     }
  426.     return PLUGIN_HANDLED
  427. }
  428. public fw_EmitSound(id, channel, const sound[])
  429. {
  430.     if(!is_user_alive(id) || ze_is_user_zombie(id))
  431.         return FMRES_IGNORED
  432.        
  433.     for(new i = 0; i < sizeof combat_sounds; i++)
  434.     for(new i = 0; i < sizeof strong_sounds; i++)
  435.     for(new i = 0; i < sizeof axe_sounds; i++)
  436.     for(new i = 0; i < sizeof katana_sounds; i++)
  437.     for(new i = 0; i < sizeof hammer_sounds; i++)
  438.     {
  439.         if(equal(sound, oldknife_sounds[i]))
  440.         {
  441.             if (g_knife_combat[id])
  442.             {
  443.                 emit_sound(id, channel, combat_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  444.                 return FMRES_SUPERCEDE
  445.             }
  446.             if (g_knife_strong[id])
  447.             {
  448.                 emit_sound(id, channel, strong_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  449.                 return FMRES_SUPERCEDE
  450.             }
  451.             if (g_knife_axe[id])
  452.             {
  453.                 emit_sound(id, channel, axe_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  454.                 return FMRES_SUPERCEDE
  455.             }
  456.             if (g_knife_katana[id])
  457.             {
  458.                 emit_sound(id, channel, katana_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  459.                 return FMRES_SUPERCEDE
  460.             }
  461.             if (g_knife_hammer[id])
  462.             {
  463.                 emit_sound(id, channel, hammer_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  464.                 return FMRES_SUPERCEDE
  465.             }
  466.             if (!g_knife_combat[id] || !g_knife_strong[id] || !g_knife_axe[id] || !g_knife_katana[id] || !g_knife_hammer[id])
  467.             {
  468.                 emit_sound(id, channel, oldknife_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
  469.                 return FMRES_SUPERCEDE
  470.             }
  471.         }
  472.     }
  473.     return FMRES_IGNORED
  474. }
  475. public message_DeathMsg(msg_id, msg_dest, id)
  476. {
  477.     static szTruncatedWeapon[33], iattacker, ivictim
  478.    
  479.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  480.    
  481.     iattacker = get_msg_arg_int(1)
  482.     ivictim = get_msg_arg_int(2)
  483.    
  484.     if(!is_user_connected(iattacker) || iattacker == ivictim)
  485.         return PLUGIN_CONTINUE
  486.  
  487.     if (!ze_is_user_zombie(iattacker))
  488.     {
  489.         if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
  490.         {
  491.             if(g_knife_combat[iattacker])
  492.                 set_msg_arg_string(4, "Combat knife")
  493.         }
  494.    
  495.         if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
  496.         {
  497.             if(g_knife_strong[iattacker])
  498.                 set_msg_arg_string(4, "Strong knife")
  499.         }
  500.  
  501.         if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
  502.         {
  503.             if(g_knife_axe[iattacker])
  504.                 set_msg_arg_string(4, "Axe knife")
  505.         }
  506.  
  507.         if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
  508.         {
  509.             if(g_knife_katana[iattacker])
  510.                 set_msg_arg_string(4, "Katana knife")
  511.         }
  512.  
  513.         if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
  514.         {
  515.             if(g_knife_hammer[iattacker])
  516.                 set_msg_arg_string(4, "Ice knife")
  517.         }
  518.     }
  519.     return PLUGIN_CONTINUE
  520. }
  521.  
  522. stock print_col_chat(const id, const input[], any:...)  
  523. {  
  524.     new count = 1, players[32];  
  525.         static msg[191];  
  526.         vformat(msg, 190, input, 3);  
  527.         replace_all(msg, 190, "!g", "^4"); // Green Color  
  528.         replace_all(msg, 190, "!y", "^1"); // Default Color
  529.         replace_all(msg, 190, "!t", "^3"); // Team Color  
  530.         if (id) players[0] = id; else get_players(players, count, "ch");  
  531.         {  
  532.             for ( new i = 0; i < count; i++ )  
  533.             {  
  534.                     if ( is_user_connected(players[i]) )  
  535.                     {  
  536.                         message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i]);  
  537.                         write_byte(players[i]);  
  538.                         write_string(msg);  
  539.                         message_end();  
  540.                     }  
  541.             }  
  542.         }  
  543. }  
  544.  
  545. public fw_PlayerPreThink(id)
  546. {
  547.     if(!is_user_alive(id) || ze_is_user_zombie(id))
  548.         return FMRES_IGNORED
  549.  
  550.     new temp[2], weapon = get_user_weapon(id, temp[0], temp[1])
  551.  
  552.     if (weapon == CSW_KNIFE && g_knife_combat[id] && !g_freezetime)
  553.     {
  554.         g_hasSpeed[id] = true
  555.         set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_combat_spd))
  556.     }
  557.  
  558.     if(weapon == CSW_KNIFE && g_knife_combat[id])        
  559.         if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
  560.         {
  561.             new flags = pev(id, pev_flags)
  562.             new waterlvl = pev(id, pev_waterlevel)
  563.            
  564.             if (!(flags & FL_ONGROUND))
  565.                 return FMRES_IGNORED
  566.  
  567.             if (flags & FL_WATERJUMP)
  568.                 return FMRES_IGNORED
  569.  
  570.             if (waterlvl > 1)
  571.                 return FMRES_IGNORED
  572.            
  573.             new Float:fVelocity[3]
  574.             pev(id, pev_velocity, fVelocity)
  575.            
  576.             fVelocity[2] += get_pcvar_num(cvar_knife_combat_jump)
  577.            
  578.             set_pev(id, pev_velocity, fVelocity)
  579.             set_pev(id, pev_gaitsequence, 6)
  580.         }
  581.     if (weapon == CSW_KNIFE && g_knife_strong[id])
  582.     {
  583.         g_hasSpeed[id] = true
  584.         set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_strong_spd))
  585.  
  586.         if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
  587.         {
  588.             new flags = pev(id, pev_flags)
  589.             new waterlvl = pev(id, pev_waterlevel)
  590.            
  591.             if (!(flags & FL_ONGROUND))
  592.                 return FMRES_IGNORED
  593.  
  594.             if (flags & FL_WATERJUMP)
  595.                 return FMRES_IGNORED
  596.  
  597.             if (waterlvl > 1)
  598.                 return FMRES_IGNORED
  599.            
  600.             new Float:fVelocity[3]
  601.             pev(id, pev_velocity, fVelocity)
  602.            
  603.             fVelocity[2] += get_pcvar_num(cvar_knife_strong_jump)
  604.            
  605.             set_pev(id, pev_velocity, fVelocity)
  606.             set_pev(id, pev_gaitsequence, 6)
  607.         }
  608.     }
  609.     if (weapon == CSW_KNIFE && g_knife_axe[id])
  610.     {
  611.         g_hasSpeed[id] = true
  612.         set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_axe_spd))
  613.  
  614.         if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
  615.         {
  616.             new flags = pev(id, pev_flags)
  617.             new waterlvl = pev(id, pev_waterlevel)
  618.            
  619.             if (!(flags & FL_ONGROUND))
  620.                 return FMRES_IGNORED
  621.  
  622.             if (flags & FL_WATERJUMP)
  623.                 return FMRES_IGNORED
  624.  
  625.             if (waterlvl > 1)
  626.                 return FMRES_IGNORED
  627.            
  628.             new Float:fVelocity[3]
  629.             pev(id, pev_velocity, fVelocity)
  630.            
  631.             fVelocity[2] += get_pcvar_num(cvar_knife_axe_jump)
  632.            
  633.             set_pev(id, pev_velocity, fVelocity)
  634.             set_pev(id, pev_gaitsequence, 6)
  635.         }
  636.     }
  637.     if (weapon == CSW_KNIFE && g_knife_katana[id])
  638.     {
  639.         g_hasSpeed[id] = true
  640.         set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_katana_spd))
  641.  
  642.         if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
  643.         {
  644.             new flags = pev(id, pev_flags)
  645.             new waterlvl = pev(id, pev_waterlevel)
  646.            
  647.             if (!(flags & FL_ONGROUND))
  648.                 return FMRES_IGNORED
  649.  
  650.             if (flags & FL_WATERJUMP)
  651.                 return FMRES_IGNORED
  652.  
  653.             if (waterlvl > 1)
  654.                 return FMRES_IGNORED
  655.            
  656.             new Float:fVelocity[3]
  657.             pev(id, pev_velocity, fVelocity)
  658.            
  659.             fVelocity[2] += get_pcvar_num(cvar_knife_katana_jump)
  660.            
  661.             set_pev(id, pev_velocity, fVelocity)
  662.             set_pev(id, pev_gaitsequence, 6)
  663.         }
  664.     }
  665.     if (weapon == CSW_KNIFE && g_knife_hammer[id])
  666.     {
  667.         g_hasSpeed[id] = true
  668.         set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_hammer_spd))
  669.  
  670.         if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
  671.         {
  672.             new flags = pev(id, pev_flags)
  673.             new waterlvl = pev(id, pev_waterlevel)
  674.            
  675.             if (!(flags & FL_ONGROUND))
  676.                 return FMRES_IGNORED
  677.  
  678.             if (flags & FL_WATERJUMP)
  679.                 return FMRES_IGNORED
  680.  
  681.             if (waterlvl > 1)
  682.                 return FMRES_IGNORED
  683.            
  684.             new Float:fVelocity[3]
  685.             pev(id, pev_velocity, fVelocity)
  686.            
  687.             fVelocity[2] += get_pcvar_num(cvar_knife_hammer_jump)
  688.            
  689.             set_pev(id, pev_velocity, fVelocity)
  690.             set_pev(id, pev_gaitsequence, 6)
  691.         }
  692.     }
  693.     return FMRES_IGNORED
  694. }  
  695.  
  696. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  697. {
  698.     if(!is_user_connected(attacker))
  699.         return HAM_IGNORED
  700.    
  701.     if(ze_is_user_zombie(attacker))
  702.         return HAM_IGNORED
  703.  
  704.     new weapon = get_user_weapon(attacker)
  705.  
  706.     if (weapon == CSW_KNIFE && g_knife_combat[attacker])
  707.     {  
  708.         SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_combat_dmg))
  709.     }
  710.     if (weapon == CSW_KNIFE && g_knife_strong[attacker])
  711.     {  
  712.         SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_strong_dmg))
  713.     }
  714.     if (weapon == CSW_KNIFE && g_knife_axe[attacker])
  715.     {  
  716.         SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_axe_dmg))
  717.     }
  718.     if (weapon == CSW_KNIFE && g_knife_katana[attacker])
  719.     {  
  720.         SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_katana_dmg))
  721.     }
  722.        
  723.     if (weapon == CSW_KNIFE && g_knife_hammer[attacker])
  724.     {    
  725.         SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_hammer_dmg))
  726.     }
  727.  
  728.     return HAM_IGNORED
  729. }
  730.  
  731. public fw_Knife_SecondaryAttack_Post(knife)
  732. {    
  733.         static id
  734.         id = get_pdata_cbase(knife, m_pPlayer, 4)
  735.  
  736.         if(ze_is_user_zombie(id))
  737.         return HAM_IGNORED
  738.    
  739.         if(is_user_connected(id) && g_knife_combat[id])
  740.         {
  741.             static Float:flRate
  742.             flRate = get_pcvar_float(cvar_knife_combat_spd_attack2)
  743.          
  744.             set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
  745.             set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
  746.             set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
  747.         }
  748.  
  749.         if(is_user_connected(id) && g_knife_strong[id])
  750.         {
  751.             static Float:flRate
  752.             flRate = get_pcvar_float(cvar_knife_strong_spd_attack2)
  753.              
  754.             set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
  755.             set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
  756.             set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
  757.         }
  758.  
  759.         if(is_user_connected(id) && g_knife_axe[id])
  760.         {
  761.             static Float:flRate
  762.             flRate = get_pcvar_float(cvar_knife_axe_spd_attack2)
  763.                  
  764.             set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
  765.             set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
  766.             set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
  767.         }
  768.  
  769.         if(is_user_connected(id) && g_knife_katana[id])
  770.         {
  771.             static Float:flRate
  772.             flRate = get_pcvar_float(cvar_knife_katana_spd_attack2)
  773.                  
  774.             set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
  775.             set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
  776.             set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
  777.         }
  778.  
  779.         if(is_user_connected(id) && g_knife_hammer[id])
  780.         {
  781.             static Float:flRate
  782.             flRate = get_pcvar_float(cvar_hammer_spd_attack2)
  783.              
  784.             set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
  785.             set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
  786.             set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
  787.         }  
  788.    
  789.         return HAM_IGNORED
  790. }
  791.  
  792. public event_Damage(id)
  793. {
  794.     new weapon , attacker = get_user_attacker(id , weapon);
  795.  
  796.     if(!is_user_alive(attacker))
  797.         return PLUGIN_CONTINUE;
  798.  
  799.     if(weapon == CSW_KNIFE && g_knife_combat[attacker])
  800.     {
  801.         new Float:vec[3];
  802.         new Float:oldvelo[3];
  803.         get_user_velocity(id, oldvelo);
  804.         create_velocity_vector(id , attacker , vec);
  805.         vec[0] += oldvelo[0];
  806.         vec[1] += oldvelo[1];
  807.         set_user_velocity(id , vec);
  808.     }
  809.  
  810.     if(weapon == CSW_KNIFE && g_knife_strong[attacker])
  811.     {
  812.         new Float:vec[3];
  813.         new Float:oldvelo[3];
  814.         get_user_velocity(id, oldvelo);
  815.         create_velocity_vector(id , attacker , vec);
  816.         vec[0] += oldvelo[0];
  817.         vec[1] += oldvelo[1];
  818.         set_user_velocity(id , vec);
  819.     }
  820.  
  821.     if(weapon == CSW_KNIFE && g_knife_axe[attacker])
  822.     {
  823.         new Float:vec[3];
  824.         new Float:oldvelo[3];
  825.         get_user_velocity(id, oldvelo);
  826.         create_velocity_vector(id , attacker , vec);
  827.         vec[0] += oldvelo[0];
  828.         vec[1] += oldvelo[1];
  829.         set_user_velocity(id , vec);
  830.     }
  831.  
  832.     if(weapon == CSW_KNIFE && g_knife_katana[attacker])
  833.     {
  834.         new Float:vec[3];
  835.         new Float:oldvelo[3];
  836.         get_user_velocity(id, oldvelo);
  837.         create_velocity_vector(id , attacker , vec);
  838.         vec[0] += oldvelo[0];
  839.         vec[1] += oldvelo[1];
  840.         set_user_velocity(id , vec);
  841.     }
  842.  
  843.     if(weapon == CSW_KNIFE && g_knife_hammer[attacker])
  844.     {
  845.         new Float:vec[3];
  846.         new Float:oldvelo[3];
  847.         get_user_velocity(id, oldvelo);
  848.         create_velocity_vector(id , attacker , vec);
  849.         vec[0] += oldvelo[0];
  850.         vec[1] += oldvelo[1];
  851.         set_user_velocity(id , vec);
  852.     }
  853.  
  854.     return PLUGIN_CONTINUE;
  855. }
  856.  
  857. stock create_velocity_vector(victim,attacker,Float:velocity[3])
  858. {
  859.     if(!ze_is_user_zombie(victim) || !is_user_alive(attacker))
  860.         return 0;
  861.  
  862.     new Float:vicorigin[3];
  863.     new Float:attorigin[3];
  864.     entity_get_vector(victim   , EV_VEC_origin , vicorigin);
  865.     entity_get_vector(attacker , EV_VEC_origin , attorigin);
  866.  
  867.     new Float:origin2[3]
  868.     origin2[0] = vicorigin[0] - attorigin[0];
  869.     origin2[1] = vicorigin[1] - attorigin[1];
  870.  
  871.     new Float:largestnum = 0.0;
  872.  
  873.     if(floatabs(origin2[0])>largestnum) largestnum = floatabs(origin2[0]);
  874.     if(floatabs(origin2[1])>largestnum) largestnum = floatabs(origin2[1]);
  875.  
  876.     origin2[0] /= largestnum;
  877.     origin2[1] /= largestnum;
  878.  
  879.     if (g_knife_combat[attacker])
  880.     {
  881.         velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_combat_knock) * 3000) ) / get_entity_distance(victim , attacker);
  882.         velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_combat_knock) * 3000) ) / get_entity_distance(victim , attacker);
  883.     }
  884.  
  885.     if (g_knife_strong[attacker])
  886.     {
  887.         velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_strong_knock) * 3000) ) / get_entity_distance(victim , attacker);
  888.         velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_strong_knock) * 3000) ) / get_entity_distance(victim , attacker);
  889.     }
  890.  
  891.     if (g_knife_axe[attacker])
  892.     {
  893.         velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_axe_knock) * 3000) ) / get_entity_distance(victim , attacker);
  894.         velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_axe_knock) * 3000) ) / get_entity_distance(victim , attacker);
  895.     }
  896.  
  897.     if (g_knife_katana[attacker])
  898.     {
  899.         velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_katana_knock) * 3000) ) / get_entity_distance(victim , attacker);
  900.         velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_katana_knock) * 3000) ) / get_entity_distance(victim , attacker);
  901.     }
  902.  
  903.     if (g_knife_hammer[attacker])
  904.     {
  905.         velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_hammer_knock) * 3000) ) / get_entity_distance(victim , attacker);
  906.         velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_hammer_knock) * 3000) ) / get_entity_distance(victim , attacker);
  907.     }
  908.  
  909.     if(velocity[0] <= 20.0 || velocity[1] <= 20.0)
  910.         velocity[2] = random_float(200.0 , 275.0);
  911.  
  912.     return 1;
  913. }
  914.  
  915. public client_putinserver(id)
  916. {
  917.     switch(random_num(0, 0))
  918.     {
  919.         case 0:
  920.         {
  921.             g_knife_combat[id] = true
  922.             g_hasSpeed[id] = true
  923.         }
  924.  
  925.     }
  926. }

The problem was in:
    1.     if (!is_user_connected(id) && ze_is_user_zombie(id))
    2.         return PLUGIN_HANDLED
Should be:
    1.     if (!is_user_connected(id) || ze_is_user_zombie(id))
    2.         return PLUGIN_HANDLED
Now it's working for me, and anyway you will get another issue that with this humans will be able to run during the freeze time. We already have knife menu in the gameplay section you can use it instead as it's fixed version: viewtopic.php?f=15&t=88

here fixed freezetime run problem:
___________________________________

Code: Select all

#include <zombie_escape>
#include <engine>
#include <fun>
 
#define PLUGIN    "Choose knifes"
#define VERSION    "1.0"
#define AUTHOR    "CHyC/4e/l"
 
#define VIP ADMIN_LEVEL_H
#define MAXPLAYERS 32
 
new combat_v_model[] = "models/zb/v_combat_knife.mdl"
new combat_p_model[] = "models/zb/p_combat_knife.mdl"
 
new strong_v_model[] = "models/zb/v_strong_knife.mdl"
new strong_p_model[] = "models/zb/p_strong_knife.mdl"
 
new axe_v_model[] = "models/zb/v_axe_knife.mdl"
new axe_p_model[] = "models/zb/p_axe_knife.mdl"
 
new katana_v_model[] = "models/zb/v_katana_knife.mdl"  
new katana_p_model[] = "models/zb/p_katana_knife.mdl"
 
new hammer_v_model[] = "models/zb/v_hammer_knife.mdl"  
new hammer_p_model[] = "models/zb/p_hammer_knife.mdl"  
 
const m_pPlayer = 41
const m_flNextPrimaryAttack = 46
const m_flNextSecondaryAttack = 47
const m_flTimeWeaponIdle = 48
 
new g_hasSpeed[33], SayText
new bool:g_WasShowed[MAXPLAYERS + 1]
new g_knife_combat[33], cvar_knife_combat_jump, cvar_knife_combat_spd, cvar_knife_combat_dmg, cvar_knife_combat_knock, cvar_knife_combat_spd_attack2
new g_knife_strong[33], cvar_knife_strong_jump, cvar_knife_strong_spd, cvar_knife_strong_dmg, cvar_knife_strong_knock, cvar_knife_strong_spd_attack2
new g_knife_axe[33], cvar_knife_axe_jump, cvar_knife_axe_spd, cvar_knife_axe_dmg, cvar_knife_axe_knock, cvar_knife_axe_spd_attack2
new g_knife_katana[33], cvar_knife_katana_jump, cvar_knife_katana_spd, cvar_knife_katana_dmg, cvar_knife_katana_knock, cvar_knife_katana_spd_attack2
new g_knife_hammer[33], cvar_knife_hammer_jump, cvar_knife_hammer_spd, cvar_knife_hammer_dmg, cvar_knife_hammer_knock, cvar_hammer_spd_attack2
 
new const g_sound_knife[] = { "items/gunpickup2.wav" }
 
new const combat_sounds[][] =
{
    "zmwpn/zb_knife/combat_deploy.wav",
    "zmwpn/zb_knife/combat_hit.wav" ,
    "zmwpn/zb_knife/combat_hit.wav" ,
    "zmwpn/zb_knife/combat_hit.wav" ,
    "zmwpn/zb_knife/combat_hit.wav" ,
    "zmwpn/zb_knife/combat_hitwall.wav",
    "zmwpn/zb_knife/combat_slash.wav",
    "zmwpn/zb_knife/combat_slash.wav",
    "zmwpn/zb_knife/combat_stab.wav"
}
 
new const strong_sounds[][] =
{
    "zmwpn/zb_knife/strong_deploy.wav",
    "zmwpn/zb_knife/strong_hit.wav",
    "zmwpn/zb_knife/strong_hit.wav",
    "zmwpn/zb_knife/strong_hit.wav",
    "zmwpn/zb_knife/strong_hit.wav",
    "zmwpn/zb_knife/strong_hitwall.wav",
    "zmwpn/zb_knife/strong_slash.wav",
    "zmwpn/zb_knife/strong_slash.wav",
    "zmwpn/zb_knife/strong_stab.wav"
}
 
new const axe_sounds[][] =
{
    "zmwpn/zb_knife/axe_deploy.wav",
    "zmwpn/zb_knife/axe_hit.wav",
    "zmwpn/zb_knife/axe_hit.wav",
    "zmwpn/zb_knife/axe_hit.wav",
    "zmwpn/zb_knife/axe_hit.wav",
    "zmwpn/zb_knife/axe_hitwall.wav",
    "zmwpn/zb_knife/axe_slash.wav",
    "zmwpn/zb_knife/axe_slash.wav",
    "zmwpn/zb_knife/axe_stab.wav"
}
 
new const katana_sounds[][] =
{
    "zmwpn/zb_knife/katana_deploy.wav",
    "zmwpn/zb_knife/katana_hit.wav",
    "zmwpn/zb_knife/katana_hit.wav",
    "zmwpn/zb_knife/katana_hit.wav",
    "zmwpn/zb_knife/katana_hit.wav",
    "zmwpn/zb_knife/katana_hitwall.wav",
    "zmwpn/zb_knife/katana_slash.wav",
    "zmwpn/zb_knife/katana_slash.wav",
    "zmwpn/zb_knife/katana_stab.wav"
}
 
new const hammer_sounds[][] =
{
    "zmwpn/zb_knife/hammer_deploy.wav",
    "zmwpn/zb_knife/hammer_hit.wav",
    "zmwpn/zb_knife/hammer_hit.wav",
    "zmwpn/zb_knife/hammer_hit.wav",
    "zmwpn/zb_knife/hammer_hit.wav",
    "zmwpn/zb_knife/hammer_hitwall.wav",
    "zmwpn/zb_knife/hammer_slash.wav",
    "zmwpn/zb_knife/hammer_slash.wav",
    "zmwpn/zb_knife/hammer_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 g_freezetime
public plugin_init()
{
    register_plugin(PLUGIN , VERSION , AUTHOR);
    register_cvar("ze_addon_knife", VERSION, FCVAR_SERVER);
    SayText = get_user_msgid("SayText")  
 
    register_clcmd("say /knife","knife_menu",ADMIN_ALL,"knife_menu")
    register_clcmd("/knife","knife_menu",ADMIN_ALL,"knife_menu")
    register_clcmd("combat", "give_combat")
    register_clcmd("strong", "give_strong")
    register_clcmd("axe", "give_axe")
    register_clcmd("katana", "give_katana")
    register_clcmd("hammer", "give_hammer")
 
    register_event("CurWeapon","checkWeapon","be","1=1");
    register_event("Damage" , "event_Damage" , "b" , "2>0");
 
    register_forward(FM_PlayerPreThink, "fw_PlayerPreThink");
    register_forward(FM_EmitSound, "fw_EmitSound");
 
    register_message(get_user_msgid("DeathMsg"), "message_DeathMsg");
 
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
    RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "fw_Knife_SecondaryAttack_Post", 1)
 
    cvar_knife_combat_jump= register_cvar("ze_knife_combat_jump", "270.0");
    cvar_knife_combat_spd = register_cvar("ze_knife_combat_spd", "310.0");
    cvar_knife_combat_dmg = register_cvar("ze_knife_combat_dmg" , "4.0");
    cvar_knife_combat_knock = register_cvar("ze_knife_combat_knock" , "6.0");
    cvar_knife_combat_spd_attack2 = register_cvar("ze_knife_combat_spd_attack2" , "1.2");
 
    cvar_knife_strong_jump= register_cvar("ze_knife_strong_jump", "265.0");
    cvar_knife_strong_spd = register_cvar("ze_knife_strong_spd", "255.0");
    cvar_knife_strong_dmg = register_cvar("ze_knife_strong_dmg" , "12.0");
    cvar_knife_strong_knock = register_cvar("ze_knife_strong_knock" , "7.0");
    cvar_knife_strong_spd_attack2 = register_cvar("ze_knife_strong_spd_attack2" , "1.6");
 
    cvar_knife_axe_jump= register_cvar("ze_knife_axe_jump", "335.0");
    cvar_knife_axe_spd = register_cvar("ze_knife_axe_spd", "250.0");
    cvar_knife_axe_dmg = register_cvar("ze_knife_axe_dmg" , "5.0");
    cvar_knife_axe_knock = register_cvar("ze_knife_axe_knock" , "6.0");
    cvar_knife_axe_spd_attack2 = register_cvar("ze_knife_axe_spd_attack2" , "1.4");
 
    cvar_knife_katana_jump= register_cvar("ze_knife_katana_jump", "275.0");
    cvar_knife_katana_spd = register_cvar("ze_knife_katana_spd", "265.0");
    cvar_knife_katana_dmg = register_cvar("ze_knife_katana_dmg" , "5.0");
    cvar_knife_katana_knock = register_cvar("ze_knife_katana_knock" , "15.0");
    cvar_knife_katana_spd_attack2 = register_cvar("ze_knife_katana_spd_attack2" , "1.2");
 
    cvar_knife_hammer_jump= register_cvar("ze_knife_hammer_jump", "335.0");
    cvar_knife_hammer_spd= register_cvar("ze_knife_hammer_spd", "315.0");
    cvar_knife_hammer_dmg = register_cvar("ze_knife_hammer_dmg" , "15.0");
    cvar_knife_hammer_knock = register_cvar("ze_knife_hammer_knock" , "15.0");
    cvar_hammer_spd_attack2 = register_cvar("ze_knife_hammer_spd_attack2" , "1.8");
 
        register_event("HLTV", "event_newround", "a", "1=0", "2=0")
    register_logevent("roundstart",2,"1=Round_Start")
}
public ze_zombie_appear()
{
	g_freezetime = false
}
public ze_roundend(id)
{
	g_freezetime = true
}
public client_connect(id)
{
    g_knife_combat[id] = false
    g_knife_strong[id] = false
    g_knife_axe[id] = false
    g_knife_katana[id] = false
    g_knife_hammer[id] = false
    g_hasSpeed[id] = false
}
 
public client_disconnected(id)
{
    g_knife_combat[id] = false
    g_knife_strong[id] = false
    g_knife_axe[id] = false
    g_knife_katana[id] = false
    g_knife_hammer[id] = false
    g_hasSpeed[id] = false
}
 
public plugin_precache()
{
    precache_model(combat_v_model)
    precache_model(combat_p_model)
    precache_model(strong_v_model)
    precache_model(strong_p_model)
    precache_model(axe_v_model)
    precache_model(axe_p_model)
    precache_model(katana_v_model)
    precache_model(katana_p_model)
    precache_model(hammer_v_model)
    precache_model(hammer_p_model)
 
    precache_sound(g_sound_knife)
 
    for(new i = 0; i < sizeof combat_sounds; i++)
        precache_sound(combat_sounds[i])
 
    for(new i = 0; i < sizeof strong_sounds; i++)
        precache_sound(strong_sounds[i])
 
    for(new i = 0; i < sizeof axe_sounds; i++)
        precache_sound(axe_sounds[i])  
 
    for(new i = 0; i < sizeof katana_sounds; i++)
        precache_sound(katana_sounds[i])
 
    for(new i = 0; i < sizeof hammer_sounds; i++)
        precache_sound(hammer_sounds[i])
}
public knife_menu(id)
{
        if (g_WasShowed[id])
        {
        print_col_chat(id, "^1[^4ZE^1] Knife menu mozete da koristite samo jednom u rundi!")
        return PLUGIN_HANDLED
    }
    else if(is_user_alive(id) && !ze_is_user_zombie(id))
    {
        my_menu(id)
    }
    return PLUGIN_HANDLED
}
public my_menu(id)
{
    new menu = menu_create("\yChose your knife!", "menu_handler");
    menu_additem(menu, "\wCombat \y[ Speed ]", "1", 0);
    menu_additem(menu, "\wStrong \y[ Damage ]", "2", 0);
    menu_additem(menu, "\wAxe \y[ Jump ]", "3", 0);
    menu_additem(menu, "\wKatana \y[ Knockback ]", "4", 0);
    menu_additem(menu, "\wHammer \r[ VIP | Boost ]", "5", 0);
   
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
   
    menu_display(id, menu, 0);    
}
public menu_handler(id, menu, item)
{
    if( item == MENU_EXIT )
    {
            menu_destroy(menu);
            return PLUGIN_HANDLED;    
    }
   
    new data[6], iName[64];
    new access, callback;
   
    menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
   
    new key = str_to_num(data);
   
    switch(key)
    {
        case 1:
        {
            give_combat(id)
            menu_destroy(menu);
            return PLUGIN_HANDLED
        }
        case 2:
        {
            give_strong(id)
            menu_destroy(menu);
            return PLUGIN_HANDLED
        }
        case 3:
        {
            give_axe(id)
            menu_destroy(menu);
            return PLUGIN_HANDLED
        }
        case 4:
        {
            give_katana(id)
            menu_destroy(menu);
            return PLUGIN_HANDLED
        }
        case 5:
        {
            give_hammer(id)
            menu_destroy(menu);
            return PLUGIN_HANDLED
        }
    }
    menu_destroy(menu);
    return PLUGIN_HANDLED
}
public give_combat(id)
{
    g_knife_combat[id] = true  
    g_knife_strong[id] = false
    g_knife_axe[id] = false
    g_knife_katana[id] = false 
    g_knife_hammer[id] = false
    if(!g_freezetime)
    {
	g_hasSpeed[id] =  true
    }
    g_WasShowed[id] = true
 
    engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
}
public give_strong(id)
{
    g_knife_combat[id] = false 
    g_knife_strong[id] = true  
    g_knife_axe[id] = false
    g_knife_katana[id] = false 
    g_knife_hammer[id] = false
    g_hasSpeed[id] = true
    g_WasShowed[id] = true
 
    engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
}
public give_axe(id)
{
    g_knife_combat[id] = false 
    g_knife_strong[id] = false 
    g_knife_axe[id] = true
    g_knife_katana[id] = false 
    g_knife_hammer[id] = false
    g_hasSpeed[id] = true
    g_WasShowed[id] = true
 
    engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
}
public give_katana(id)
{
    g_knife_combat[id] = false 
    g_knife_strong[id] = false 
    g_knife_axe[id] = false
    g_knife_katana[id] = true  
    g_knife_hammer[id] = false
    g_hasSpeed[id] = true
    g_WasShowed[id] = true
 
    engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
}
public give_hammer(id)
{
    if (get_user_flags(id) & VIP)
    {
        g_knife_combat[id] = false 
        g_knife_strong[id] = false 
        g_knife_axe[id] = false
        g_knife_katana[id] = false
        g_knife_hammer[id] = true
        if(!g_freezetime)
        {
		g_hasSpeed[id] =  true
        }
        g_WasShowed[id] = true
 
        engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
    }
    else
    {
        client_cmd(id, "/knife")
        g_WasShowed[id] = true
    }
}
public checkWeapon(id)
{
    new plrWeapId
   
    plrWeapId = get_user_weapon(id)
   
    if (plrWeapId == CSW_KNIFE && (g_knife_combat[id] || g_knife_strong[id] || g_knife_axe[id] || g_knife_katana[id] || g_knife_hammer[id]))
    {
        checkModel(id)
    }
}
public checkModel(id)
{
    if (!is_user_connected(id) || ze_is_user_zombie(id))
        return PLUGIN_HANDLED
       
    if(g_knife_combat[id])
    {
        set_pev(id, pev_viewmodel2, combat_v_model)
        set_pev(id, pev_weaponmodel2, combat_p_model)
    }
    if(g_knife_strong[id])
    {
        set_pev(id, pev_viewmodel2, strong_v_model)
        set_pev(id, pev_weaponmodel2, strong_p_model)
    }
    if(g_knife_axe[id])
    {
        set_pev(id, pev_viewmodel2, axe_v_model)
        set_pev(id, pev_weaponmodel2, axe_p_model)
    }
    if(g_knife_katana[id])
    {
        set_pev(id, pev_viewmodel2, katana_v_model)
        set_pev(id, pev_weaponmodel2, katana_p_model)
    }
    if(g_knife_hammer[id])
    {
        set_pev(id, pev_viewmodel2, hammer_v_model)
        set_pev(id, pev_weaponmodel2, hammer_p_model)
    }
    return PLUGIN_HANDLED
}
public fw_EmitSound(id, channel, const sound[])
{
    if(!is_user_alive(id) || ze_is_user_zombie(id))
        return FMRES_IGNORED
       
    for(new i = 0; i < sizeof combat_sounds; i++)
    for(new i = 0; i < sizeof strong_sounds; i++)
    for(new i = 0; i < sizeof axe_sounds; i++)
    for(new i = 0; i < sizeof katana_sounds; i++)
    for(new i = 0; i < sizeof hammer_sounds; i++)
    {
        if(equal(sound, oldknife_sounds[i]))
        {
            if (g_knife_combat[id])
            {
                emit_sound(id, channel, combat_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            if (g_knife_strong[id])
            {
                emit_sound(id, channel, strong_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            if (g_knife_axe[id])
            {
                emit_sound(id, channel, axe_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            if (g_knife_katana[id])
            {
                emit_sound(id, channel, katana_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            if (g_knife_hammer[id])
            {
                emit_sound(id, channel, hammer_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
            if (!g_knife_combat[id] || !g_knife_strong[id] || !g_knife_axe[id] || !g_knife_katana[id] || !g_knife_hammer[id])
            {
                emit_sound(id, channel, oldknife_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
                return FMRES_SUPERCEDE
            }
        }
    }
    return FMRES_IGNORED
}
public message_DeathMsg(msg_id, msg_dest, id)
{
    static szTruncatedWeapon[33], iattacker, ivictim
   
    get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
   
    iattacker = get_msg_arg_int(1)
    ivictim = get_msg_arg_int(2)
   
    if(!is_user_connected(iattacker) || iattacker == ivictim)
        return PLUGIN_CONTINUE
 
    if (!ze_is_user_zombie(iattacker))
    {
        if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
        {
            if(g_knife_combat[iattacker])
                set_msg_arg_string(4, "Combat knife")
        }
   
        if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
        {
            if(g_knife_strong[iattacker])
                set_msg_arg_string(4, "Strong knife")
        }
 
        if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
        {
            if(g_knife_axe[iattacker])
                set_msg_arg_string(4, "Axe knife")
        }
 
        if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
        {
            if(g_knife_katana[iattacker])
                set_msg_arg_string(4, "Katana knife")
        }
 
        if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iattacker) == CSW_KNIFE)
        {
            if(g_knife_hammer[iattacker])
                set_msg_arg_string(4, "Ice knife")
        }
    }
    return PLUGIN_CONTINUE
}
 
stock print_col_chat(const id, const input[], any:...)  
{  
    new count = 1, players[32];  
        static msg[191];  
        vformat(msg, 190, input, 3);  
        replace_all(msg, 190, "!g", "^4"); // Green Color  
        replace_all(msg, 190, "!y", "^1"); // Default Color
        replace_all(msg, 190, "!t", "^3"); // Team Color  
        if (id) players[0] = id; else get_players(players, count, "ch");  
        {  
            for ( new i = 0; i < count; i++ )  
            {  
                    if ( is_user_connected(players[i]) )  
                    {  
                        message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i]);  
                        write_byte(players[i]);  
                        write_string(msg);  
                        message_end();  
                    }  
            }  
        }  
}  
 
public fw_PlayerPreThink(id)
{
    if(!is_user_alive(id) || ze_is_user_zombie(id))
        return FMRES_IGNORED
 
    new temp[2], weapon = get_user_weapon(id, temp[0], temp[1])
 
    if (weapon == CSW_KNIFE && g_knife_combat[id])
    {
        g_hasSpeed[id] = true
        set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_combat_spd))
    }
 
    if(weapon == CSW_KNIFE && g_knife_combat[id])        
        if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
        {
            new flags = pev(id, pev_flags)
            new waterlvl = pev(id, pev_waterlevel)
           
            if (!(flags & FL_ONGROUND))
                return FMRES_IGNORED
 
            if (flags & FL_WATERJUMP)
                return FMRES_IGNORED
 
            if (waterlvl > 1)
                return FMRES_IGNORED
           
            new Float:fVelocity[3]
            pev(id, pev_velocity, fVelocity)
           
            fVelocity[2] += get_pcvar_num(cvar_knife_combat_jump)
           
            set_pev(id, pev_velocity, fVelocity)
            set_pev(id, pev_gaitsequence, 6)
        }
    if (weapon == CSW_KNIFE && g_knife_strong[id])
    {
        g_hasSpeed[id] = true
        set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_strong_spd))
 
        if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
        {
            new flags = pev(id, pev_flags)
            new waterlvl = pev(id, pev_waterlevel)
           
            if (!(flags & FL_ONGROUND))
                return FMRES_IGNORED
 
            if (flags & FL_WATERJUMP)
                return FMRES_IGNORED
 
            if (waterlvl > 1)
                return FMRES_IGNORED
           
            new Float:fVelocity[3]
            pev(id, pev_velocity, fVelocity)
           
            fVelocity[2] += get_pcvar_num(cvar_knife_strong_jump)
           
            set_pev(id, pev_velocity, fVelocity)
            set_pev(id, pev_gaitsequence, 6)
        }
    }
    if (weapon == CSW_KNIFE && g_knife_axe[id])
    {
        g_hasSpeed[id] = true
        set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_axe_spd))
 
        if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
        {
            new flags = pev(id, pev_flags)
            new waterlvl = pev(id, pev_waterlevel)
           
            if (!(flags & FL_ONGROUND))
                return FMRES_IGNORED
 
            if (flags & FL_WATERJUMP)
                return FMRES_IGNORED
 
            if (waterlvl > 1)
                return FMRES_IGNORED
           
            new Float:fVelocity[3]
            pev(id, pev_velocity, fVelocity)
           
            fVelocity[2] += get_pcvar_num(cvar_knife_axe_jump)
           
            set_pev(id, pev_velocity, fVelocity)
            set_pev(id, pev_gaitsequence, 6)
        }
    }
    if (weapon == CSW_KNIFE && g_knife_katana[id])
    {
        g_hasSpeed[id] = true
        set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_katana_spd))
 
        if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
        {
            new flags = pev(id, pev_flags)
            new waterlvl = pev(id, pev_waterlevel)
           
            if (!(flags & FL_ONGROUND))
                return FMRES_IGNORED
 
            if (flags & FL_WATERJUMP)
                return FMRES_IGNORED
 
            if (waterlvl > 1)
                return FMRES_IGNORED
           
            new Float:fVelocity[3]
            pev(id, pev_velocity, fVelocity)
           
            fVelocity[2] += get_pcvar_num(cvar_knife_katana_jump)
           
            set_pev(id, pev_velocity, fVelocity)
            set_pev(id, pev_gaitsequence, 6)
        }
    }
    if (weapon == CSW_KNIFE && g_knife_hammer[id])
    {
        g_hasSpeed[id] = true
        set_pev(id, pev_maxspeed, get_pcvar_float(cvar_knife_hammer_spd))
 
        if ((pev(id, pev_button) & IN_JUMP) && !(pev(id, pev_oldbuttons) & IN_JUMP))
        {
            new flags = pev(id, pev_flags)
            new waterlvl = pev(id, pev_waterlevel)
           
            if (!(flags & FL_ONGROUND))
                return FMRES_IGNORED
 
            if (flags & FL_WATERJUMP)
                return FMRES_IGNORED
 
            if (waterlvl > 1)
                return FMRES_IGNORED
           
            new Float:fVelocity[3]
            pev(id, pev_velocity, fVelocity)
           
            fVelocity[2] += get_pcvar_num(cvar_knife_hammer_jump)
           
            set_pev(id, pev_velocity, fVelocity)
            set_pev(id, pev_gaitsequence, 6)
        }
    }
    return FMRES_IGNORED
}  
 
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
    if(!is_user_connected(attacker))
        return HAM_IGNORED
   
    if(ze_is_user_zombie(attacker))
        return HAM_IGNORED
 
    new weapon = get_user_weapon(attacker)
 
    if (weapon == CSW_KNIFE && g_knife_combat[attacker])
    {  
        SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_combat_dmg))
    }
    if (weapon == CSW_KNIFE && g_knife_strong[attacker])
    {  
        SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_strong_dmg))
    }
    if (weapon == CSW_KNIFE && g_knife_axe[attacker])
    {  
        SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_axe_dmg))
    }
    if (weapon == CSW_KNIFE && g_knife_katana[attacker])
    {  
        SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_katana_dmg))
    }
       
    if (weapon == CSW_KNIFE && g_knife_hammer[attacker])
    {    
        SetHamParamFloat(4, damage * get_pcvar_float(cvar_knife_hammer_dmg))
    }
 
    return HAM_IGNORED
}
 
public fw_Knife_SecondaryAttack_Post(knife)
{    
        static id
        id = get_pdata_cbase(knife, m_pPlayer, 4)
 
        if(ze_is_user_zombie(id))
        return HAM_IGNORED
   
        if(is_user_connected(id) && g_knife_combat[id])
        {
            static Float:flRate
            flRate = get_pcvar_float(cvar_knife_combat_spd_attack2)
         
            set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
            set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
            set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
        }
 
        if(is_user_connected(id) && g_knife_strong[id])
        {
            static Float:flRate
            flRate = get_pcvar_float(cvar_knife_strong_spd_attack2)
             
            set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
            set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
            set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
        }
 
        if(is_user_connected(id) && g_knife_axe[id])
        {
            static Float:flRate
            flRate = get_pcvar_float(cvar_knife_axe_spd_attack2)
                 
            set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
            set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
            set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
        }
 
        if(is_user_connected(id) && g_knife_katana[id])
        {
            static Float:flRate
            flRate = get_pcvar_float(cvar_knife_katana_spd_attack2)
                 
            set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
            set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
            set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
        }
 
        if(is_user_connected(id) && g_knife_hammer[id])
        {
            static Float:flRate
            flRate = get_pcvar_float(cvar_hammer_spd_attack2)
             
            set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
            set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
            set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
        }  
   
        return HAM_IGNORED
}
 
public event_Damage(id)
{
    new weapon , attacker = get_user_attacker(id , weapon);
 
    if(!is_user_alive(attacker))
        return PLUGIN_CONTINUE;
 
    if(weapon == CSW_KNIFE && g_knife_combat[attacker])
    {
        new Float:vec[3];
        new Float:oldvelo[3];
        get_user_velocity(id, oldvelo);
        create_velocity_vector(id , attacker , vec);
        vec[0] += oldvelo[0];
        vec[1] += oldvelo[1];
        set_user_velocity(id , vec);
    }
 
    if(weapon == CSW_KNIFE && g_knife_strong[attacker])
    {
        new Float:vec[3];
        new Float:oldvelo[3];
        get_user_velocity(id, oldvelo);
        create_velocity_vector(id , attacker , vec);
        vec[0] += oldvelo[0];
        vec[1] += oldvelo[1];
        set_user_velocity(id , vec);
    }
 
    if(weapon == CSW_KNIFE && g_knife_axe[attacker])
    {
        new Float:vec[3];
        new Float:oldvelo[3];
        get_user_velocity(id, oldvelo);
        create_velocity_vector(id , attacker , vec);
        vec[0] += oldvelo[0];
        vec[1] += oldvelo[1];
        set_user_velocity(id , vec);
    }
 
    if(weapon == CSW_KNIFE && g_knife_katana[attacker])
    {
        new Float:vec[3];
        new Float:oldvelo[3];
        get_user_velocity(id, oldvelo);
        create_velocity_vector(id , attacker , vec);
        vec[0] += oldvelo[0];
        vec[1] += oldvelo[1];
        set_user_velocity(id , vec);
    }
 
    if(weapon == CSW_KNIFE && g_knife_hammer[attacker])
    {
        new Float:vec[3];
        new Float:oldvelo[3];
        get_user_velocity(id, oldvelo);
        create_velocity_vector(id , attacker , vec);
        vec[0] += oldvelo[0];
        vec[1] += oldvelo[1];
        set_user_velocity(id , vec);
    }
 
    return PLUGIN_CONTINUE;
}
 
stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
    if(!ze_is_user_zombie(victim) || !is_user_alive(attacker))
        return 0;
 
    new Float:vicorigin[3];
    new Float:attorigin[3];
    entity_get_vector(victim   , EV_VEC_origin , vicorigin);
    entity_get_vector(attacker , EV_VEC_origin , attorigin);
 
    new Float:origin2[3]
    origin2[0] = vicorigin[0] - attorigin[0];
    origin2[1] = vicorigin[1] - attorigin[1];
 
    new Float:largestnum = 0.0;
 
    if(floatabs(origin2[0])>largestnum) largestnum = floatabs(origin2[0]);
    if(floatabs(origin2[1])>largestnum) largestnum = floatabs(origin2[1]);
 
    origin2[0] /= largestnum;
    origin2[1] /= largestnum;
 
    if (g_knife_combat[attacker])
    {
        velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_combat_knock) * 3000) ) / get_entity_distance(victim , attacker);
        velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_combat_knock) * 3000) ) / get_entity_distance(victim , attacker);
    }
 
    if (g_knife_strong[attacker])
    {
        velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_strong_knock) * 3000) ) / get_entity_distance(victim , attacker);
        velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_strong_knock) * 3000) ) / get_entity_distance(victim , attacker);
    }
 
    if (g_knife_axe[attacker])
    {
        velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_axe_knock) * 3000) ) / get_entity_distance(victim , attacker);
        velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_axe_knock) * 3000) ) / get_entity_distance(victim , attacker);
    }
 
    if (g_knife_katana[attacker])
    {
        velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_katana_knock) * 3000) ) / get_entity_distance(victim , attacker);
        velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_katana_knock) * 3000) ) / get_entity_distance(victim , attacker);
    }
 
    if (g_knife_hammer[attacker])
    {
        velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knife_hammer_knock) * 3000) ) / get_entity_distance(victim , attacker);
        velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knife_hammer_knock) * 3000) ) / get_entity_distance(victim , attacker);
    }
 
    if(velocity[0] <= 20.0 || velocity[1] <= 20.0)
        velocity[2] = random_float(200.0 , 275.0);
 
    return 1;
}
 
public client_putinserver(id)
{
    switch(random_num(0, 0))
    {
        case 0:
        {
            g_knife_combat[id] = true
            g_hasSpeed[id] = true
        }
 
    }
}

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 4 guests