forked from ztxs/Aimware-v5-luas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoHoldpos.lua
90 lines (63 loc) · 2.5 KB
/
AutoHoldpos.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
------Auto Hold Postion by Mario------
local players = entities.FindByClass( "CCSPlayer" )
local isBot = false
--AW Gui--
local Ref_BotCmd = gui.Reference("MISC", "AUTOMATION", "Other");
local CC_Text2 = gui.Text(Ref_BotCmd, "#~#~ Bots HoldPosition ~#~#")
local Checkbox_BotCmd = gui.Checkbox( Ref_BotCmd, "msc_holdpos_active", "Auto Hold Position", 0 );
--Timer--
local timer = timer or {}
local timers = {}
---------
function checkBot() --Checking if there is a Bot in your team (*exept u)
for i = 1, #players do
local player = players[ i ];
botDificulty = entities.GetPlayerResources():GetPropInt("m_iBotDifficulty", player:GetIndex());
if player:GetTeamNumber() == entities.GetLocalPlayer():GetTeamNumber() then
if botDificulty >= 0 then --Yup... I am to dumb and lazy to find a proper way
isBot = true
return true
else
isBot = false
return false
end
else
end
end
end
function holdPos(event) --Holdpos function
if (event:GetName() == "round_freeze_end") then
if Checkbox_BotCmd:GetValue() then
checkBot()
if (isBot() == true) then
timer.Create("holdpos_delay", 1.0, 1, function()
client.Command("holdpos", true)
end)
end
end
end
end
client.AllowListener("round_freeze_end")
callbacks.Register("FireGameEvent", holdPos);
----------------------GLuaTimer---------------------------
--Timer by imacookie https://aimware.net/forum/thread-86687.html?highlight=glua+Timer
function timer.Create(name, delay, times, func)
table.insert(timers, {["name"] = name, ["delay"] = delay, ["times"] = times, ["func"] = func, ["lastTime"] = globals.RealTime()})
end
function timer.Remove(name)
for k,v in pairs(timers or {}) do
if (name == v["name"]) then table.remove(timers, k) end
end
end
function timer.Tick()
for k,v in pairs(timers or {}) do
if (v["times"] <= 0) then table.remove(timers, k) end
if (v["lastTime"] + v["delay"] <= globals.RealTime()) then
timers[k]["lastTime"] = globals.RealTime()
timers[k]["times"] = timers[k]["times"] - 1
v["func"]()
end
end
end
callbacks.Register( "Draw", timer.Tick);
--------------------------------------------------------------