Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. public Action:OnPlayerRunCmd(Client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
  2. {
  3. if(IsClientInGame(Client) && IsPlayerAlive(Client))
  4. {
  5. if(g_bKnockBack[Client])
  6. {
  7. if(!(GetEntityFlags(Client) & FL_ONGROUND))
  8. {
  9. vel[0] = 0.0;
  10. vel[1] = 0.0;
  11. vel[2] = 0.0;
  12. }
  13. else
  14. {
  15. new Float:Velocity[3], Float:Speed;
  16. GetEntPropVector(Client, Prop_Data, "m_vecVelocity", Velocity);
  17. Velocity[2] = 0.0;
  18. Speed = GetVectorLength(Velocity);
  19. NormalizeVector(Velocity, Velocity);
  20. ScaleVector(Velocity, 500.0);
  21.  
  22. if(Speed == 0.0)
  23. {
  24. g_bKnockBack[Client] = false;
  25. }
  26. else
  27. {
  28. if(Speed >= 1000.0)
  29. {
  30. TeleportEntity(Client, NULL_VECTOR, NULL_VECTOR, Velocity);
  31. }
  32.  
  33. vel[0] = 0.0;
  34. vel[1] = 0.0;
  35. vel[2] = 0.0;
  36. }
  37. }
  38. }
  39. }
  40. }
  41.  
  42. public Action:Hook_OnTakeDamage(Client, &attacker, &inflictor, &Float:damage, &damagetype)
  43. {
  44. if(!(1 <= inflictor <= MaxClients && GetClientTeam(Client) != GetClientTeam(attacker)))
  45. {
  46. return Plugin_Continue;
  47. }
  48.  
  49. new String:WeaponName[32];
  50. GetClientWeapon(inflictor, WeaponName, sizeof(WeaponName));
  51.  
  52. if(StrContains(WeaponName, "knife", false) != -1 || StrContains(WeaponName, "bayonet", false) != -1)
  53. {
  54. GiveKnockback(attacker, Client);
  55. g_bKnockBack[Client] = true;
  56.  
  57. damage = 0.0;
  58. return Plugin_Changed;
  59. }
  60. return Plugin_Continue;
  61. }
  62.  
  63. GiveKnockback(Client, Target)
  64. {
  65. new Float:Pos01[3], Float:Pos02[3], Float:Vector[3];
  66.  
  67. GetClientAbsOrigin(Client, Pos01);
  68. GetClientAbsOrigin(Target, Pos02);
  69.  
  70. Pos01[2] = 0.0;
  71. Pos02[2] = 0.0;
  72.  
  73. MakeVectorFromPoints(Pos01, Pos02, Vector);
  74. NormalizeVector(Vector, Vector);
  75.  
  76. if(!(GetEntityFlags(Target) & FL_ONGROUND))
  77. {
  78. ScaleVector(Vector, 350.0);
  79. }
  80. else
  81. {
  82. ScaleVector(Vector, 1000.0);
  83. }
  84.  
  85. KnifeSound(Client);
  86. TeleportEntity(Target, NULL_VECTOR, NULL_VECTOR, Vector);
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement