-
Notifications
You must be signed in to change notification settings - Fork 3
/
[LuaScript] Better Double Tap.lua
66 lines (59 loc) · 2.24 KB
/
[LuaScript] Better Double Tap.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
-- Reference
local fakeduck = ui.reference("RAGE", "Other", "Duck peek assist")
local doubleTap = ui.reference("RAGE", "Other", "Double Tap");
-- UI Crap
local disableOnFakeDuck = ui.new_checkbox("RAGE", "Other", "Disable Double Tap On Fake Duck")
local disableOnNades = ui.new_checkbox("RAGE", "Other", "Disable Double Tap On Grenades")
local disableOnRevolver = ui.new_checkbox("RAGE", "Other", "Disable Double Tap On Revolver")
local disableOnMiss = ui.new_checkbox("RAGE", "Other", "Disable Double Tap On Miss")
local missShots = ui.new_slider("RAGE", "Other", 'Missed Shots', 0, 10, 1, true);
local resetDelay = ui.new_slider("RAGE", "Other", 'Missed Shots Reset', 1, 60, 1, true, 's');
-- Cache
local missed = 0;
local nextReset = 0;
local prev_mode;
local hotkey_modes = {
[0] = "always on",
[1] = "on hotkey",
[2] = "toggle",
[3] = "off hotkey"
}
-- Disables double tap while restoring the state thanks @sapphyrus
local function disableDoubleTap()
if ui.get(doubleTap) then
local _, mode = ui.get(doubleTap)
if prev_mode == nil then
prev_mode = mode
end
ui.set(doubleTap, hotkey_modes[mode == 3 and 1 or 3])
end
end
client.set_event_callback("paint", function()
local entindex = entity.get_local_player()
local active_weapon = entity.get_prop(entindex, "m_hActiveWeapon")
if entindex == nil or not entity.is_alive(entindex) or active_weapon == nil then
return
end
local item = bit.band((entity.get_prop(active_weapon, "m_iItemDefinitionIndex")), 0xFFFF);
if ((ui.get(disableOnMiss) and missed >= ui.get(missShots)) or
(ui.get(disableOnFakeDuck) and ui.get(fakeduck)) or
(ui.get(disableOnNades) and (item > 42 and item < 49) or
(ui.get(disableOnRevolver) and item == 64))
) then
disableDoubleTap();
elseif (prev_mode ~= nil) then
ui.set(doubleTap, hotkey_modes[prev_mode]);
prev_mode = nil;
end
if (nextReset < globals.realtime()) then
missed = 0;
nextReset = nextReset + ui.get(resetDelay);
end
end)
client.set_event_callback("shutdown", function()
-- reset on script reload
prev_mode = nil;
end)
client.set_event_callback("aim_miss", function(_)
missed = missed + 1;
end);