Skip to content

Commit

Permalink
fix: allow searching keys only when in drivers seat and prevent bypas…
Browse files Browse the repository at this point in the history
…sing cooldown
  • Loading branch information
Manason authored Sep 10, 2024
1 parent 03f9c3a commit 86f1cfa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,20 @@ local function findKeys(vehicleModel, vehicleClass, plate, vehicle)
end
end

local isSearchLocked = false
local isSearchAllowed = false
local function setSearchLabelState(isAllowed)
if isSearchLocked and isAllowed then return end
local isOpen, text = lib.isTextUIOpen()
local newText = locale('info.search_keys_dispatch')
local isValidMessage = text and text == newText
if isAllowed and not isValidMessage then
if isAllowed and not isValidMessage and cache.seat == -1 then
lib.showTextUI(newText)
elseif not isAllowed and isOpen and isValidMessage then
elseif (not isAllowed or cache.seat ~= -1) and isOpen and isValidMessage then
lib.hideTextUI()
end

isSearchAllowed = isAllowed
isSearchAllowed = isAllowed and cache.seat == -1
end

local isShowHotwiringLabelRunning = false
Expand Down Expand Up @@ -310,6 +312,7 @@ lib.addKeybind({
secondaryKey = 'LRIGHT_INDEX',
onPressed = function()
if isSearchAllowed and cache.vehicle then
isSearchLocked = true
setSearchLabelState(false)
local vehicle = cache.vehicle
local plate = qbx.getVehiclePlate(vehicle)
Expand All @@ -321,6 +324,7 @@ lib.addKeybind({
end)
end
Wait(config.timeBetweenHotwires)
isSearchLocked = false
setSearchLabelState(not isFound)
end
end
Expand Down

0 comments on commit 86f1cfa

Please sign in to comment.