cruise control add key stop - S/Space

test-utf-8
rubin 2 years ago
parent 4be235b8a7
commit fc43b75078
  1. 44
      TruckHUD.lua

@ -1020,33 +1020,41 @@ function doPickup()
end end
end end
function check_press_key(table)
local result = false
local result_key_text = ""
for i = 1, #table do
if isKeyDown(vkeys[table[i]]) then
result = true
result_key_text = table[i]:gsub("VK_", "")
break
end
end
return result, result_key_text
end
cruise = false
function doCruise() function doCruise()
if not inifiles.Settings.Cruise then return end if not inifiles.Settings.Cruise then return end
if cruise == nil then cruise = false end additional_key_stop = { "VK_W", "VK_S", "VK_SPACE" }
if not isCharInAnyCar(playerPed) then local car = storeCarCharIsInNoSave(playerPed)
if not isCharInAnyCar(playerPed) or not isCarEngineOn(car) then
if cruise then if cruise then
cruise = false cruise = false
printStringNow('~R~Cruise Control - OFF', 1500) printStringNow('~R~cruise control - OFF', 1500)
end end
return return
end end
local car = storeCarCharIsInNoSave(playerPed) if not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsCursorActive() then
if cruise and not isCarEngineOn(car) then if not cruise and isKeyDown(vkeys["VK_W"]) and isKeyDown(vkeys[inifiles.Settings.Key4]) then
cruise = false repeat
printStringNow('~R~Cruise Control - OFF', 1500) wait(100)
return until not isKeyDown(vkeys["VK_W"])
end
if not sampIsChatInputActive( ) and not sampIsDialogActive( ) and not sampIsCursorActive( ) then
if pressW ~= nil and not isKeyDown(87) then
pressW = nil
end
if not cruise and isKeyDown(87) and isKeyDown(vkeys[inifiles.Settings.Key4]) and isCarEngineOn(car) and isCharInAnyCar(playerPed) then
cruise = true cruise = true
pressW = true printStringNow('~G~cruise control - ON', 1500)
printStringNow('~G~Cruise Control - ON', 1500) elseif cruise and not isKeyDown(vkeys[inifiles.Settings.Key4]) and select(1, check_press_key(additional_key_stop)) then
elseif cruise and not isKeyDown(vkeys[inifiles.Settings.Key4]) and isKeyDown(87) and pressW == nil then
cruise = false cruise = false
printStringNow('~R~Cruise Control - OFF', 1500) printStringNow('~R~cruise control - OFF', 1500)
end end
end end
if cruise then if cruise then

Loading…
Cancel
Save