-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathautowalk.lua
More file actions
49 lines (43 loc) · 1.53 KB
/
autowalk.lua
File metadata and controls
49 lines (43 loc) · 1.53 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
PLUGIN.name = 'Auto Walk'
PLUGIN.author = 'NightAngel (Ported from Flux)'
PLUGIN.description = 'Allows users to press a button to automatically walk forward.'
PLUGIN.button = KEY_N
if SERVER then
PLUGIN.check = {
[IN_FORWARD] = true,
[IN_BACK] = true,
[IN_MOVELEFT] = true,
[IN_MOVERIGHT] = true,
[IN_JUMP] = true
}
function PLUGIN:SetupMove(client, move_data, cmd_data)
if not client:GetNetVar('auto_walk', false) then return end
move_data:SetForwardSpeed(move_data:GetMaxSpeed())
for k in pairs(self.check) do
if cmd_data:KeyDown(k) then
client:SetNetVar('auto_walk', false)
break
end
end
end
concommand.Add('ix_toggleautowalk', function(client)
if hook.Run('CanPlayerAutoWalk', client) ~= false then
client:SetNetVar('auto_walk', not client:GetNetVar('auto_walk', false))
end
end)
function PLUGIN:CanPlayerAutoWalk(client)
return true
end
else
function PLUGIN:SetupMove(client, move_data, cmd_data)
if not client:GetNetVar('auto_walk', false) then return end
move_data:SetForwardSpeed(move_data:GetMaxSpeed())
end
function PLUGIN:PlayerButtonDown(client, button)
if button == self.button then
if (client.ixNextAWToggle || 0) > CurTime() then return end
RunConsoleCommand('ix_toggleautowalk')
client.ixNextAWToggle = CurTime() + 1
end
end
end