Im making a script for sprinting for my TTT server and i need help.
How do i go about checking whether the player double tapped 'w'?
How do i set the speed faster if they do?
[lua]local PRESS_TIME = 0.1
local SPEED_MULTIPLYER = 1.5
hook.Add("KeyPress", "DumbDoubleTap", function(ply, pressed)
if pressed == IN_FORWARD then
if CurTime() - ply.LastPress <= PRESS_TIME then
ply.Sprinting = true
ply.LastPress = CurTime() + 0.1
else
ply.LastPress = CurTime()
end
end
end)
hook.Add("KeyRelease", "DumbUNDoubleTap", function(ply, pressed)
if pressed == IN_FORWARD and ply.Sprinting then
ply.Sprinting = false
end
end)
local plymeta = FindMetaTable("Player")
plymeta.OldSetSpeed = plymeta.OldSetSpeed or plymeta.SetSpeed
function plymeta:SetSpeed(slowed)
if slowed then
self:OldSetSpeed(slowed)
else
self:SetWalkSpeed(220 * SPEED_MULTIPLYER)
self:SetRunSpeed(220 * SPEED_MULTIPLYER)
self:SetMaxSpeed(220 * SPEED_MULTIPLYER)
end
end[/lua]
That probably works, if it doesn't I don't care.
Also badking complained a lot about how ULX does stupid stuff with hooks in TTT, but that setspeed stuff is garbage.
Sorry, you need to Log In to post a reply to this thread.