Approved Knife Knockback

Gameplay Addons
User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 258
Joined: 5 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 19 times
Age: 33
Contact:

Knife Knockback

#1

Post by Mark » 4 Months Ago

Knife Knockback



Description:
  • This addon will make your knife have a knockback

Cvars
    1.     CvarPower = register_cvar("kb_power","1000")
    2.     CvarHeight = register_cvar("kb_height","500")


Code:
    1. #include <zombie_escape>
    2.  
    3. new g_pCvarPower,
    4.     g_pCvarHeight
    5.  
    6. public plugin_init()
    7. {
    8.     register_plugin("ZE Knife Knock Back", "0.0.1", "wbyokomo")
    9.    
    10.     g_pCvarPower = register_cvar("kb_power","1000")
    11.     g_pCvarHeight = register_cvar("kb_height","500")
    12.    
    13.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
    14. }
    15.  
    16. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:flDamage, bitsDamageType)
    17. {
    18.     if(iVictim == iAttacker) return HC_CONTINUE; //self damage
    19.     if(iInflictor != iAttacker) return HC_CONTINUE; //prevent from other damage like bazooka, tripmine we need knife damage only
    20.     if(!is_user_connected(iAttacker)) return HC_CONTINUE; //non-player damage
    21.     if(get_user_weapon(iAttacker) != CSW_KNIFE) return HC_CONTINUE; //current weapon is not knife
    22.  
    23.     if(ze_is_user_zombie(iVictim) && !ze_is_user_zombie(iAttacker))
    24.     {
    25.         static Float:flVelocity[3]
    26.         velocity_by_aim(iAttacker, get_pcvar_num(g_pCvarPower), flVelocity)
    27.         flVelocity[2] = get_pcvar_float(g_pCvarHeight)
    28.         set_entvar(iVictim, var_velocity, flVelocity)
    29.     }
    30.    
    31.     return HC_CONTINUE;
    32. }
Have Fun :D
Last edited by Mark on 16 Sep 2018, 01:57, edited 3 times in total.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1723
Joined: 1 Year Ago
Location: Egypt
Has thanked: 28 times
Been thanked: 78 times
Age: 21
Contact:

#2

Post by Raheem » 4 Months Ago

ReAPI and My STYLE :D:

  1. #include <zombie_escape>
  2.  
  3. new g_pCvarPower,
  4.     g_pCvarHeight
  5.  
  6. public plugin_init()
  7. {
  8.     register_plugin("ZP Knife Knock Back", "0.0.1", "wbyokomo")
  9.    
  10.     g_pCvarPower = register_cvar("kb_power","1000")
  11.     g_pCvarHeight = register_cvar("kb_height","500")
  12.    
  13.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  14. }
  15.  
  16. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:flDamage, bitsDamageType)
  17. {
  18.     if(iVictim == iAttacker) return HC_CONTINUE; //self damage
  19.     if(iInflictor != iAttacker) return HC_CONTINUE; //prevent from other damage like bazooka, tripmine we need knife damage only
  20.     if(!is_user_connected(iAttacker)) return HC_CONTINUE; //non-player damage
  21.     if(get_user_weapon(iAttacker) != CSW_KNIFE) return HC_CONTINUE; //current weapon is not knife
  22.  
  23.     if(ze_is_user_zombie(iVictim) && !ze_is_user_zombie(iAttacker))
  24.     {
  25.         static Float:flVelocity[3]
  26.         velocity_by_aim(iAttacker, get_pcvar_num(g_pCvarPower), flVelocity)
  27.         flVelocity[2] = get_pcvar_float(g_pCvarHeight)
  28.         set_entvar(iVictim, var_velocity, flVelocity)
  29.     }
  30.    
  31.     return HC_CONTINUE;
  32. }
Last edited by Raheem on 16 Sep 2018, 01:56, edited 1 time in total.
Reason: iInflictor ...
You don't know? Learn and you will know.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 258
Joined: 5 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 19 times
Age: 33
Contact:

#3

Post by Mark » 4 Months Ago

Raheem wrote:
4 Months Ago
ReAPI and My STYLE :D:

  1. #include <zombie_escape>
  2.  
  3. new g_pCvarPower,
  4.     g_pCvarHeight
  5.  
  6. public plugin_init()
  7. {
  8.     register_plugin("ZP Knife Knock Back", "0.0.1", "wbyokomo")
  9.    
  10.     g_pCvarPower = register_cvar("kb_power","1000")
  11.     g_pCvarHeight = register_cvar("kb_height","500")
  12.    
  13.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  14. }
  15.  
  16. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:flDamage, bitsDamageType)
  17. {
  18.     if(iVictim == iAttacker) return HC_CONTINUE; //self damage
  19.     if(inflictor != iAttacker) return HC_CONTINUE; //prevent from other damage like bazooka, tripmine we need knife damage only
  20.     if(!is_user_connected(iAttacker)) return HC_CONTINUE; //non-player damage
  21.     if(get_user_weapon(iAttacker) != CSW_KNIFE) return HC_CONTINUE; //current weapon is not knife
  22.  
  23.     if(ze_is_user_zombie(iVictim) && !ze_is_user_zombie(iAttacker))
  24.     {
  25.         static Float:flVelocity[3]
  26.         velocity_by_aim(iAttacker, get_pcvar_num(g_pCvarPower), flVelocity)
  27.         flVelocity[2] = get_pcvar_float(g_pCvarHeight)
  28.         set_entvar(iVictim, var_velocity, flVelocity)
  29.     }
  30.    
  31.     return HC_CONTINUE;
  32. }
