Skip to content

Commit

Permalink
Create jumpcooldown
Browse files Browse the repository at this point in the history
  • Loading branch information
monarchmatrix authored Aug 26, 2024
1 parent cabb12a commit 5e253b9
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions client/jumpcooldown
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- Initialize variables
local jumpCooldown = false
local cooldownTime = Config.jumpCooldown

-- Cooldown function
local function startJumpCooldown()
jumpCooldown = true
Citizen.CreateThread(function()
Citizen.Wait(cooldownTime * 1000) -- Wait for the cooldown time
jumpCooldown = false
end)
end

-- Main thread to handle jump key
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if not IsControlPressed(0, 25) then
if IsControlJustPressed(0, 22) then
if not jumpCooldown then
TaskJump(PlayerPedId())
startJumpCooldown()
end
end
else
end
end
end)

-- Disable the default jump when cooldown is active
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if not IsControlPressed(0, 25) then
if jumpCooldown then
DisableControlAction(0, 22, true)
end
else
EnableControlAction(0, 22, true)
end
end
end)

0 comments on commit 5e253b9

Please sign in to comment.