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