-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotifyLogs.lua
271 lines (232 loc) · 6.25 KB
/
NotifyLogs.lua
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
local logs = gui.checkbox(gui.control_id('enable_logs'));
local console_logs = gui.checkbox(gui.control_id('console_logs'));
local c_logs = gui.make_control('Notify Logs', logs);
local c_con_logs = gui.make_control('Console Logs', console_logs);
local group = gui.ctx:find('lua>elements a');
group:add(c_logs);
group:reset();
group:add(c_con_logs);
group:reset();
local hitgroup = {
[0] = 'generic',
[1] = 'head',
[2] = 'chest',
[3] = 'stomach',
[4] = 'left arm',
[5] = 'right arm',
[6] = 'left leg',
[7] = 'right leg'
};
setmetatable(hitgroup, {
__index = function(_, key)
return key;
end
});
local weapon_name = {
['ak47'] = 'AK-47',
['aug'] = 'AUG',
['awp'] = 'AWP',
['bizon'] = 'PP-Bizon',
['c4'] = 'C4',
['cz75a'] = 'CZ75-Auto',
['deagle'] = 'Desert Eagle',
['decoy'] = 'Decoy',
['elite'] = 'Dual Berettas',
['famas'] = 'FAMAS',
['fists'] = 'Bare Hands',
['fiveseven'] = 'Five-SeveN',
['flashbang'] = 'Flashbang',
['g3sg1'] = 'G3SG1',
['galilar'] = 'Galil AR',
['glock'] = 'Glock-18',
['hammer'] = 'Hammer',
['healthshot'] = 'Healthshot',
['hkp2000'] = 'P2000',
['incgrenade'] = 'Molotov',
['knife'] = 'Knife',
['m249'] = 'M249',
['m4a1'] = 'M4A4',
['m4a1_silencer'] = 'M4A1-S',
['mac10'] = 'MAC-10',
['mag7'] = 'MAG-7',
['molotov'] = 'Molotov',
['mp5sd'] = 'MP5-SD',
['mp7'] = 'MP7',
['mp9'] = 'MP9',
['negev'] = 'Negev',
['nova'] = 'Nova',
['p250'] = 'P250',
['p90'] = 'P90',
['revolver'] = 'R8 Revolver',
['sawedoff'] = 'Sawed-Off',
['scar20'] = 'SCAR-20',
['sg556'] = 'SG 553',
['smokegrenade'] = 'Smoke',
['ssg08'] = 'SSG 08',
['taser'] = 'Zeus',
['tec9'] = 'Tec-9',
['ump45'] = 'UMP-45',
['usp_silencer'] = 'USP-S',
['xm1014'] = 'XM1014',
['hegrenade'] = 'HE Grenade',
['inferno'] = 'Fire'
};
setmetatable(weapon_name, {
__index = function(_, key)
return 'undefined';
end
});
local fuck_valve = {
['weapon_revolver'] = 'R8 Revolver',
['weapon_usp_silencer'] = 'USP-S',
['weapon_m4a1_silencer'] = 'M4A1-S',
['weapon_mp5sd'] = 'MP5-SD',
['weapon_cz75a'] = 'CZ75-Auto'
};
setmetatable(fuck_valve, {
__index = function(_, key)
return key;
end
});
local bomb_events = {
['bomb_beginplant'] = ' Began planting the bomb',
['bomb_abortplant'] = ' Cancelled planting the bomb',
['bomb_planted'] = ' Planted the bomb',
['bomb_defused'] = ' Defused the bomb',
['bomb_exploded'] = ' Exploded the bomb'
};
setmetatable(bomb_events, {
__index = function(_, key)
return key;
end
});
local round_events = {
['round_start'] = {'Round started!', 'Buy weapons and FIGHT!!!'},
['round_end'] = {'Round end.', 'Better luck next time.'}
};
setmetatable(round_events, {
__index = function(_, key)
return {key, 'undefined'};
end
});
local function bomb_logs(event, console, notify)
local userid = 'undefined';
if event:get_controller('userid') ~= nil then
userid = event:get_controller('userid'):get_name();
end
local message = '<'..
userid..
'>'..
bomb_events[event:get_name()];
if console then
print(message);
end
if notify then
gui.notify:add(gui.notification(
'<'..
userid..
'>',
bomb_events[event:get_name()],
draw.textures['icon_visuals']));
end
end
local function hit_logs(event, console, notify)
local weapon = 'undefined';
local event_weapon = event:get_string('weapon');
local attacker_weapon = event:get_pawn_from_id('attacker'):get_active_weapon():get_data().name;
if weapon_name[event_weapon] ~= 'undefined' and fuck_valve[attacker_weapon] == attacker_weapon then
weapon = weapon_name[event_weapon];
else
weapon = fuck_valve[attacker_weapon];
end
local userid = 'undefined';
if event:get_controller('userid') ~= nil then
userid = event:get_controller('userid'):get_name();
end
local message = 'Hit <'
..userid..
'> for '
..event:get_int('dmg_health')..
' ('
..event:get_int('health')..
') hp in '
..hitgroup[event:get_int('hitgroup')]..
' with '
..weapon;
if console then
print(message);
end
if notify then
gui.notify:add(gui.notification(
'Hit!',
message,
draw.textures['icon_rage']));
end
end
local function hurt_logs(event, console, notify)
local attacker = 'undefined';
if event:get_controller('attacker') ~= nil then
attacker = event:get_controller('attacker'):get_name();
end
local message = 'Hurt by <'
..attacker..
'> for '
..event:get_int('dmg_health')..
' ('
..event:get_int('health')..
') hp in '
..hitgroup[event:get_int('hitgroup')]..
' with '
..weapon_name[event:get_string('weapon')];
if console then
print(message);
end
if notify then
gui.notify:add(gui.notification(
'Hurt!',
message,
draw.textures['icon_legit']));
end
end
local function round_logs(event, console, notify)
local event_name = event:get_name();
local message = round_events[event_name];
if event:get_string('message') ~= nil then
if string.find(event:get_string('message'), '_Terrorists') then
message[2] = 'Terrorists win!';
elseif string.find(event:get_string('message'), '_CTs_') then
message[2] = 'Counter-Terrorists win!';
end
end
if console then
print(message[1]..message[2]);
end
if notify then
gui.notify:add(gui.notification(
message[1],
message[2],
draw.textures['icon_visuals']));
end
end
local function on_event(event)
local l = logs:get_value():get();
local c = console_logs:get_value():get();
local e = event:get_name();
if l or c then
if e == 'player_hurt' then
if event:get_controller('attacker') == entities.get_local_controller() then
return hit_logs(event, c, l);
elseif event:get_controller('userid') == entities.get_local_controller() then
return hurt_logs(event, c, l);
end
end
if string.find(e, 'round_') then
return round_logs(event, c, l);
end
if string.find(e, 'bomb_') then
return bomb_logs(event, c, l);
end
end
end
mods.events:add_listener('round_end');
events.event:add(on_event);