Updated first post with your code :D

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1723
Joined: 1 Year Ago
Location: Egypt
Has thanked: 28 times
Been thanked: 78 times
Age: 21
Contact:

#4

Post by Raheem » 4 Months Ago

But try my code first, i don't trust myself :lol:
You don't know? Learn and you will know.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 258
Joined: 5 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 19 times
Age: 33
Contact:

#5

Post by Mark » 4 Months Ago

Raheem wrote:
4 Months Ago
But try my code first, i don't trust myself :lol:
your code i put mine back for now :D
  1. //// ze_knife_knockback.sma
  2. //
  3. // C:\Users\marcu\Desktop\Compiler v1.8.3\Compiler v1.8.3\scripting\ze_knife_knockback.sma(19) : error 017: undefined symbol "inflictor"
  4. //
  5. // 1 Error.
  6. // Could not locate output file compiled\ze_knife_knockback.amx (compile failed).
  7. //
  8. // Compilation Time: 0.59 sec
  9. // ----------------------------------------

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 258
Joined: 5 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 19 times
Age: 33
Contact:

#6

Post by Mark » 4 Months Ago

Mark wrote:
4 Months Ago
Raheem wrote:
4 Months Ago
But try my code first, i don't trust myself :lol:
your code i put mine back for now :D
  1. //// ze_knife_knockback.sma
  2. //
  3. // C:\Users\marcu\Desktop\Compiler v1.8.3\Compiler v1.8.3\scripting\ze_knife_knockback.sma(19) : error 017: undefined symbol "inflictor"
  4. //
  5. // 1 Error.
  6. // Could not locate output file compiled\ze_knife_knockback.amx (compile failed).
  7. //
  8. // Compilation Time: 0.59 sec
  9. // ----------------------------------------
i fixed your typo
  1. #include <zombie_escape>
  2.  
  3. new g_pCvarPower,
  4.     g_pCvarHeight
  5.  
  6. public plugin_init()
  7. {
  8.     register_plugin("ZP Knife Knock Back", "0.0.1", "wbyokomo")
  9.    
  10.     g_pCvarPower = register_cvar("kb_power","1000")
  11.     g_pCvarHeight = register_cvar("kb_height","500")
  12.    
  13.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  14. }
  15.  
  16. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:flDamage, bitsDamageType)
  17. {
  18.     if(iVictim == iAttacker) return HC_CONTINUE; //self damage
  19.     if(iInflictor != iAttacker) return HC_CONTINUE; //prevent from other damage like bazooka, tripmine we need knife damage only
  20.     if(!is_user_connected(iAttacker)) return HC_CONTINUE; //non-player damage
  21.     if(get_user_weapon(iAttacker) != CSW_KNIFE) return HC_CONTINUE; //current weapon is not knife
  22.  
  23.     if(ze_is_user_zombie(iVictim) && !ze_is_user_zombie(iAttacker))
  24.     {
  25.         static Float:flVelocity[3]
  26.         velocity_by_aim(iAttacker, get_pcvar_num(g_pCvarPower), flVelocity)
  27.         flVelocity[2] = get_pcvar_float(g_pCvarHeight)
  28.         set_entvar(iVictim, var_velocity, flVelocity)
  29.     }
  30.    
  31.     return HC_CONTINUE;
  32. }
Your code works fine!

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1723
Joined: 1 Year Ago
Location: Egypt
Has thanked: 28 times
Been thanked: 78 times
Age: 21
Contact:

#7

Post by Raheem » 4 Months Ago

OH, I updated it. Just confirm it's working in server.

Edit: That's OK :D
Last edited by Raheem on 16 Sep 2018, 01:57, edited 1 time in total.
Reason: OK
You don't know? Learn and you will know.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 258
Joined: 5 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 19 times
Age: 33
Contact:

#8

Post by Mark » 4 Months Ago

Raheem wrote:
4 Months Ago
OH, I updated it. Just confirm it's working in server.

Edit: That's OK :D
maybe we clean this thread up lol

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1723
Joined: 1 Year Ago
Location: Egypt
Has thanked: 28 times
Been thanked: 78 times
Age: 21
Contact:

#9

Post by Raheem » 4 Months Ago

lol, let comments maybe someone find something useful in them :lol:
These users thanked the author Raheem for the post:
Mark (4 Months Ago)
You don't know? Learn and you will know.

Rain1153
Senior Member
Senior Member
India
Posts: 277
Joined: 1 Year Ago
Has thanked: 2 times
Been thanked: 1 time
Age: 18
Contact:

#10

Post by Rain1153 » 4 Months Ago

I thought when zombie would hit humans the human will fly away 😂

[ Post made via Android ]
LOL

Post Reply

Who is online

Users browsing this forum: Muhammet20 and 1 guest