-
Notifications
You must be signed in to change notification settings - Fork 0
/
tf2_distance.sp
70 lines (57 loc) · 1.71 KB
/
tf2_distance.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <sourcemod>
#include <morecolors>
#include <sdktools>
#include <sdktools_sound>
#define g_soundName1 "zeleczki/event/headshot1.wav"
#define MAX_FILE_LEN 80
public Plugin:myinfo =
{
name = "Distance",
author = "Rolowy",
description = "#",
version = "1.0",
url = "#"
};
public OnPluginStart()
{
HookEvent("player_death", Event_Player_Death, EventHookMode_Pre);
}
public OnConfigsExecuted()
{
char buffer[100];
for(int x = 1; x<=7; x++)
{
Format(buffer, sizeof(buffer), "zeleczki/event/headshot%i.wav", x);
PrecacheSound(buffer, true);
Format(buffer, sizeof(buffer), "sound/%s", buffer);
AddFileToDownloadsTable(buffer);
}
}
public Event_Player_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
if(attacker != victim && attacker != 0 && victim != 0)
{
new Float:distance;
distance = GetEntitiesDistance(victim, attacker);
distance = (distance * 0.01905);
CPrintToChat(victim, "\x07fe8a71%N \x07FFFFFFkilled you from a distance of \x07fed766%.2f \x07FFFFFFmeters.", attacker, distance);
int customkill = GetEventInt(event,"customkill");
if(customkill == 1)
{
char buffer[100];
int los = GetRandomInt(1, 7);
Format(buffer, sizeof(buffer), "zeleczki/event/headshot%i.wav", los)
EmitSoundToClient(attacker, buffer);
}
}
}
stock Float:GetEntitiesDistance(ent1, ent2)
{
new Float:orig1[3];
GetEntPropVector(ent1, Prop_Send, "m_vecOrigin", orig1);
new Float:orig2[3];
GetEntPropVector(ent2, Prop_Send, "m_vecOrigin", orig2);
return GetVectorDistance(orig1, orig2);
}