Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a cooldown to jump spamming #474

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions client/jumpcooldown.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
-- Initialize variables
local QBCore = exports['qb-core']:GetCoreObject()
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)
1 change: 1 addition & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Config.PauseMapText = '' -- Text shown above
Config.HarnessUses = 20
Config.DamageNeeded = 100.0 -- amount of damage till you can push your vehicle. 0-1000
Config.Logging = 'discord' -- fivemanage
Config.jumpCooldown = 7 -- in seconds

Config.AFK = {
ignoredGroups = {
Expand Down
Loading