Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <tf2>
  4. #include <tf2_stocks>
  5. #include <sdkhooks>
  6. int attack[MAXPLAYERS+1];
  7. new offset_ammo;
  8. new offset_clip
  9. public OnPluginStart()
  10. {
  11. HookEvent("object_deflected", Deflect, EventHookMode_Post);
  12. offset_ammo = FindSendPropInfo("CBasePlayer", "m_iAmmo");
  13. offset_clip = FindSendPropInfo("CBaseCombatWeapon", "m_iClip1");
  14. }
  15. public void OnClientPutInServer(client)
  16. {
  17. SDKHook(client, SDKHook_OnTakeDamage, OnClientTakeDamage);
  18. }
  19. public Action OnClientTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3])
  20. {
  21. damage = 0.0;
  22. return Plugin_Changed;
  23. }
  24. public Action Deflect(Handle hEvent, char[] strEventName, bool bDontBroadcast)
  25. {
  26. int rocket = GetEventInt(hEvent, "object_entindex");
  27. RemoveEdict(rocket);
  28. return Plugin_Continue;
  29. }
  30. public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
  31. {
  32. if (!IsPlayerAlive(client)) return Plugin_Continue;
  33. new iWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  34. new ammotype = GetEntProp(iWeapon, Prop_Send, "m_iPrimaryAmmoType")*4;
  35. SetEntData(weapon, offset_clip, 99, 4, true);
  36. SetEntData(client, ammotype+offset_ammo, 99, 4, true);
  37. TF2_RegeneratePlayer(client);
  38. if (buttons & IN_ATTACK)
  39. {
  40. attack[client] = 1;
  41. }
  42. if (buttons & IN_ATTACK2)
  43. {
  44. attack[client] = 2;
  45. }
  46. if (attack[client] == 1)
  47. {
  48. buttons |= IN_ATTACK;
  49. }
  50. if (attack[client] == 2)
  51. {
  52. buttons |= IN_ATTACK2;
  53. }
  54. ModRateOfFire(iWeapon);
  55. return Plugin_Continue;
  56. }
  57. stock ModRateOfFire(weapon)
  58. {
  59. new Float:m_flNextPrimaryAttack = GetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack");
  60. new Float:m_flNextSecondaryAttack = GetEntPropFloat(weapon, Prop_Send, "m_flNextSecondaryAttack");
  61. SetEntPropFloat(weapon, Prop_Send, "m_flPlaybackRate", 10.0);
  62.  
  63. new Float:fGameTime = GetGameTime();
  64. new Float:fPrimaryTime = ((m_flNextPrimaryAttack - fGameTime) - 0.99);
  65. new Float:fSecondaryTime = ((m_flNextSecondaryAttack - fGameTime) - 0.99);
  66.  
  67. SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", fPrimaryTime + fGameTime);
  68. SetEntPropFloat(weapon, Prop_Send, "m_flNextSecondaryAttack", fSecondaryTime + fGameTime);
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement