Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1. #include <sdktools>
  2. #include <cstrike>
  3. #include <sdkhooks>
  4. #include <emitsoundany>
  5.  
  6. #define SOUND "hitsounds/hit_sound.mp3"
  7. #define HS_SOUND "hitsounds/hs_sound.mp3"
  8.  
  9. #define PLUGIN_VERSION "1.0"
  10.  
  11. public Plugin:myinfo = {
  12. name = "Hitsoundsy/smokehide",
  13. author = "Yugi",
  14. description = "Jebac ulane kurwy!",
  15. version = PLUGIN_VERSION,
  16. url = "http://cs-placzabaw.pl/"
  17. };
  18. bool headshot[MAXPLAYERS+1];
  19.  
  20. new Handle:cvarDisplayDamage;
  21.  
  22. new Handle:aSmokes;
  23.  
  24. public OnPluginStart()
  25. {
  26. HookEvent("smokegrenade_detonate", Event_SmokeDetonate);
  27. HookEvent("smokegrenade_expired", Event_SmokeRemoved);
  28. HookEvent("round_start", Event_RoundStart);
  29.  
  30. cvarDisplayDamage = CreateConVar("sm_hitsounds_displaydamage", "1", "Display damage done to attacker", _, true, 0.0, true, 1.0);
  31. aSmokes = CreateArray(3);
  32. }
  33.  
  34. public void OnMapStart()
  35. {
  36. PrecacheSoundAny(SOUND, true);
  37. PrecacheSoundAny(HS_SOUND, true);
  38. char temp[128];
  39. char temp1[128];
  40. Format(temp, sizeof(temp), "sound/%s", SOUND);
  41. Format(temp1, sizeof(temp1), "sound/%s", HS_SOUND);
  42. AddFileToDownloadsTable(temp);
  43. AddFileToDownloadsTable(temp1);
  44. }
  45. public void OnClientPutInServer(client)
  46. {
  47. SDKHook(client, SDKHook_TraceAttack, TraceAttack);
  48. SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  49. }
  50. public void OnClientDisconnect(client)
  51. {
  52. SDKUnhook(client, SDKHook_TraceAttack, TraceAttack);
  53. SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  54. }
  55. public Action:TraceAttack(client, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
  56. {
  57. if(!IsValidClient(client))
  58. return Plugin_Continue;
  59.  
  60. if(!IsValidClient(attacker) || GetClientTeam(client) == GetClientTeam(attacker))
  61. return Plugin_Continue;
  62.  
  63. headshot[client] = (hitgroup == 1)? true: false;
  64. return Plugin_Continue;
  65. }
  66. public Action:OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype)
  67. {
  68. if(!IsValidClient(client) || !IsValidClient(attacker))
  69. return Plugin_Continue;
  70.  
  71. if(GetClientTeam(client) == GetClientTeam(attacker))
  72. return Plugin_Continue;
  73.  
  74. int obrazenia = RoundFloat(damage);
  75. if(headshot[client])
  76. {
  77. if(GetConVarBool(cvarDisplayDamage))
  78. PrintHintText(attacker, "<font color='#E22B29'>[ZADANE OBRAŻENIA]\n<font color='#f62a2a'>[%i]</font>", obrazenia);
  79. EmitSoundToClientAny(attacker, HS_SOUND);
  80. }
  81. else
  82. {
  83. if(GetConVarBool(cvarDisplayDamage))
  84. PrintHintText(attacker, "<font color='#E22B29'>[ZADANE OBRAŻENIA]\n<font color='#dfe119'>[%i]</font>", obrazenia);
  85. EmitSoundToClientAny(attacker, SOUND);
  86. }
  87. return Plugin_Continue;
  88. }
  89. public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
  90. {
  91. ClearArray(aSmokes);
  92. }
  93. public Action:Event_SmokeDetonate(Handle:event, const String:name[], bool:dontBroadcast)
  94. {
  95. new Float:Pos[3];
  96. Pos[0] = GetEventFloat(event, "x");
  97. Pos[1] = GetEventFloat(event, "y");
  98. Pos[2] = GetEventFloat(event, "z");
  99. PushArrayArray(aSmokes, Pos, 3);
  100. }
  101.  
  102. public Action:Event_SmokeRemoved(Handle:event, const String:name[], bool:dontBroadcast)
  103. {
  104. new Float:Pos[3];
  105. Pos[0] = GetEventFloat(event, "x");
  106. Pos[1] = GetEventFloat(event, "y");
  107. Pos[2] = GetEventFloat(event, "z");
  108. new numSmokes = GetArraySize(aSmokes), closest = -1, Float:closestdist = 400.0;
  109. for (new i = 0; i < numSmokes; i++)
  110. {
  111. decl Float:thisPos[3];
  112. GetArrayArray(aSmokes, i, thisPos, 3);
  113. new Float:dist = GetVectorDistance(Pos, thisPos);
  114. if (dist > closestdist) continue;
  115. closest = i, closestdist = dist;
  116. }
  117. if (closest == -1) return;
  118. RemoveFromArray(aSmokes, closest);
  119. }
  120. stock HasClearSight(client, target)
  121. {
  122. new Float:ClientPos[3], Float:TargetPos[3], Float:Result[3];
  123. GetClientEyePosition(client, ClientPos);
  124. GetClientAbsOrigin(target, TargetPos);
  125. TargetPos[2] += 32.0;
  126.  
  127. MakeVectorFromPoints(ClientPos, TargetPos, Result);
  128. GetVectorAngles(Result, Result);
  129.  
  130. TR_TraceRayFilter(ClientPos, Result, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf, client);
  131. return target == TR_GetEntityIndex();
  132. }
  133. public bool:TraceRayDontHitSelf(Ent, Mask, any:Hit)
  134. {
  135. return Ent != Hit;
  136. }
  137. public OnMapEnd()
  138. {
  139. ClearArray(aSmokes);
  140. }
  141. public bool:IsValidClient(client)
  142. {
  143. if(IsClientInGame(client) && client >= 1 && client <= MaxClients)
  144. return true;
  145.  
  146. return false;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement