Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdkhooks>
  3. #include <tf2_stocks>
  4. #include <tf2items>
  5.  
  6. #pragma semicolon 1
  7.  
  8. int PlayerHit[MAXPLAYERS+1] = 0; int weaponPlayer[MAXPLAYERS+1];
  9.  
  10. int laserrifle = 30665;
  11.  
  12. bool LaserActivated = false;
  13.  
  14. public OnPluginStart()
  15. {
  16. RegConsoleCmd("sm_test", CMD_Test);
  17. RegConsoleCmd("sm_testoff", CMD_TestOff);
  18. HookEvent("player_death", Ev_PlayerDeath);
  19. }
  20.  
  21. public void OnClientPostAdminCheck(int client)
  22. {
  23. SDKHook(client, SDKHook_TraceAttack, TraceAttackHook);
  24. }
  25.  
  26. public OnClientDisconnect(int client)
  27. {
  28. SDKUnhook(client, SDKHook_TraceAttack, TraceAttackHook);
  29. }
  30.  
  31. public Action TF2_CalcIsAttackCritical(int client, int weapon, char[] weaponname, bool &result)
  32. {
  33. if (LaserActivated == true)
  34. {
  35. if (GetEntProp(weapon, Prop_Send, "m_iClip1") == 1)
  36. {
  37. TF2_RemoveAllWeapons(client);
  38. Handle sniperlaser = TF2Items_CreateItem(OVERRIDE_ATTRIBUTES|PRESERVE_ATTRIBUTES);
  39. TF2Items_SetClassname(sniperlaser, "tf_weapon_sniperrifle");
  40. TF2Items_SetItemIndex(sniperlaser, laserrifle);
  41. TF2Items_SetLevel(sniperlaser, 1);
  42. TF2Items_SetQuality(sniperlaser, 1);
  43. TF2Items_SetNumAttributes(sniperlaser, 2);
  44. TF2Items_SetAttribute(sniperlaser, 0, 2, 100.0);
  45. TF2Items_SetAttribute(sniperlaser, 0, 297, 0.0);
  46. weaponPlayer[client] = TF2Items_GiveNamedItem(client, sniperlaser);
  47. EquipPlayerWeapon(client, weaponPlayer[client]);
  48. SetEntProp(weaponPlayer[client], Prop_Data, "m_iClip1", 9);
  49. CloseHandle(sniperlaser);
  50. SetEntProp(client, Prop_Send, "m_bGlowEnabled", 1);
  51. }
  52. }
  53. }
  54.  
  55. public Action TraceAttackHook(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
  56. {
  57. if (LaserActivated == true)
  58. {
  59. int Replacement = PlayerHit[victim]+1;
  60. PlayerHit[victim] = Replacement;
  61. if (PlayerHit[victim] >= 3)
  62. {
  63. return Plugin_Continue;
  64. }
  65. else
  66. {
  67. damage = 0.0;
  68. }
  69. return Plugin_Changed;
  70. }
  71. else
  72. {
  73. return Plugin_Continue;
  74. }
  75. }
  76.  
  77.  
  78. public Action Ev_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
  79. {
  80. int victim = GetClientOfUserId(GetEventInt(event, "userid", 0));
  81. PlayerHit[victim] = 0;
  82. return Plugin_Handled;
  83. }
  84.  
  85.  
  86.  
  87. public Action CMD_Test(int client, int args)
  88. {
  89. LaserActivated = true;
  90. for (int i = 1; i <= MaxClients; i++)
  91. {
  92. if (IsClientInGame(i))
  93. {
  94. TF2_SetPlayerClass(i, TFClass_Sniper);
  95. TF2_RespawnPlayer(i);
  96.  
  97. if (IsPlayerAlive(i))
  98. {
  99. TF2_RemoveAllWeapons(i);
  100. Handle sniperlaser = TF2Items_CreateItem(OVERRIDE_ATTRIBUTES|PRESERVE_ATTRIBUTES);
  101. TF2Items_SetClassname(sniperlaser, "tf_weapon_sniperrifle");
  102. TF2Items_SetItemIndex(sniperlaser, laserrifle);
  103. TF2Items_SetLevel(sniperlaser, 1);
  104. TF2Items_SetQuality(sniperlaser, 1);
  105. TF2Items_SetNumAttributes(sniperlaser, 2);
  106. TF2Items_SetAttribute(sniperlaser, 0, 2, 100.0);
  107. TF2Items_SetAttribute(sniperlaser, 0, 297, 0.0);
  108. weaponPlayer[i] = TF2Items_GiveNamedItem(i, sniperlaser);
  109. EquipPlayerWeapon(i, weaponPlayer[i]);
  110. SetEntProp(weaponPlayer[i], Prop_Data, "m_iClip1", 3);
  111. CloseHandle(sniperlaser);
  112. SetEntProp(i, Prop_Send, "m_bGlowEnabled", 1);
  113. }
  114. }
  115. }
  116. SetConVarInt(FindConVar("sv_gravity"), 600);
  117.  
  118. PrintToChatAll("Laser Activated");
  119.  
  120. return Plugin_Handled;
  121. }
  122.  
  123. public Action CMD_TestOff(int client, int args)
  124. {
  125. LaserActivated = false;
  126. SetConVarInt(FindConVar("sv_gravity"), 800);
  127. return Plugin_Handled;
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement