Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 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;
  9.  
  10. const int laserrifle = 30665;
  11.  
  12. bool LaserActivated;
  13.  
  14. public OnPluginStart()
  15. {
  16. RegConsoleCmd("sm_test", CMD_Test);
  17. RegConsoleCmd("sm_testoff", CMD_TestOff);
  18. HookEvent("player_death", Ev_PlayerDeath);
  19. HookEvent("teamplay_win_panel", Ev_TeamplayWinPanel);
  20. }
  21.  
  22. public void OnPlayerConnected(int client)
  23. {
  24. SDKHook(client, SDKHook_TraceAttack, TraceAttackHook);
  25. }
  26.  
  27. public Action TraceAttackHook(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
  28. {
  29. damage = 0.0;
  30. int Replacement = PlayerHit[victim]+1;
  31. PlayerHit[victim] = Replacement;
  32. if (PlayerHit[victim] >= 3)
  33. {
  34. TF2_RemoveCondition(victim, TFCond_PreventDeath);
  35. SDKHooks_TakeDamage(victim, laserrifle, attacker, float(GetClientHealth(victim)), DMG_ENERGYBEAM, laserrifle, _, _);
  36. }
  37. }
  38.  
  39. public void OnGameFrame()
  40. {
  41. if (LaserActivated == true)
  42. {
  43. for (int i = 1; i <= MaxClients; i++)
  44. {
  45. if (IsClientInGame(i))
  46. {
  47. if (IsPlayerAlive(i))
  48. {
  49. if (TF2_GetPlayerClass(i) == TFClass_Sniper)
  50. {
  51. SetEntProp(i, Prop_Send, "m_bGlowEnabled", 1);
  52. SetEntProp(i, Prop_Send, "m_hActiveWeapon", TFWeaponSlot_Primary);
  53. TF2_AddCondition(i, TFCond_PreventDeath);
  54. }
  55. else
  56. {
  57. ForcePlayerSuicide(i);
  58.  
  59. TF2_SetPlayerClass(i, TFClass_Sniper);
  60.  
  61. TF2_RespawnPlayer(i);
  62. if (TF2_GetPlayerClass(i) == TFClass_Sniper)
  63. {
  64. SetEntProp(i, Prop_Send, "m_bGlowEnabled", 1);
  65. SetEntProp(i, Prop_Send, "m_hActiveWeapon", TFWeaponSlot_Primary);
  66. TF2_AddCondition(i, TFCond_PreventDeath);
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }
  73. }
  74.  
  75. public Action TF2Items_OnGiveNamedItem(int client, char[] classname, int iItemDefinitionIndex, Handle& hItem)
  76. {
  77. SetEntProp(client, Prop_Send, "m_hActiveWeapon", TFWeaponSlot_Primary);
  78. TF2_RemoveWeaponSlot(client, 1);
  79. TF2_RemoveWeaponSlot(client, 2);
  80. return Plugin_Handled;
  81. }
  82.  
  83. public Action Ev_TeamplayWinPanel(Event event, const char[] name, bool dontBroadcast)
  84. {
  85. for (int i = 1; i <= MaxClients; i++)
  86. {
  87. if (IsClientInGame(i))
  88. {
  89. if (IsPlayerAlive(i))
  90. {
  91. PlayerHit[i] = 0;
  92. LaserActivated = false;
  93. if (TF2_IsPlayerInCondition(i, TFCond_PreventDeath) == true)
  94. {
  95. TF2_RemoveCondition(i, TFCond_PreventDeath);
  96. }
  97. }
  98. }
  99. }
  100. }
  101.  
  102. public Action Ev_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
  103. {
  104. int victim = GetClientOfUserId(GetEventInt(event, "victim", 0));
  105. PlayerHit[victim] = 0;
  106. if (TF2_IsPlayerInCondition(victim, TFCond_PreventDeath) == true)
  107. {
  108. TF2_RemoveCondition(victim, TFCond_PreventDeath);
  109. }
  110. }
  111.  
  112. public Action CMD_Test(int client, int args)
  113. {
  114. LaserActivated = true;
  115. SetConVarInt(FindConVar("sv_gravity"), 600);
  116. Handle sniperlaser = TF2Items_CreateItem(OVERRIDE_ALL);
  117. TF2Items_SetClassname(sniperlaser, "tf_weapon_sniperrifle");
  118. TF2Items_SetItemIndex(sniperlaser, laserrifle);
  119. TF2Items_SetLevel(sniperlaser, 1);
  120. TF2Items_SetQuality(sniperlaser, 1);
  121. TF2Items_SetNumAttributes(sniperlaser, 2);
  122. TF2Items_SetAttribute(sniperlaser, 0, 47, 1.0);
  123. TF2Items_SetAttribute(sniperlaser, 0, 315, 1.0);
  124. for (int i = 1; i <= MaxClients; i++)
  125. {
  126. if (IsClientInGame(i))
  127. {
  128. if (IsPlayerAlive(i))
  129. {
  130. TF2_AddCondition(i, TFCond_PreventDeath, TFCondDuration_Infinite, 0);
  131. SetEntProp(i, Prop_Send, "m_bGlowEnabled", 1);
  132. int weapon = TF2Items_GiveNamedItem(i, sniperlaser);
  133. EquipPlayerWeapon(i, weapon);
  134. SetEntProp(weapon, Prop_Data, "m_iClip1", 1);
  135. }
  136. }
  137. }
  138. PrintToChatAll("Laser Activated");
  139.  
  140. CloseHandle(sniperlaser);
  141.  
  142. return Plugin_Handled;
  143. }
  144.  
  145. public Action CMD_TestOff(int client, int args)
  146. {
  147. LaserActivated = false;
  148. return Plugin_Handled;
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement