Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sdktools>
- #include <cstrike>
- #include <sdkhooks>
- #include <emitsoundany>
- #define SOUND "hitsounds/hit_sound.mp3"
- #define HS_SOUND "hitsounds/hs_sound.mp3"
- #define PLUGIN_VERSION "1.0"
- public Plugin:myinfo = {
- name = "Hitsoundsy/smokehide",
- author = "Yugi",
- description = "Jebac ulane kurwy!",
- version = PLUGIN_VERSION,
- url = "http://cs-placzabaw.pl/"
- };
- bool headshot[MAXPLAYERS+1];
- new Handle:cvarDisplayDamage;
- new Handle:aSmokes;
- public OnPluginStart()
- {
- HookEvent("smokegrenade_detonate", Event_SmokeDetonate);
- HookEvent("smokegrenade_expired", Event_SmokeRemoved);
- HookEvent("round_start", Event_RoundStart);
- cvarDisplayDamage = CreateConVar("sm_hitsounds_displaydamage", "1", "Display damage done to attacker", _, true, 0.0, true, 1.0);
- aSmokes = CreateArray(3);
- }
- public void OnMapStart()
- {
- PrecacheSoundAny(SOUND, true);
- PrecacheSoundAny(HS_SOUND, true);
- char temp[128];
- char temp1[128];
- Format(temp, sizeof(temp), "sound/%s", SOUND);
- Format(temp1, sizeof(temp1), "sound/%s", HS_SOUND);
- AddFileToDownloadsTable(temp);
- AddFileToDownloadsTable(temp1);
- }
- public void OnClientPutInServer(client)
- {
- SDKHook(client, SDKHook_TraceAttack, TraceAttack);
- SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- }
- public void OnClientDisconnect(client)
- {
- SDKUnhook(client, SDKHook_TraceAttack, TraceAttack);
- SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- }
- public Action:TraceAttack(client, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
- {
- if(!IsValidClient(client))
- return Plugin_Continue;
- if(!IsValidClient(attacker) || GetClientTeam(client) == GetClientTeam(attacker))
- return Plugin_Continue;
- headshot[client] = (hitgroup == 1)? true: false;
- return Plugin_Continue;
- }
- public Action:OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype)
- {
- if(!IsValidClient(client) || !IsValidClient(attacker))
- return Plugin_Continue;
- if(GetClientTeam(client) == GetClientTeam(attacker))
- return Plugin_Continue;
- int obrazenia = RoundFloat(damage);
- if(headshot[client])
- {
- if(GetConVarBool(cvarDisplayDamage))
- PrintHintText(attacker, "<font color='#E22B29'>[ZADANE OBRAŻENIA]\n<font color='#f62a2a'>[%i]</font>", obrazenia);
- EmitSoundToClientAny(attacker, HS_SOUND);
- }
- else
- {
- if(GetConVarBool(cvarDisplayDamage))
- PrintHintText(attacker, "<font color='#E22B29'>[ZADANE OBRAŻENIA]\n<font color='#dfe119'>[%i]</font>", obrazenia);
- EmitSoundToClientAny(attacker, SOUND);
- }
- return Plugin_Continue;
- }
- public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
- {
- ClearArray(aSmokes);
- }
- public Action:Event_SmokeDetonate(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new Float:Pos[3];
- Pos[0] = GetEventFloat(event, "x");
- Pos[1] = GetEventFloat(event, "y");
- Pos[2] = GetEventFloat(event, "z");
- PushArrayArray(aSmokes, Pos, 3);
- }
- public Action:Event_SmokeRemoved(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new Float:Pos[3];
- Pos[0] = GetEventFloat(event, "x");
- Pos[1] = GetEventFloat(event, "y");
- Pos[2] = GetEventFloat(event, "z");
- new numSmokes = GetArraySize(aSmokes), closest = -1, Float:closestdist = 400.0;
- for (new i = 0; i < numSmokes; i++)
- {
- decl Float:thisPos[3];
- GetArrayArray(aSmokes, i, thisPos, 3);
- new Float:dist = GetVectorDistance(Pos, thisPos);
- if (dist > closestdist) continue;
- closest = i, closestdist = dist;
- }
- if (closest == -1) return;
- RemoveFromArray(aSmokes, closest);
- }
- stock HasClearSight(client, target)
- {
- new Float:ClientPos[3], Float:TargetPos[3], Float:Result[3];
- GetClientEyePosition(client, ClientPos);
- GetClientAbsOrigin(target, TargetPos);
- TargetPos[2] += 32.0;
- MakeVectorFromPoints(ClientPos, TargetPos, Result);
- GetVectorAngles(Result, Result);
- TR_TraceRayFilter(ClientPos, Result, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf, client);
- return target == TR_GetEntityIndex();
- }
- public bool:TraceRayDontHitSelf(Ent, Mask, any:Hit)
- {
- return Ent != Hit;
- }
- public OnMapEnd()
- {
- ClearArray(aSmokes);
- }
- public bool:IsValidClient(client)
- {
- if(IsClientInGame(client) && client >= 1 && client <= MaxClients)
- return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement