commit
baf5dd5e78
@ -0,0 +1,58 @@ |
||||
script_name("easy-cruise") |
||||
script_author("rubin") |
||||
script_version("22.10.26.1") |
||||
|
||||
vkeys = require("vkeys") |
||||
|
||||
main_key_start = { "VK_LSHIFT" } |
||||
additional_key_start = { "VK_W", "VK_S", "VK_SPACE" } |
||||
|
||||
function main() |
||||
repeat wait(0) until isSampAvailable() |
||||
cruise = false |
||||
while true do |
||||
wait(0) |
||||
doCruise() |
||||
end |
||||
end |
||||
|
||||
function doCruise() |
||||
local car = storeCarCharIsInNoSave(playerPed) |
||||
if not isCharInAnyCar(playerPed) or not isCarEngineOn(car) then |
||||
if cruise then |
||||
cruise = false |
||||
printStringNow('~R~cruise control - OFF', 1500) |
||||
end |
||||
return |
||||
end |
||||
if not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsCursorActive() then |
||||
if not cruise and select(1, check_press_key(additional_key_start)) and select(1, check_press_key(main_key_start)) then |
||||
repeat |
||||
wait(100) |
||||
local result, text = check_press_key(additional_key_start) |
||||
printStringNow("~G~don't press "..text, 100) |
||||
until not result |
||||
cruise = true |
||||
printStringNow('~G~cruise control - ON', 1500) |
||||
elseif cruise and not isKeyDown(vkeys["VK_LSHIFT"]) and select(1, check_press_key(additional_key_start)) then |
||||
cruise = false |
||||
printStringNow('~R~cruise control - OFF', 1500) |
||||
end |
||||
end |
||||
if cruise then |
||||
setGameKeyState(16, 255) |
||||
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 |
Loading…
Reference in new issue