Repository navigation
Expand file tree
/
Copy pathCS2 Basic Hitlog.lua
More file actions
54 lines (45 loc) · 1.55 KB
/
Copy pathCS2 Basic Hitlog.lua
File metadata and controls
54 lines (45 loc) · 1.55 KB
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
local g_aHitgroups = {
[0] = "General";
[1] = "Head";
[2] = "Chest";
[3] = "Pelvis";
[4] = "Left Arm";
[5] = "Right Arm";
[6] = "Left Leg";
[7] = "Right Leg";
};
callbacks.Register("FireGameEvent", function(ctx)
if ctx:GetName() ~= "player_hurt" then
return;
end
local pVictimController = entities.GetByIndex(ctx:GetInt("userid") + 1);
local pAttackerController = entities.GetByIndex(ctx:GetInt("attacker") + 1);
if not pVictimController or not pAttackerController then
return;
end
if pVictimController:GetClass() ~= "CCSPlayerController" or pAttackerController:GetClass() ~= "CCSPlayerController" then
return;
end
local pAttackerPawn = pAttackerController:GetPropEntity("m_hPawn");
local pLocalPlayer = entities.GetLocalPlayer();
if not pAttackerPawn or not pLocalPlayer then
return;
end
if pAttackerPawn:GetIndex() ~= pLocalPlayer:GetIndex() then
return;
end
if ctx:GetInt("health") > 0 then
print(("Hurt %s in the %s for %ihp (%ihp remaining)"):format(
pVictimController:GetPropString("m_iszPlayerName"),
(g_aHitgroups[ctx:GetInt("hitgroup")] or "General"),
ctx:GetInt("dmg_health"),
ctx:GetInt("health")
));
else
print(("Killed %s with an %ihp attack to the %s"):format(
pVictimController:GetPropString("m_iszPlayerName"),
ctx:GetInt("dmg_health"),
(g_aHitgroups[ctx:GetInt("hitgroup")] or "General")
));
end
end)