Approved Knife Knockback

Plug-ins compatibility with Zombie Escape 1.x only!


Post Reply
User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

Knife Knockback

#1

Post by Mark » 5 years 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 5 years ago, edited 3 times in total.

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

#2

Post by Raheem » 5 years 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 5 years ago, edited 1 time in total.
Reason: iInflictor ...
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#3

Post by Mark » 5 years ago

Raheem wrote: 5 years 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
Posts: 2214
Joined: 7 years ago
Contact:

#4

Post by Raheem » 5 years ago

But try my code first, i don't trust myself :lol:
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#5

Post by Mark » 5 years ago

Raheem wrote: 5 years 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
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#6

Post by Mark » 5 years ago

Mark wrote: 5 years ago
Raheem wrote: 5 years 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
Posts: 2214
Joined: 7 years ago
Contact:

#7

Post by Raheem » 5 years ago

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

Edit: That's OK :D
Last edited by Raheem 5 years ago, edited 1 time in total.
Reason: OK
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#8

Post by Mark » 5 years ago

Raheem wrote: 5 years 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
Posts: 2214
Joined: 7 years ago
Contact:

#9

Post by Raheem » 5 years ago

lol, let comments maybe someone find something useful in them :lol:
He who fails to plan is planning to fail

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

#10

Post by Rain1153 » 5 years ago

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

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#11

Post by Mark » 5 years ago

Rain1153 wrote: 5 years ago I thought when zombie would hit humans the human will fly away 😂
lol :lol: :lol: :lol:

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#12

Post by Mark » 5 years ago

Rain1153 wrote: 5 years ago I thought when zombie would hit humans the human will fly away 😂
If you want that to happen i could make that happen lol

Post Reply

Create an account or sign in to join the discussion

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

Create an account

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

Register

Sign in

Who is online

Users browsing this forum: No registered users and 0 guests