Resolved warhammer

Unpaid Requests, Public Plugins
Post Reply
czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 529
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

warhammer

#1

Post by czirimbolo » 2 Months Ago

Hey, when I pick up this knife, I can walk if freeze time. Can someone tell me how to fix this?
  1. #pragma compress 1
  2.  
  3. #include <zombie_escape>
  4. #include <fakemeta_util>
  5.  
  6.  
  7. #define CustomItem(%0) (pev(%0, pev_impulse) == WEAPON_SPECIAL_CODE)
  8.  
  9. // Linux extra offsets
  10. #define linux_diff_animating 4
  11. #define linux_diff_weapon 4
  12. #define linux_diff_player 5
  13.  
  14. // CBasePlayerItem
  15. #define m_pPlayer 41
  16.  
  17. // CBasePlayerWeapon
  18. #define m_flNextPrimaryAttack 46
  19. #define m_flNextSecondaryAttack 47
  20. #define m_flTimeWeaponIdle 48
  21.  
  22. // CBaseMonster
  23. #define m_LastHitGroup 75
  24. #define m_flNextAttack 83
  25.  
  26. // CBasePlayer
  27. #define m_flPainShock 108
  28. #define m_pActiveItem 373
  29. #define m_szAnimExtention 492
  30.  
  31. // from model: Frames / FPS
  32. #define TIME_IDLE 401/30.0
  33. #define TIME_DRAW_ATTACK 16/30.0
  34. #define TIME_DRAW 31/30.0
  35. #define TIME_MIDSLASH1 33/30.0
  36. #define TIME_MIDSLASH1_HIT 69/30.0
  37. #define TIME_MIDSLASH2 29/30.0
  38. #define TIME_MIDSLASH2_HIT 43/30.0
  39.  
  40. #define ANIM_IDLE 0
  41. #define ANIM_DRAW_ATTACK 1
  42. #define ANIM_DRAW 3
  43. #define ANIM_MIDSLASH1 4
  44. #define ANIM_MIDSLASH1_HIT 5
  45. #define ANIM_MIDSLASH2 7
  46. #define ANIM_MIDSLASH2_HIT 8
  47. #define ANIM_MIDSLASH2_FAIL 9
  48.  
  49. #define KNIFE_REFERENCE "weapon_knife"
  50.  
  51. #define KNIFE_MODEL_V "models/v_stormgiant.mdl"
  52. #define KNIFE_MODEL_P "models/p_stormgiant.mdl"
  53.  
  54. new const KNIFE_SOUNDS[][] = {
  55.     "weapons/stormgiant_attack_hit2.wav",       // 0
  56.     "weapons/stormgiant_hit1.wav",              // 1
  57.     "weapons/stormgiant_hit2.wav",              // 2
  58.     "weapons/stormgiant_midslash1.wav",         // 3
  59.     "weapons/stormgiant_midslash1_fail.wav",    // 4
  60.     "weapons/stormgiant_midslash1_hit.wav",     // 5
  61.     "weapons/stormgiant_midslash2_fail.wav",    // 6
  62.     "weapons/stormgiant_midslash2_hit.wav",     // 7
  63.     "weapons/stormgiant_metal1.wav",            // 8
  64.     "weapons/stormgiant_metal2.wav",            // 9
  65.     "weapons/stormgiant_stone1.wav",            // 10
  66.     "weapons/stormgiant_stone2.wav",            // 11
  67.     "weapons/stormgiant_wood1.wav",             // 12
  68.     "weapons/stormgiant_wood2.wav"              // 13
  69. };
  70.  
  71. #define SHOCK_SPRITE "sprites/ef_coilmg.spr"
  72.  
  73. enum _: e_HitResultList {
  74.     HIT_NONE = 0,
  75.     HIT_WORLD,
  76.     HIT_ENTITY
  77. };
  78.  
  79. #define KNIFE_ANIM_EXTENSION "knife"
  80.  
  81. #define DRAW_DAMAGE 390
  82. #define DRAW_DISTANCE 110
  83.  
  84. #define MIDSLASH1_DAMAGE 910
  85. #define MIDSLASH1_DISTANCE 130
  86.  
  87. #define MIDSLASH2_DAMAGE 700
  88. #define MIDSLASH2_DISTANCE 120
  89.  
  90. #define STORMGIANT_KNOCKBACK 750
  91. #define STORMGIANT_SPEED 380.0
  92.  
  93. new bool: g_bMelee[33],
  94.     bool: g_bWeaponState[33],
  95.     g_iSpriteIndex_Shock;
  96.  
  97. public plugin_init() {
  98.     register_plugin("Warhammer Storm Giant", "0.1", "inf");
  99.  
  100.     register_event("CurWeapon", "CurWeapon", "be", "1=1");
  101.  
  102.     register_forward(FM_UpdateClientData,   "FM_Hook_UpdateClientData", true);
  103.  
  104.     RegisterHam(Ham_Item_Deploy,            KNIFE_REFERENCE,    "CWeapon__Deploy", true);
  105.     RegisterHam(Ham_Item_PostFrame,         KNIFE_REFERENCE,    "CWeapon__PostFrame", false);
  106.     RegisterHam(Ham_Weapon_WeaponIdle,      KNIFE_REFERENCE,    "CWeapon__WeaponIdle", false);
  107.     RegisterHam(Ham_Weapon_PrimaryAttack,   KNIFE_REFERENCE,    "CWeapon__PrimaryAttack", false);
  108.     RegisterHam(Ham_Weapon_SecondaryAttack, KNIFE_REFERENCE,    "CWeapon__SecondaryAttack", false);
  109.  
  110. }
  111.  
  112. public plugin_precache() {
  113.     // Precache models
  114.     engfunc(EngFunc_PrecacheModel, KNIFE_MODEL_V);
  115.     engfunc(EngFunc_PrecacheModel, KNIFE_MODEL_P);
  116.  
  117.     // Precache sounds
  118.     for(new i = 0; i < sizeof KNIFE_SOUNDS; i++) engfunc(EngFunc_PrecacheSound, KNIFE_SOUNDS[i]);
  119.     UTIL_PrecacheSoundsFromModel(KNIFE_MODEL_V);
  120.  
  121.     // Other
  122.     g_iSpriteIndex_Shock = engfunc(EngFunc_PrecacheModel, SHOCK_SPRITE);
  123. }
  124. public plugin_natives()
  125. {
  126.     register_native("SetUserWarHammer", "Command_GiveMelee", 1);
  127.     register_native("DelUserWarHammer", "Remove_Melee", 1);
  128. }
  129.  
  130. public client_putinserver(iPlayer) Remove_Melee(iPlayer);
  131. public ze_user_infected(iPlayer) Remove_Melee(iPlayer);
  132. public Remove_Melee(iPlayer) {
  133.     g_bMelee[iPlayer] = false;
  134.     g_bWeaponState[iPlayer] = false;
  135. }
  136. //public GetWeapon(iPlayer, iItemID) if(iItemID == g_iItemID) Command_GiveMelee(iPlayer);//
  137.  
  138. public RemoveWeapon(iPlayer) Remove_Melee(iPlayer);
  139.  
  140. public Command_GiveMelee(iPlayer) {
  141.  
  142.     g_bMelee[iPlayer] = true;
  143.     g_bWeaponState[iPlayer] = false;
  144.  
  145.     static iItem; iItem = get_pdata_cbase(iPlayer, m_pActiveItem, linux_diff_player);
  146.  
  147.     ExecuteHamB(Ham_Item_Deploy, iItem);
  148.  
  149.     emit_sound(iPlayer, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  150. }
  151.  
  152. public CurWeapon(iPlayer) {
  153.     if(is_user_alive(iPlayer) && g_bMelee[iPlayer] && get_user_weapon(iPlayer) == CSW_KNIFE)
  154.         set_pev(iPlayer, pev_maxspeed, STORMGIANT_SPEED);
  155. }
  156.  
  157. public CWeapon__Deploy(iItem) {
  158.     static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
  159.  
  160.     if(g_bMelee[iPlayer] == false) return;
  161.  
  162.     g_bWeaponState[iPlayer] = true;
  163.  
  164.     set_pev(iPlayer, pev_viewmodel2, KNIFE_MODEL_V);
  165.     set_pev(iPlayer, pev_weaponmodel2, KNIFE_MODEL_P);
  166.  
  167.     UTIL_SendWeaponAnim(iPlayer, ANIM_DRAW_ATTACK);
  168.     emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  169.  
  170.     set_pdata_float(iPlayer, m_flNextAttack, 5/30.0, linux_diff_player);
  171.     set_pdata_float(iItem, m_flNextPrimaryAttack, TIME_DRAW_ATTACK, linux_diff_weapon);
  172.     set_pdata_float(iItem, m_flNextSecondaryAttack, 12/30.0, linux_diff_weapon);
  173.     set_pdata_float(iItem, m_flTimeWeaponIdle, TIME_DRAW_ATTACK, linux_diff_weapon);
  174.  
  175.     set_pdata_string(iPlayer, m_szAnimExtention * 4, KNIFE_ANIM_EXTENSION, -1, linux_diff_player * linux_diff_animating);
  176. }
  177.  
  178. public CWeapon__PostFrame(iItem) {
  179.     static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
  180.  
  181.     if(g_bMelee[iPlayer] == false) return HAM_IGNORED;
  182.  
  183.     if(g_bWeaponState[iPlayer] == true) {
  184.         g_bWeaponState[iPlayer] = false;
  185.  
  186.         switch(pev(iPlayer, pev_weaponanim)) {
  187.             case ANIM_DRAW_ATTACK: FakeTraceLine(iPlayer, float(DRAW_DAMAGE), float(DRAW_DISTANCE));
  188.             case ANIM_MIDSLASH1: {
  189.                 UTIL_SendWeaponAnim(iPlayer, ANIM_MIDSLASH1_HIT);
  190.                 set_pdata_float(iItem, m_flNextPrimaryAttack, 39/30.0, linux_diff_weapon);
  191.                 set_pdata_float(iItem, m_flNextSecondaryAttack, TIME_MIDSLASH1_HIT, linux_diff_weapon);
  192.                 set_pdata_float(iItem, m_flTimeWeaponIdle, TIME_MIDSLASH1_HIT, linux_diff_weapon);
  193.  
  194.                 FakeTraceLine(iPlayer, float(MIDSLASH1_DAMAGE), float(MIDSLASH1_DISTANCE));
  195.             }
  196.             case ANIM_MIDSLASH2: {
  197.                 set_pdata_float(iItem, m_flNextPrimaryAttack, TIME_MIDSLASH2_HIT, linux_diff_weapon);
  198.                 set_pdata_float(iItem, m_flNextSecondaryAttack, 19/30.0, linux_diff_weapon);
  199.                 set_pdata_float(iItem, m_flTimeWeaponIdle, TIME_MIDSLASH2_HIT, linux_diff_weapon);
  200.  
  201.                 FakeTraceLine(iPlayer, float(MIDSLASH2_DAMAGE), float(MIDSLASH2_DISTANCE));
  202.             }
  203.             case ANIM_MIDSLASH2_FAIL: FakeTraceLine(iPlayer, float(DRAW_DAMAGE), float(DRAW_DISTANCE));
  204.         }
  205.  
  206.         static szAnimation[64];
  207.         formatex(szAnimation, charsmax(szAnimation), pev(iPlayer, pev_flags) & FL_DUCKING ? "crouch_shoot_%s" : "ref_shoot_%s", KNIFE_ANIM_EXTENSION);
  208.         UTIL_PlayerAnimation(iPlayer, szAnimation);
  209.     }
  210.  
  211.     if(pev(iPlayer, pev_weaponanim) == ANIM_DRAW_ATTACK && get_pdata_float(iItem, m_flTimeWeaponIdle, linux_diff_weapon) <= 0.0) {
  212.         UTIL_SendWeaponAnim(iPlayer, ANIM_DRAW);
  213.         set_pdata_float(iPlayer, m_flNextAttack, TIME_DRAW, linux_diff_player);
  214.         set_pdata_float(iItem, m_flNextPrimaryAttack, TIME_DRAW, linux_diff_weapon);
  215.         set_pdata_float(iItem, m_flNextSecondaryAttack, TIME_DRAW, linux_diff_weapon);
  216.         set_pdata_float(iItem, m_flTimeWeaponIdle, TIME_DRAW, linux_diff_weapon);
  217.     }
  218.  
  219.     return HAM_IGNORED;
  220. }
  221.  
  222. public CWeapon__WeaponIdle(iItem) {
  223.     static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
  224.  
  225.     if(g_bMelee[iPlayer] == false || get_pdata_float(iItem, m_flTimeWeaponIdle, linux_diff_weapon) > 0.0) return HAM_IGNORED;
  226.  
  227.     UTIL_SendWeaponAnim(iPlayer, ANIM_IDLE);
  228.     set_pdata_float(iItem, m_flTimeWeaponIdle, TIME_IDLE, linux_diff_weapon);
  229.  
  230.     return HAM_SUPERCEDE;
  231. }
  232.  
  233. public CWeapon__PrimaryAttack(iItem) {
  234.     static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
  235.  
  236.     if(g_bMelee[iPlayer] == false) return HAM_IGNORED;
  237.  
  238.     g_bWeaponState[iPlayer] = true;
  239.  
  240.     UTIL_SendWeaponAnim(iPlayer, ANIM_MIDSLASH1);
  241.     emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[3], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  242.  
  243.     set_pdata_float(iPlayer, m_flNextAttack, TIME_MIDSLASH1, linux_diff_player);
  244.     set_pdata_float(iItem, m_flNextPrimaryAttack, TIME_MIDSLASH1, linux_diff_weapon);
  245.     set_pdata_float(iItem, m_flNextSecondaryAttack, TIME_MIDSLASH1, linux_diff_weapon);
  246.     set_pdata_float(iItem, m_flTimeWeaponIdle, TIME_MIDSLASH1, linux_diff_weapon);
  247.  
  248.     return HAM_SUPERCEDE;
  249. }
  250.  
  251. public CWeapon__SecondaryAttack(iItem) {
  252.     static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
  253.  
  254.     if(g_bMelee[iPlayer] == false) return HAM_IGNORED;
  255.  
  256.     g_bWeaponState[iPlayer] = true;
  257.  
  258.     UTIL_SendWeaponAnim(iPlayer, pev(iPlayer, pev_weaponanim) == ANIM_DRAW_ATTACK ? ANIM_MIDSLASH2_FAIL : ANIM_MIDSLASH2);
  259.     set_pdata_float(iPlayer, m_flNextAttack, pev(iPlayer, pev_weaponanim) == ANIM_MIDSLASH2_FAIL ? 1/30.0 : TIME_MIDSLASH2, linux_diff_player);
  260.     set_pdata_float(iItem, m_flNextPrimaryAttack, pev(iPlayer, pev_weaponanim) == ANIM_MIDSLASH2_FAIL ? TIME_MIDSLASH2_HIT : TIME_MIDSLASH2, linux_diff_weapon);
  261.     set_pdata_float(iItem, m_flNextSecondaryAttack, pev(iPlayer, pev_weaponanim) == ANIM_MIDSLASH2_FAIL ? TIME_MIDSLASH2_HIT : TIME_MIDSLASH2, linux_diff_weapon);
  262.     set_pdata_float(iItem, m_flTimeWeaponIdle, pev(iPlayer, pev_weaponanim) == ANIM_MIDSLASH2_FAIL ? TIME_MIDSLASH2_HIT : TIME_MIDSLASH2, linux_diff_weapon);
  263.  
  264.     return HAM_SUPERCEDE;
  265. }
  266.  
  267. public FM_Hook_UpdateClientData(iPlayer, SendWeapons, CD_Handle) {
  268.     if(get_cd(CD_Handle, CD_DeadFlag) != DEAD_NO) return;
  269.     if(get_user_weapon(iPlayer) == CSW_KNIFE && g_bMelee[iPlayer] == true) set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001);
  270. }
  271.  
  272. public FakeTraceLine(iPlayer, Float: flDamage, Float: flDistance) {
  273.     new Float: flOrigin[3], Float: flAngle[3], Float: flEnd[3], Float: flViewOfs[3];
  274.     new Float: flForw[3], Float: flUp[3], Float: flRight[3];
  275.  
  276.     pev(iPlayer, pev_origin, flOrigin);
  277.     pev(iPlayer, pev_view_ofs, flViewOfs);
  278.  
  279.     flOrigin[0] += flViewOfs[0];
  280.     flOrigin[1] += flViewOfs[1];
  281.     flOrigin[2] += flViewOfs[2];
  282.            
  283.     pev(iPlayer, pev_v_angle, flAngle);
  284.     engfunc(EngFunc_AngleVectors, flAngle, flForw, flRight, flUp);
  285.            
  286.     new iTrace = create_tr2();
  287.  
  288.     new Float: flSendAngles[] = { 0.0, 10.0, -10.0 }
  289.     new Float: flSendAnglesUp[] = { 0.0, 0.0, 0.0 }
  290.  
  291.     new Float: flTan;
  292.     new Float: flMul;
  293.  
  294.     static Float: flFraction, pHit;
  295.     static pHitEntity; pHitEntity = HIT_NONE;
  296.     static iHitResult; iHitResult = HIT_NONE;
  297.  
  298.     for(new i; i < sizeof flSendAngles; i++) {
  299.         flTan = floattan(flSendAngles[i], degrees);
  300.  
  301.         flEnd[0] = (flForw[0] * flDistance) + (flRight[0] * flTan * flDistance) + flUp[0] * flSendAnglesUp[i];
  302.         flEnd[1] = (flForw[1] * flDistance) + (flRight[1] * flTan * flDistance) + flUp[1] * flSendAnglesUp[i];
  303.         flEnd[2] = (flForw[2] * flDistance) + (flRight[2] * flTan * flDistance) + flUp[2] * flSendAnglesUp[i];
  304.            
  305.         flMul = (flDistance / vector_length(flEnd));
  306.         flEnd[0] *= flMul;
  307.         flEnd[1] *= flMul;
  308.         flEnd[2] *= flMul;
  309.  
  310.         flEnd[0] = flEnd[0] + flOrigin[0];
  311.         flEnd[1] = flEnd[1] + flOrigin[1];
  312.         flEnd[2] = flEnd[2] + flOrigin[2];
  313.  
  314.         engfunc(EngFunc_TraceLine, flOrigin, flEnd, DONT_IGNORE_MONSTERS, iPlayer, iTrace);
  315.         get_tr2(iTrace, TR_flFraction, flFraction);
  316.  
  317.         if(flFraction == 1.0) {
  318.             engfunc(EngFunc_TraceHull, flOrigin, flEnd, HULL_HEAD, iPlayer, iTrace);
  319.             get_tr2(iTrace, TR_flFraction, flFraction);
  320.        
  321.             engfunc(EngFunc_TraceLine, flOrigin, flEnd, DONT_IGNORE_MONSTERS, iPlayer, iTrace);
  322.             pHit = get_tr2(iTrace, TR_pHit);
  323.         }
  324.         else pHit = get_tr2(iTrace, TR_pHit);
  325.  
  326.         if(flFraction != 1.0) {
  327.             if(!iHitResult) {
  328.                 iHitResult = HIT_WORLD;
  329.  
  330.                 new Float: vecEndPos[3]; get_tr2(iTrace, TR_vecEndPos, vecEndPos);
  331.                 UTIL_ShockEffect(vecEndPos);
  332.             }
  333.         }
  334.  
  335.         if(pHit > 0 && pHitEntity != pHit) {
  336.             if(pev(pHit, pev_solid) == SOLID_BSP && !(pev(pHit, pev_spawnflags) & SF_BREAK_TRIGGER_ONLY)) ExecuteHamB(Ham_TakeDamage, pHit, iPlayer, iPlayer, flDamage, DMG_CLUB);
  337.             else {
  338.                 FakeTraceAttack(pHit, iPlayer, flDamage, flForw, iTrace, DMG_CLUB);
  339.                 if(pev(iPlayer, pev_weaponanim) == ANIM_MIDSLASH2_FAIL) {
  340.                     if(is_user_alive(pHit) && ze_is_user_zombie(pHit)) {
  341.                         new iKnockBack = STORMGIANT_KNOCKBACK;
  342.                         if(pev(pHit, pev_flags) & (FL_DUCKING | FL_ONGROUND) == (FL_DUCKING | FL_ONGROUND)) iKnockBack = (iKnockBack / 3);
  343.  
  344.                         new Float: vecVelocity[3]; pev(pHit, pev_velocity, vecVelocity);
  345.                         new Float: vecKnockBack[3]; velocity_by_aim(iPlayer, iKnockBack, vecKnockBack);
  346.  
  347.                         vecVelocity[2] += 200.0;
  348.                         vecKnockBack[2] = vecVelocity[2];
  349.  
  350.                         set_pev(pHit, pev_velocity, vecKnockBack);
  351.  
  352.                         set_pdata_float(pHit, m_flPainShock, 1.0, linux_diff_player);
  353.                     }
  354.                 }
  355.             }
  356.  
  357.             iHitResult = HIT_ENTITY;
  358.             pHitEntity = pHit;
  359.  
  360.             if(iHitResult != HIT_ENTITY) {
  361.                 new Float: vecEndPos[3]; get_tr2(iTrace, TR_vecEndPos, vecEndPos);
  362.                 UTIL_ShockEffect(vecEndPos);
  363.             }
  364.         }
  365.     }
  366.  
  367.     free_tr2(iTrace);
  368.  
  369.     switch(iHitResult) {
  370.         case HIT_NONE: {
  371.             switch(pev(iPlayer, pev_weaponanim)) {
  372.                 case ANIM_MIDSLASH1_HIT: emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[4], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  373.                 case ANIM_MIDSLASH2: {
  374.                     UTIL_SendWeaponAnim(iPlayer, ANIM_MIDSLASH2_FAIL);
  375.                     emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[6], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  376.                 }
  377.                 case ANIM_MIDSLASH2_FAIL: emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[6], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  378.             }
  379.         }
  380.         case HIT_WORLD: {
  381.             if(pev(iPlayer, pev_weaponanim) == ANIM_MIDSLASH2) UTIL_SendWeaponAnim(iPlayer, ANIM_MIDSLASH2_HIT);
  382.             emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[random_num(8, 13)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  383.         }
  384.         case HIT_ENTITY: {
  385.             switch(pev(iPlayer, pev_weaponanim)) {
  386.                 case ANIM_DRAW_ATTACK: emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[1], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  387.                 case ANIM_MIDSLASH1_HIT: {
  388.                     emit_sound(iPlayer, CHAN_ITEM, KNIFE_SOUNDS[5], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  389.                     emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[1], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  390.                 }
  391.                 case ANIM_MIDSLASH2: {
  392.                     UTIL_SendWeaponAnim(iPlayer, ANIM_MIDSLASH2_HIT);
  393.                     emit_sound(iPlayer, CHAN_ITEM, KNIFE_SOUNDS[7], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  394.                     emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[2], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  395.                 }
  396.                 case ANIM_MIDSLASH2_FAIL: {
  397.                     emit_sound(iPlayer, CHAN_ITEM, KNIFE_SOUNDS[6], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  398.                     emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[2], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  399.                 }
  400.             }
  401.         }
  402.     }
  403. }
  404.  
  405. public FakeTraceAttack(iVictim, iAttacker, Float: flDamage, Float: vecDirection[3], iTrace, iDamageBits) {
  406.     static Float: flTakeDamage; pev(iVictim, pev_takedamage, flTakeDamage);
  407.  
  408.     if(flTakeDamage == DAMAGE_NO) return PLUGIN_CONTINUE;
  409.     if(!is_user_alive(iVictim)) return PLUGIN_CONTINUE;
  410.  
  411.     if(is_user_connected(iVictim)) if(iVictim == iAttacker) return PLUGIN_CONTINUE;
  412.  
  413.     static iHitgroup; iHitgroup = get_tr2(iTrace, TR_iHitgroup);
  414.     static Float: vecEndPos[3]; get_tr2(iTrace, TR_vecEndPos, vecEndPos);
  415.    
  416.     set_pdata_int(iVictim, m_LastHitGroup, iHitgroup, linux_diff_player);
  417.  
  418.     switch(iHitgroup) {
  419.         case HIT_HEAD:                  flDamage *= random_float(1.0, 2.0);
  420.         case HIT_LEFTARM, HIT_RIGHTARM: flDamage *= random_float(0.5, 1.0);
  421.         case HIT_LEFTLEG, HIT_RIGHTLEG: flDamage *= random_float(0.5, 1.0);
  422.         case HIT_STOMACH:               flDamage *= random_float(0.5, 1.0);
  423.     }
  424.    
  425.     ExecuteHamB(Ham_TakeDamage, iVictim, iAttacker, iAttacker, flDamage, iDamageBits);
  426.    
  427.     if(ze_is_user_zombie(iVictim)) {
  428.         UTIL_BloodDrips(iVictim, vecEndPos, floatround(flDamage));
  429.         set_pdata_float(iVictim, m_flPainShock, 0.75, linux_diff_player);
  430.     }
  431.  
  432.     return PLUGIN_HANDLED;
  433. }
  434.  
  435. stock UTIL_ShockEffect(Float: vecOrigin[3]) {
  436.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecOrigin, 0);
  437.     write_byte(TE_EXPLOSION);
  438.     engfunc(EngFunc_WriteCoord, vecOrigin[0]);
  439.     engfunc(EngFunc_WriteCoord, vecOrigin[1]);
  440.     engfunc(EngFunc_WriteCoord, vecOrigin[2]);
  441.     write_short(g_iSpriteIndex_Shock);
  442.     write_byte(3);
  443.     write_byte(15);
  444.     write_byte(TE_EXPLFLAG_NODLIGHTS|TE_EXPLFLAG_NOSOUND|TE_EXPLFLAG_NOPARTICLES);
  445.     message_end();
  446. }
  447. stock UTIL_BloodDrips(iVictim, Float: vecOrigin[3], iAmount) {
  448.     if(iAmount > 255) iAmount = 255;
  449.    
  450.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecOrigin, 0);
  451.     write_byte(TE_BLOODSPRITE);
  452.     engfunc(EngFunc_WriteCoord, vecOrigin[0]);
  453.     engfunc(EngFunc_WriteCoord, vecOrigin[1]);
  454.     engfunc(EngFunc_WriteCoord, vecOrigin[2]);
  455.     write_short(engfunc(EngFunc_PrecacheModel, "sprites/bloodspray.spr"));
  456.     write_short(engfunc(EngFunc_PrecacheModel, "sprites/blood.spr"));
  457.     write_byte(ExecuteHamB(Ham_BloodColor, iVictim));
  458.     write_byte(min(max(3, iAmount / 10), 16));
  459.     message_end();
  460. }
  461. stock UTIL_PlayerAnimation(iPlayer, szAnim[]) {
  462.     new iAnimDesired, Float: flFrameRate, Float: flGroundSpeed, bool: bLoops;
  463.        
  464.     if((iAnimDesired = lookup_sequence(iPlayer, szAnim, flFrameRate, bLoops, flGroundSpeed)) == -1) iAnimDesired = 0;
  465.  
  466.     set_pev(iPlayer, pev_frame, 0.0);
  467.     set_pev(iPlayer, pev_framerate, 1.0);
  468.     set_pev(iPlayer, pev_animtime, get_gametime());
  469.     set_pev(iPlayer, pev_sequence, iAnimDesired);
  470.    
  471.     set_pdata_int(iPlayer, 40, bLoops, linux_diff_animating);
  472.     set_pdata_int(iPlayer, 39, 0, linux_diff_animating);
  473.    
  474.     set_pdata_float(iPlayer, 36, flFrameRate, linux_diff_animating);
  475.     set_pdata_float(iPlayer, 37, flGroundSpeed, linux_diff_animating);
  476.     set_pdata_float(iPlayer, 38, get_gametime(), linux_diff_animating);
  477.    
  478.     set_pdata_int(iPlayer, 73, 28, linux_diff_player);
  479.     set_pdata_int(iPlayer, 74, 28, linux_diff_player);
  480.     set_pdata_float(iPlayer, 220, get_gametime(), linux_diff_player);
  481. }
  482. stock UTIL_SendWeaponAnim(iPlayer, iAnim, iBody = 0) {
  483.     set_pev(iPlayer, pev_weaponanim, iAnim);
  484.  
  485.     message_begin(MSG_ONE, SVC_WEAPONANIM, _, iPlayer);
  486.     write_byte(iAnim);
  487.     write_byte(iBody);
  488.     message_end();
  489. }
  490. stock UTIL_PrecacheSoundsFromModel(const szModelPath[]) {
  491.     new iFile;
  492.    
  493.     if((iFile = fopen(szModelPath, "rt"))) {
  494.         new szSoundPath[64];
  495.        
  496.         new iNumSeq, iSeqIndex;
  497.         new iEvent, iNumEvents, iEventIndex;
  498.        
  499.         fseek(iFile, 164, SEEK_SET);
  500.         fread(iFile, iNumSeq, BLOCK_INT);
  501.         fread(iFile, iSeqIndex, BLOCK_INT);
  502.        
  503.         for(new k, i = 0; i < iNumSeq; i++) {
  504.             fseek(iFile, iSeqIndex + 48 + 176 * i, SEEK_SET);
  505.             fread(iFile, iNumEvents, BLOCK_INT);
  506.             fread(iFile, iEventIndex, BLOCK_INT);
  507.             fseek(iFile, iEventIndex + 176 * i, SEEK_SET);
  508.            
  509.             for(k = 0; k < iNumEvents; k++) {
  510.                 fseek(iFile, iEventIndex + 4 + 76 * k, SEEK_SET);
  511.                 fread(iFile, iEvent, BLOCK_INT);
  512.                 fseek(iFile, 4, SEEK_CUR);
  513.                
  514.                 if(iEvent != 5004) continue;
  515.                
  516.                 fread_blocks(iFile, szSoundPath, 64, BLOCK_CHAR);
  517.                
  518.                 if(strlen(szSoundPath)) {
  519.                     strtolower(szSoundPath);
  520.                     engfunc(EngFunc_PrecacheSound, szSoundPath);
  521.                 }
  522.             }
  523.         }
  524.     }
  525.    
  526.     fclose(iFile);
  527. }
Image

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

#2

Post by Muhammet20 » 2 Months Ago

czirimbolo wrote:
2 Months Ago
Hey, when I pick up this knife, I can walk if freeze time. Can someone tell me how to fix this?
  1. #pragma compress 1
  2.  
  3. #include <zombie_escape>
  4. #include <fakemeta_util>
  5.  
  6.  
  7. #define CustomItem(%0) (pev(%0, pev_impulse) == WEAPON_SPECIAL_CODE)
  8.  
  9. // Linux extra offsets
  10. #define linux_diff_animating 4
  11. #define linux_diff_weapon 4
  12. #define linux_diff_player 5
  13.  
  14. // CBasePlayerItem
  15. #define m_pPlayer 41
  16.  
  17. // CBasePlayerWeapon
  18. #define m_flNextPrimaryAttack 46
  19. #define m_flNextSecondaryAttack 47
  20. #define m_flTimeWeaponIdle 48
  21.  
  22. // CBaseMonster
  23. #define m_LastHitGroup 75
  24. #define m_flNextAttack 83
  25.  
  26. // CBasePlayer
  27. #define m_flPainShock 108
  28. #define m_pActiveItem 373
  29. #define m_szAnimExtention 492
  30.  
  31. // from model: Frames / FPS
  32. #define TIME_IDLE 401/30.0
  33. #define TIME_DRAW_ATTACK 16/30.0
  34. #define TIME_DRAW 31/30.0
  35. #define TIME_MIDSLASH1 33/30.0
  36. #define TIME_MIDSLASH1_HIT 69/30.0
  37. #define TIME_MIDSLASH2 29/30.0
  38. #define TIME_MIDSLASH2_HIT 43/30.0
  39.  
  40. #define ANIM_IDLE 0
  41. #define ANIM_DRAW_ATTACK 1
  42. #define ANIM_DRAW 3
  43. #define ANIM_MIDSLASH1 4
  44. #define ANIM_MIDSLASH1_HIT 5
  45. #define ANIM_MIDSLASH2 7
  46. #define ANIM_MIDSLASH2_HIT 8
  47. #define ANIM_MIDSLASH2_FAIL 9
  48.  
  49. #define KNIFE_REFERENCE "weapon_knife"
  50.  
  51. #define KNIFE_MODEL_V "models/v_stormgiant.mdl"
  52. #define KNIFE_MODEL_P "models/p_stormgiant.mdl"
  53.  
  54. new const KNIFE_SOUNDS[][] = {
  55.     "weapons/stormgiant_attack_hit2.wav",       // 0
  56.     "weapons/stormgiant_hit1.wav",              // 1
  57.     "weapons/stormgiant_hit2.wav",              // 2
  58.     "weapons/stormgiant_midslash1.wav",         // 3
  59.     "weapons/stormgiant_midslash1_fail.wav",    // 4
  60.     "weapons/stormgiant_midslash1_hit.wav",     // 5
  61.     "weapons/stormgiant_midslash2_fail.wav",    // 6
  62.     "weapons/stormgiant_midslash2_hit.wav",     // 7
  63.     "weapons/stormgiant_metal1.wav",            // 8
  64.     "weapons/stormgiant_metal2.wav",            // 9
  65.     "weapons/stormgiant_stone1.wav",            // 10
  66.     "weapons/stormgiant_stone2.wav",            // 11
  67.     "weapons/stormgiant_wood1.wav",             // 12
  68.     "weapons/stormgiant_wood2.wav"              // 13
  69. };
  70.  
  71. #define SHOCK_SPRITE "sprites/ef_coilmg.spr"
  72.  
  73. enum _: e_HitResultList {
  74.     HIT_NONE = 0,
  75.     HIT_WORLD,
  76.     HIT_ENTITY
  77. };
  78.  
  79. #define KNIFE_ANIM_EXTENSION "knife"
  80.  
  81. #define DRAW_DAMAGE 390
  82. #define DRAW_DISTANCE 110
  83.  
  84. #define MIDSLASH1_DAMAGE 910
  85. #define MIDSLASH1_DISTANCE 130
  86.  
  87. #define MIDSLASH2_DAMAGE 700
  88. #define MIDSLASH2_DISTANCE 120
  89.  
  90. #define STORMGIANT_KNOCKBACK 750
  91. #define STORMGIANT_SPEED 380.0
  92.  
  93. new bool: g_bMelee[33],
  94.     bool: g_bWeaponState[33],
  95.     g_iSpriteIndex_Shock;
  96.  
  97. new g_freezetime
  98. public plugin_init() {
  99.     register_plugin("Warhammer Storm Giant", "0.1", "inf");
  100.  
  101.     register_event("CurWeapon", "CurWeapon", "be", "1=1");
  102.     register_event("HLTV", "event_newround", "a", "1=0", "2=0")
  103.  
  104.     register_forward(FM_UpdateClientData,   "FM_Hook_UpdateClientData", true);
  105.  
  106.     RegisterHam(Ham_Item_Deploy,            KNIFE_REFERENCE,    "CWeapon__Deploy", true);
  107.     RegisterHam(Ham_Item_PostFrame,         KNIFE_REFERENCE,    "CWeapon__PostFrame", false);
  108.     RegisterHam(Ham_Weapon_WeaponIdle,      KNIFE_REFERENCE,    "CWeapon__WeaponIdle", false);
  109.     RegisterHam(Ham_Weapon_PrimaryAttack,   KNIFE_REFERENCE,    "CWeapon__PrimaryAttack", false);
  110.     RegisterHam(Ham_Weapon_SecondaryAttack, KNIFE_REFERENCE,    "CWeapon__SecondaryAttack", false);
  111.  
  112. }
  113. public event_newround(id)
  114. {
  115.     g_freezetime = true
  116. }
  117. public ze_zombie_appear()
  118. {
  119.     g_freezetime = false
  120. }
  121. public plugin_precache() {
  122.     // Precache models
  123.     engfunc(EngFunc_PrecacheModel, KNIFE_MODEL_V);
  124.     engfunc(EngFunc_PrecacheModel, KNIFE_MODEL_P);
  125.  
  126.     // Precache sounds
  127.     for(new i = 0; i < sizeof KNIFE_SOUNDS; i++) engfunc(EngFunc_PrecacheSound, KNIFE_SOUNDS[i]);
  128.     UTIL_PrecacheSoundsFromModel(KNIFE_MODEL_V);
  129.  
  130.     // Other
  131.     g_iSpriteIndex_Shock = engfunc(EngFunc_PrecacheModel, SHOCK_SPRITE);
  132. }
  133. public plugin_natives()
  134. {
  135.     register_native("SetUserWarHammer", "Command_GiveMelee", 1);
  136.     register_native("DelUserWarHammer", "Remove_Melee", 1);
  137. }
  138.  
  139. public client_putinserver(iPlayer) Remove_Melee(iPlayer);
  140. public ze_user_infected(iPlayer) Remove_Melee(iPlayer);
  141. public Remove_Melee(iPlayer) {
  142.     g_bMelee[iPlayer] = false;
  143.     g_bWeaponState[iPlayer] = false;
  144. }
  145. //public GetWeapon(iPlayer, iItemID) if(iItemID == g_iItemID) Command_GiveMelee(iPlayer);//
  146.  
  147. public RemoveWeapon(iPlayer) Remove_Melee(iPlayer);
  148.  
  149. public Command_GiveMelee(iPlayer) {
  150.  
  151.     g_bMelee[iPlayer] = true;
  152.     g_bWeaponState[iPlayer] = false;
  153.  
  154.     static iItem; iItem = get_pdata_cbase(iPlayer, m_pActiveItem, linux_diff_player);
  155.  
  156.     ExecuteHamB(Ham_Item_Deploy, iItem);
  157.  
  158.     emit_sound(iPlayer, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  159. }
  160.  
  161. public CurWeapon(iPlayer) {
  162.     if(is_user_alive(iPlayer) && g_bMelee[iPlayer] && get_user_weapon(iPlayer) == CSW_KNIFE && !g_freezetime)
  163.         set_pev(iPlayer, pev_maxspeed, STORMGIANT_SPEED);
  164. }
  165.  
  166. public CWeapon__Deploy(iItem) {
  167.     static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
  168.  
  169.     if(g_bMelee[iPlayer] == false) return;
  170.  
  171.     g_bWeaponState[iPlayer] = true;
  172.  
  173.     set_pev(iPlayer, pev_viewmodel2, KNIFE_MODEL_V);
  174.     set_pev(iPlayer, pev_weaponmodel2, KNIFE_MODEL_P);
  175.  
  176.     UTIL_SendWeaponAnim(iPlayer, ANIM_DRAW_ATTACK);
  177.     emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  178.  
  179.     set_pdata_float(iPlayer, m_flNextAttack, 5/30.0, linux_diff_player);
  180.     set_pdata_float(iItem, m_flNextPrimaryAttack, TIME_DRAW_ATTACK, linux_diff_weapon);
  181.     set_pdata_float(iItem, m_flNextSecondaryAttack, 12/30.0, linux_diff_weapon);
  182.     set_pdata_float(iItem, m_flTimeWeaponIdle, TIME_DRAW_ATTACK, linux_diff_weapon);
  183.  
  184.     set_pdata_string(iPlayer, m_szAnimExtention * 4, KNIFE_ANIM_EXTENSION, -1, linux_diff_player * linux_diff_animating);
  185. }
  186.  
  187. public CWeapon__PostFrame(iItem) {
  188.     static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
  189.  
  190.     if(g_bMelee[iPlayer] == false) return HAM_IGNORED;
  191.  
  192.     if(g_bWeaponState[iPlayer] == true) {
  193.         g_bWeaponState[iPlayer] = false;
  194.  
  195.         switch(pev(iPlayer, pev_weaponanim)) {
  196.             case ANIM_DRAW_ATTACK: FakeTraceLine(iPlayer, float(DRAW_DAMAGE), float(DRAW_DISTANCE));
  197.             case ANIM_MIDSLASH1: {
  198.                 UTIL_SendWeaponAnim(iPlayer, ANIM_MIDSLASH1_HIT);
  199.                 set_pdata_float(iItem, m_flNextPrimaryAttack, 39/30.0, linux_diff_weapon);
  200.                 set_pdata_float(iItem, m_flNextSecondaryAttack, TIME_MIDSLASH1_HIT, linux_diff_weapon);
  201.                 set_pdata_float(iItem, m_flTimeWeaponIdle, TIME_MIDSLASH1_HIT, linux_diff_weapon);
  202.  
  203.                 FakeTraceLine(iPlayer, float(MIDSLASH1_DAMAGE), float(MIDSLASH1_DISTANCE));
  204.             }
  205.             case ANIM_MIDSLASH2: {
  206.                 set_pdata_float(iItem, m_flNextPrimaryAttack, TIME_MIDSLASH2_HIT, linux_diff_weapon);
  207.                 set_pdata_float(iItem, m_flNextSecondaryAttack, 19/30.0, linux_diff_weapon);
  208.                 set_pdata_float(iItem, m_flTimeWeaponIdle, TIME_MIDSLASH2_HIT, linux_diff_weapon);
  209.  
  210.                 FakeTraceLine(iPlayer, float(MIDSLASH2_DAMAGE), float(MIDSLASH2_DISTANCE));
  211.             }
  212.             case ANIM_MIDSLASH2_FAIL: FakeTraceLine(iPlayer, float(DRAW_DAMAGE), float(DRAW_DISTANCE));
  213.         }
  214.  
  215.         static szAnimation[64];
  216.         formatex(szAnimation, charsmax(szAnimation), pev(iPlayer, pev_flags) & FL_DUCKING ? "crouch_shoot_%s" : "ref_shoot_%s", KNIFE_ANIM_EXTENSION);
  217.         UTIL_PlayerAnimation(iPlayer, szAnimation);
  218.     }
  219.  
  220.     if(pev(iPlayer, pev_weaponanim) == ANIM_DRAW_ATTACK && get_pdata_float(iItem, m_flTimeWeaponIdle, linux_diff_weapon) <= 0.0) {
  221.         UTIL_SendWeaponAnim(iPlayer, ANIM_DRAW);
  222.         set_pdata_float(iPlayer, m_flNextAttack, TIME_DRAW, linux_diff_player);
  223.         set_pdata_float(iItem, m_flNextPrimaryAttack, TIME_DRAW, linux_diff_weapon);
  224.         set_pdata_float(iItem, m_flNextSecondaryAttack, TIME_DRAW, linux_diff_weapon);
  225.         set_pdata_float(iItem, m_flTimeWeaponIdle, TIME_DRAW, linux_diff_weapon);
  226.     }
  227.  
  228.     return HAM_IGNORED;
  229. }
  230.  
  231. public CWeapon__WeaponIdle(iItem) {
  232.     static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
  233.  
  234.     if(g_bMelee[iPlayer] == false || get_pdata_float(iItem, m_flTimeWeaponIdle, linux_diff_weapon) > 0.0) return HAM_IGNORED;
  235.  
  236.     UTIL_SendWeaponAnim(iPlayer, ANIM_IDLE);
  237.     set_pdata_float(iItem, m_flTimeWeaponIdle, TIME_IDLE, linux_diff_weapon);
  238.  
  239.     return HAM_SUPERCEDE;
  240. }
  241.  
  242. public CWeapon__PrimaryAttack(iItem) {
  243.     static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
  244.  
  245.     if(g_bMelee[iPlayer] == false) return HAM_IGNORED;
  246.  
  247.     g_bWeaponState[iPlayer] = true;
  248.  
  249.     UTIL_SendWeaponAnim(iPlayer, ANIM_MIDSLASH1);
  250.     emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[3], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  251.  
  252.     set_pdata_float(iPlayer, m_flNextAttack, TIME_MIDSLASH1, linux_diff_player);
  253.     set_pdata_float(iItem, m_flNextPrimaryAttack, TIME_MIDSLASH1, linux_diff_weapon);
  254.     set_pdata_float(iItem, m_flNextSecondaryAttack, TIME_MIDSLASH1, linux_diff_weapon);
  255.     set_pdata_float(iItem, m_flTimeWeaponIdle, TIME_MIDSLASH1, linux_diff_weapon);
  256.  
  257.     return HAM_SUPERCEDE;
  258. }
  259.  
  260. public CWeapon__SecondaryAttack(iItem) {
  261.     static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
  262.  
  263.     if(g_bMelee[iPlayer] == false) return HAM_IGNORED;
  264.  
  265.     g_bWeaponState[iPlayer] = true;
  266.  
  267.     UTIL_SendWeaponAnim(iPlayer, pev(iPlayer, pev_weaponanim) == ANIM_DRAW_ATTACK ? ANIM_MIDSLASH2_FAIL : ANIM_MIDSLASH2);
  268.     set_pdata_float(iPlayer, m_flNextAttack, pev(iPlayer, pev_weaponanim) == ANIM_MIDSLASH2_FAIL ? 1/30.0 : TIME_MIDSLASH2, linux_diff_player);
  269.     set_pdata_float(iItem, m_flNextPrimaryAttack, pev(iPlayer, pev_weaponanim) == ANIM_MIDSLASH2_FAIL ? TIME_MIDSLASH2_HIT : TIME_MIDSLASH2, linux_diff_weapon);
  270.     set_pdata_float(iItem, m_flNextSecondaryAttack, pev(iPlayer, pev_weaponanim) == ANIM_MIDSLASH2_FAIL ? TIME_MIDSLASH2_HIT : TIME_MIDSLASH2, linux_diff_weapon);
  271.     set_pdata_float(iItem, m_flTimeWeaponIdle, pev(iPlayer, pev_weaponanim) == ANIM_MIDSLASH2_FAIL ? TIME_MIDSLASH2_HIT : TIME_MIDSLASH2, linux_diff_weapon);
  272.  
  273.     return HAM_SUPERCEDE;
  274. }
  275.  
  276. public FM_Hook_UpdateClientData(iPlayer, SendWeapons, CD_Handle) {
  277.     if(get_cd(CD_Handle, CD_DeadFlag) != DEAD_NO) return;
  278.     if(get_user_weapon(iPlayer) == CSW_KNIFE && g_bMelee[iPlayer] == true) set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001);
  279. }
  280.  
  281. public FakeTraceLine(iPlayer, Float: flDamage, Float: flDistance) {
  282.     new Float: flOrigin[3], Float: flAngle[3], Float: flEnd[3], Float: flViewOfs[3];
  283.     new Float: flForw[3], Float: flUp[3], Float: flRight[3];
  284.  
  285.     pev(iPlayer, pev_origin, flOrigin);
  286.     pev(iPlayer, pev_view_ofs, flViewOfs);
  287.  
  288.     flOrigin[0] += flViewOfs[0];
  289.     flOrigin[1] += flViewOfs[1];
  290.     flOrigin[2] += flViewOfs[2];
  291.            
  292.     pev(iPlayer, pev_v_angle, flAngle);
  293.     engfunc(EngFunc_AngleVectors, flAngle, flForw, flRight, flUp);
  294.            
  295.     new iTrace = create_tr2();
  296.  
  297.     new Float: flSendAngles[] = { 0.0, 10.0, -10.0 }
  298.     new Float: flSendAnglesUp[] = { 0.0, 0.0, 0.0 }
  299.  
  300.     new Float: flTan;
  301.     new Float: flMul;
  302.  
  303.     static Float: flFraction, pHit;
  304.     static pHitEntity; pHitEntity = HIT_NONE;
  305.     static iHitResult; iHitResult = HIT_NONE;
  306.  
  307.     for(new i; i < sizeof flSendAngles; i++) {
  308.         flTan = floattan(flSendAngles[i], degrees);
  309.  
  310.         flEnd[0] = (flForw[0] * flDistance) + (flRight[0] * flTan * flDistance) + flUp[0] * flSendAnglesUp[i];
  311.         flEnd[1] = (flForw[1] * flDistance) + (flRight[1] * flTan * flDistance) + flUp[1] * flSendAnglesUp[i];
  312.         flEnd[2] = (flForw[2] * flDistance) + (flRight[2] * flTan * flDistance) + flUp[2] * flSendAnglesUp[i];
  313.            
  314.         flMul = (flDistance / vector_length(flEnd));
  315.         flEnd[0] *= flMul;
  316.         flEnd[1] *= flMul;
  317.         flEnd[2] *= flMul;
  318.  
  319.         flEnd[0] = flEnd[0] + flOrigin[0];
  320.         flEnd[1] = flEnd[1] + flOrigin[1];
  321.         flEnd[2] = flEnd[2] + flOrigin[2];
  322.  
  323.         engfunc(EngFunc_TraceLine, flOrigin, flEnd, DONT_IGNORE_MONSTERS, iPlayer, iTrace);
  324.         get_tr2(iTrace, TR_flFraction, flFraction);
  325.  
  326.         if(flFraction == 1.0) {
  327.             engfunc(EngFunc_TraceHull, flOrigin, flEnd, HULL_HEAD, iPlayer, iTrace);
  328.             get_tr2(iTrace, TR_flFraction, flFraction);
  329.        
  330.             engfunc(EngFunc_TraceLine, flOrigin, flEnd, DONT_IGNORE_MONSTERS, iPlayer, iTrace);
  331.             pHit = get_tr2(iTrace, TR_pHit);
  332.         }
  333.         else pHit = get_tr2(iTrace, TR_pHit);
  334.  
  335.         if(flFraction != 1.0) {
  336.             if(!iHitResult) {
  337.                 iHitResult = HIT_WORLD;
  338.  
  339.                 new Float: vecEndPos[3]; get_tr2(iTrace, TR_vecEndPos, vecEndPos);
  340.                 UTIL_ShockEffect(vecEndPos);
  341.             }
  342.         }
  343.  
  344.         if(pHit > 0 && pHitEntity != pHit) {
  345.             if(pev(pHit, pev_solid) == SOLID_BSP && !(pev(pHit, pev_spawnflags) & SF_BREAK_TRIGGER_ONLY)) ExecuteHamB(Ham_TakeDamage, pHit, iPlayer, iPlayer, flDamage, DMG_CLUB);
  346.             else {
  347.                 FakeTraceAttack(pHit, iPlayer, flDamage, flForw, iTrace, DMG_CLUB);
  348.                 if(pev(iPlayer, pev_weaponanim) == ANIM_MIDSLASH2_FAIL) {
  349.                     if(is_user_alive(pHit) && ze_is_user_zombie(pHit)) {
  350.                         new iKnockBack = STORMGIANT_KNOCKBACK;
  351.                         if(pev(pHit, pev_flags) & (FL_DUCKING | FL_ONGROUND) == (FL_DUCKING | FL_ONGROUND)) iKnockBack = (iKnockBack / 3);
  352.  
  353.                         new Float: vecVelocity[3]; pev(pHit, pev_velocity, vecVelocity);
  354.                         new Float: vecKnockBack[3]; velocity_by_aim(iPlayer, iKnockBack, vecKnockBack);
  355.  
  356.                         vecVelocity[2] += 200.0;
  357.                         vecKnockBack[2] = vecVelocity[2];
  358.  
  359.                         set_pev(pHit, pev_velocity, vecKnockBack);
  360.  
  361.                         set_pdata_float(pHit, m_flPainShock, 1.0, linux_diff_player);
  362.                     }
  363.                 }
  364.             }
  365.  
  366.             iHitResult = HIT_ENTITY;
  367.             pHitEntity = pHit;
  368.  
  369.             if(iHitResult != HIT_ENTITY) {
  370.                 new Float: vecEndPos[3]; get_tr2(iTrace, TR_vecEndPos, vecEndPos);
  371.                 UTIL_ShockEffect(vecEndPos);
  372.             }
  373.         }
  374.     }
  375.  
  376.     free_tr2(iTrace);
  377.  
  378.     switch(iHitResult) {
  379.         case HIT_NONE: {
  380.             switch(pev(iPlayer, pev_weaponanim)) {
  381.                 case ANIM_MIDSLASH1_HIT: emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[4], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  382.                 case ANIM_MIDSLASH2: {
  383.                     UTIL_SendWeaponAnim(iPlayer, ANIM_MIDSLASH2_FAIL);
  384.                     emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[6], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  385.                 }
  386.                 case ANIM_MIDSLASH2_FAIL: emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[6], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  387.             }
  388.         }
  389.         case HIT_WORLD: {
  390.             if(pev(iPlayer, pev_weaponanim) == ANIM_MIDSLASH2) UTIL_SendWeaponAnim(iPlayer, ANIM_MIDSLASH2_HIT);
  391.             emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[random_num(8, 13)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  392.         }
  393.         case HIT_ENTITY: {
  394.             switch(pev(iPlayer, pev_weaponanim)) {
  395.                 case ANIM_DRAW_ATTACK: emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[1], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  396.                 case ANIM_MIDSLASH1_HIT: {
  397.                     emit_sound(iPlayer, CHAN_ITEM, KNIFE_SOUNDS[5], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  398.                     emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[1], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  399.                 }
  400.                 case ANIM_MIDSLASH2: {
  401.                     UTIL_SendWeaponAnim(iPlayer, ANIM_MIDSLASH2_HIT);
  402.                     emit_sound(iPlayer, CHAN_ITEM, KNIFE_SOUNDS[7], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  403.                     emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[2], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  404.                 }
  405.                 case ANIM_MIDSLASH2_FAIL: {
  406.                     emit_sound(iPlayer, CHAN_ITEM, KNIFE_SOUNDS[6], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  407.                     emit_sound(iPlayer, CHAN_WEAPON, KNIFE_SOUNDS[2], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  408.                 }
  409.             }
  410.         }
  411.     }
  412. }
  413.  
  414. public FakeTraceAttack(iVictim, iAttacker, Float: flDamage, Float: vecDirection[3], iTrace, iDamageBits) {
  415.     static Float: flTakeDamage; pev(iVictim, pev_takedamage, flTakeDamage);
  416.  
  417.     if(flTakeDamage == DAMAGE_NO) return PLUGIN_CONTINUE;
  418.     if(!is_user_alive(iVictim)) return PLUGIN_CONTINUE;
  419.  
  420.     if(is_user_connected(iVictim)) if(iVictim == iAttacker) return PLUGIN_CONTINUE;
  421.  
  422.     static iHitgroup; iHitgroup = get_tr2(iTrace, TR_iHitgroup);
  423.     static Float: vecEndPos[3]; get_tr2(iTrace, TR_vecEndPos, vecEndPos);
  424.    
  425.     set_pdata_int(iVictim, m_LastHitGroup, iHitgroup, linux_diff_player);
  426.  
  427.     switch(iHitgroup) {
  428.         case HIT_HEAD:                  flDamage *= random_float(1.0, 2.0);
  429.         case HIT_LEFTARM, HIT_RIGHTARM: flDamage *= random_float(0.5, 1.0);
  430.         case HIT_LEFTLEG, HIT_RIGHTLEG: flDamage *= random_float(0.5, 1.0);
  431.         case HIT_STOMACH:               flDamage *= random_float(0.5, 1.0);
  432.     }
  433.    
  434.     ExecuteHamB(Ham_TakeDamage, iVictim, iAttacker, iAttacker, flDamage, iDamageBits);
  435.    
  436.     if(ze_is_user_zombie(iVictim)) {
  437.         UTIL_BloodDrips(iVictim, vecEndPos, floatround(flDamage));
  438.         set_pdata_float(iVictim, m_flPainShock, 0.75, linux_diff_player);
  439.     }
  440.  
  441.     return PLUGIN_HANDLED;
  442. }
  443.  
  444. stock UTIL_ShockEffect(Float: vecOrigin[3]) {
  445.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecOrigin, 0);
  446.     write_byte(TE_EXPLOSION);
  447.     engfunc(EngFunc_WriteCoord, vecOrigin[0]);
  448.     engfunc(EngFunc_WriteCoord, vecOrigin[1]);
  449.     engfunc(EngFunc_WriteCoord, vecOrigin[2]);
  450.     write_short(g_iSpriteIndex_Shock);
  451.     write_byte(3);
  452.     write_byte(15);
  453.     write_byte(TE_EXPLFLAG_NODLIGHTS|TE_EXPLFLAG_NOSOUND|TE_EXPLFLAG_NOPARTICLES);
  454.     message_end();
  455. }
  456. stock UTIL_BloodDrips(iVictim, Float: vecOrigin[3], iAmount) {
  457.     if(iAmount > 255) iAmount = 255;
  458.    
  459.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecOrigin, 0);
  460.     write_byte(TE_BLOODSPRITE);
  461.     engfunc(EngFunc_WriteCoord, vecOrigin[0]);
  462.     engfunc(EngFunc_WriteCoord, vecOrigin[1]);
  463.     engfunc(EngFunc_WriteCoord, vecOrigin[2]);
  464.     write_short(engfunc(EngFunc_PrecacheModel, "sprites/bloodspray.spr"));
  465.     write_short(engfunc(EngFunc_PrecacheModel, "sprites/blood.spr"));
  466.     write_byte(ExecuteHamB(Ham_BloodColor, iVictim));
  467.     write_byte(min(max(3, iAmount / 10), 16));
  468.     message_end();
  469. }
  470. stock UTIL_PlayerAnimation(iPlayer, szAnim[]) {
  471.     new iAnimDesired, Float: flFrameRate, Float: flGroundSpeed, bool: bLoops;
  472.        
  473.     if((iAnimDesired = lookup_sequence(iPlayer, szAnim, flFrameRate, bLoops, flGroundSpeed)) == -1) iAnimDesired = 0;
  474.  
  475.     set_pev(iPlayer, pev_frame, 0.0);
  476.     set_pev(iPlayer, pev_framerate, 1.0);
  477.     set_pev(iPlayer, pev_animtime, get_gametime());
  478.     set_pev(iPlayer, pev_sequence, iAnimDesired);
  479.    
  480.     set_pdata_int(iPlayer, 40, bLoops, linux_diff_animating);
  481.     set_pdata_int(iPlayer, 39, 0, linux_diff_animating);
  482.    
  483.     set_pdata_float(iPlayer, 36, flFrameRate, linux_diff_animating);
  484.     set_pdata_float(iPlayer, 37, flGroundSpeed, linux_diff_animating);
  485.     set_pdata_float(iPlayer, 38, get_gametime(), linux_diff_animating);
  486.    
  487.     set_pdata_int(iPlayer, 73, 28, linux_diff_player);
  488.     set_pdata_int(iPlayer, 74, 28, linux_diff_player);
  489.     set_pdata_float(iPlayer, 220, get_gametime(), linux_diff_player);
  490. }
  491. stock UTIL_SendWeaponAnim(iPlayer, iAnim, iBody = 0) {
  492.     set_pev(iPlayer, pev_weaponanim, iAnim);
  493.  
  494.     message_begin(MSG_ONE, SVC_WEAPONANIM, _, iPlayer);
  495.     write_byte(iAnim);
  496.     write_byte(iBody);
  497.     message_end();
  498. }
  499. stock UTIL_PrecacheSoundsFromModel(const szModelPath[]) {
  500.     new iFile;
  501.    
  502.     if((iFile = fopen(szModelPath, "rt"))) {
  503.         new szSoundPath[64];
  504.        
  505.         new iNumSeq, iSeqIndex;
  506.         new iEvent, iNumEvents, iEventIndex;
  507.        
  508.         fseek(iFile, 164, SEEK_SET);
  509.         fread(iFile, iNumSeq, BLOCK_INT);
  510.         fread(iFile, iSeqIndex, BLOCK_INT);
  511.        
  512.         for(new k, i = 0; i < iNumSeq; i++) {
  513.             fseek(iFile, iSeqIndex + 48 + 176 * i, SEEK_SET);
  514.             fread(iFile, iNumEvents, BLOCK_INT);
  515.             fread(iFile, iEventIndex, BLOCK_INT);
  516.             fseek(iFile, iEventIndex + 176 * i, SEEK_SET);
  517.            
  518.             for(k = 0; k < iNumEvents; k++) {
  519.                 fseek(iFile, iEventIndex + 4 + 76 * k, SEEK_SET);
  520.                 fread(iFile, iEvent, BLOCK_INT);
  521.                 fseek(iFile, 4, SEEK_CUR);
  522.                
  523.                 if(iEvent != 5004) continue;
  524.                
  525.                 fread_blocks(iFile, szSoundPath, 64, BLOCK_CHAR);
  526.                
  527.                 if(strlen(szSoundPath)) {
  528.                     strtolower(szSoundPath);
  529.                     engfunc(EngFunc_PrecacheSound, szSoundPath);
  530.                 }
  531.             }
  532.         }
  533.     }
  534.    
  535.     fclose(iFile);
  536. }[/code]
Last edited by Raheem on 30 Jul 2019, 13:00, edited 1 time in total.
Reason: Updated ze_zombie_appear(id) --> ze_zombie_appear()
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

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

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

#3

Post by czirimbolo » 2 Months Ago

//// cso_melee_stormgiant.sma
//
// C:\Users\macie\Documents\Compiler v1.8.3\scripting\cso_melee_stormgiant.sma(117) : error 025: function heading differs from prototype
//
// 1 Error.
// Could not locate output file compiled\cso_melee_stormgiant.amx (compile failed).
//
// Compilation Time: 1,56 sec
// -------------------------------
Image

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

#4

Post by Muhammet20 » 2 Months Ago

@czirimblo idk why you facing this problem ask @Raheem

[ Post made via Android ]
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

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

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#5

Post by Raheem » 2 Months Ago

Try his code now.
You don't know? Learn and you will know.

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

#6

Post by czirimbolo » 2 Months Ago

Raheem wrote:
2 Months Ago
Try his code now.
worked. Can you tell me what did you change? I have the same problem with another knife
Image

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

#7

Post by Muhammet20 » 2 Months Ago

ze_zombie_appear(id) --> ze_zombie_appear()
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

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

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

#8

Post by czirimbolo » 2 Months Ago

Muhammet20 wrote:
2 Months Ago
ze_zombie_appear(id) --> ze_zombie_appear()
ok but what else? what exactly did you add to this code?
Image

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

#9

Post by Muhammet20 » 2 Months Ago

czirimbolo wrote:
2 Months Ago
Muhammet20 wrote:
2 Months Ago
ze_zombie_appear(id) --> ze_zombie_appear()
ok but what else? what exactly did you add to this code?
look i added this:

Code: Select all

new g_freezetime

public plugin_init()
{
	register_event("HLTV", "event_newround", "a", "1=0", "2=0")
}
public event_newround(id)
{
	g_freezetime = true
}
public ze_zombie_appear()
{
	g_freezetime = false
}
and i added this check

Code: Select all

if(g_freezetime)
	return

// set knife speed
These users thanked the author Muhammet20 for the post:
czirimbolo (2 Months Ago)
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest