Skip to content

Instantly share code, notes, and snippets.

@banagale
Last active April 25, 2017 19:08
Show Gist options
  • Save banagale/6460f1b9d876c4dda0f1f4ebb06f9ec5 to your computer and use it in GitHub Desktop.
Save banagale/6460f1b9d876c4dda0f1f4ebb06f9ec5 to your computer and use it in GitHub Desktop.
-- Realistic Vehicle Controls v1.3.1
-- by skyrayfox
-- Changelog:
-- 1.3.1
-- library hotfix
-- 1.3:
-- Auto-Drive to waypoint (AI will try to follow all traffic code, press "W,S or Space" to disengage)
-- Auto-Patrol the area (AI will randomly drive the vehicle around, following the fraffic code)
-- You can now open and close all individual car doors
-- New Mod Menu design and navigation improvements
-- Mod menu bug fixes and new notification options
-- Turn Indicators and Emergency Lights improvements
-- Hotkeys: "F3" or "/" (numpad divide) to toggle open/close mod menu, backspace also works for closing the menu
-- Hotkeys: You can now activate mod menu options with "Space" OR "NumPad 5"
-- Hotkeys: Hold "F" to exit with vehicle engine off GTA4 style (alternative to Ctrl+F)
-- Hotkeys: "Ctrl+S" is now Emergency Lights, "Shift+S" Brake Lights
-- Hotkeys: "Shift+X" for Auto Patrol mode
-- Hotkeys: "Shift+W" for Auto Drive to waypoint
-- 1.2:
-- New hotkey "+" for skipping radio songs
-- New hotkey "Shift+S" for emergency lights
-- Cruise Control is now smoother
-- Cruise Control should now disengage when wehicle is flying or at slow speeds/crashing
-- Lights no longer flicker when exiting vehicles or in cruise mode
-- New - Toggle Brake Lights as always on or always on when stationary
-- 1.1:
-- Hotfix for GUI.lua file
-- CONFIGURE KEYS BELOW - defaults listen on the right:
key = {}
key.closemenu = 8 -- "backspace"
key.openmenu = 114 -- "F3" -- open/close mod menu
key.openmenu2 = 111 -- "/" (numpad divide) alternative open/close mod menu button
key.enterveh = 70 -- "F"
key.driveforwards = 87 -- "W" drive forward key (used to disengage cruise)
key.drivebackwards = 83 -- "S" drive backward key (used to disengage cruise)
key.handbrake = 32 -- "space" key used for handbraking (used to disengage cruise)
key.ctrl = 17 -- "Control" modifier used with the keys below (eg. Ctrl+A for left turn signal)
key.turnleft = 65 -- "A" left turn signal
key.turnright = 68 -- "D" right turn signal
key.emergencylights = 83 -- "S" emergency lights
key.siren = 90 -- "Z" blip police siren
key.cruise = 87 -- "W" toggle cruise
key.autodrive = 87 -- "W" toggle auto drive to waypoint
key.engine = 88 -- "X" toggle engine
key.skipsong = 187 -- "+" skip current radio song
key.shift = 16 -- "Shift" modifier used with keys below (eg Shift+X for auto patrol)
key.brakelights = 83 -- "S" brake lights
key.patrol = 88 -- "X" auto patrol
-- KEY CODES:
------------------------------------
-- Keys.None = 0
-- Keys.LButton = 1
-- Keys.RButton = 2
-- Keys.Cancel = 3
-- Keys.MButton = 4
-- Keys.XButton1 = 5
-- Keys.XButton2 = 6
-- Keys.Back = 8
-- Keys.Tab = 9
-- Keys.LineFeed = 10
-- Keys.Clear = 12
-- Keys.Return = 13
-- Keys.ShiftKey = 16
-- Keys.ControlKey = 17
-- Keys.Menu = 18
-- Keys.Pause = 19
-- Keys.Capital = 20
-- Keys.KanaMode = 21
-- Keys.JunjaMode = 23
-- Keys.FinalMode = 24
-- Keys.HanjaMode = 25
-- Keys.Escape = 27
-- Keys.IMEConvert = 28
-- Keys.IMENonconvert = 29
-- Keys.IMEAceept = 30
-- Keys.IMEModeChange = 31
-- Keys.Space = 32
-- Keys.PageUp = 33
-- Keys.Next = 34
-- Keys.End = 35
-- Keys.Home = 36
-- Keys.Left = 37
-- Keys.Up = 38
-- Keys.Right = 39
-- Keys.Down = 40
-- Keys.Select = 41
-- Keys.Print = 42
-- Keys.Execute = 43
-- Keys.PrintScreen = 44
-- Keys.Insert = 45
-- Keys.Delete = 46
-- Keys.Help = 47
-- Keys.D0 = 48
-- Keys.D1 = 49
-- Keys.D2 = 50
-- Keys.D3 = 51
-- Keys.D4 = 52
-- Keys.D5 = 53
-- Keys.D6 = 54
-- Keys.D7 = 55
-- Keys.D8 = 56
-- Keys.D9 = 57
-- Keys.A = 65
-- Keys.B = 66
-- Keys.C = 67
-- Keys.D = 68
-- Keys.E = 69
-- Keys.F = 70
-- Keys.G = 71
-- Keys.H = 72
-- Keys.I = 73
-- Keys.J = 74
-- Keys.K = 75
-- Keys.L = 76
-- Keys.M = 77
-- Keys.N = 78
-- Keys.O = 79
-- Keys.P = 80
-- Keys.Q = 81
-- Keys.R = 82
-- Keys.S = 83
-- Keys.T = 84
-- Keys.U = 85
-- Keys.V = 86
-- Keys.W = 87
-- Keys.X = 88
-- Keys.Y = 89
-- Keys.Z = 90
-- Keys.LWin = 91
-- Keys.RWin = 92
-- Keys.Apps = 93
-- Keys.Sleep = 95
-- Keys.NumPad0 = 96
-- Keys.NumPad1 = 97
-- Keys.NumPad2 = 98
-- Keys.NumPad3 = 99
-- Keys.NumPad4 = 100
-- Keys.NumPad5 = 101
-- Keys.NumPad6 = 102
-- Keys.NumPad7 = 103
-- Keys.NumPad8 = 104
-- Keys.NumPad9 = 105
-- Keys.Multiply = 106
-- Keys.Add = 107
-- Keys.Separator = 108
-- Keys.Subtract = 109
-- Keys.Decimal = 110
-- Keys.Divide = 111
-- Keys.F1 = 112
-- Keys.F2 = 113
-- Keys.F3 = 114
-- Keys.F4 = 115
-- Keys.F5 = 116
-- Keys.F6 = 117
-- Keys.F7 = 118
-- Keys.F8 = 119
-- Keys.F9 = 120
-- Keys.F10 = 121
-- Keys.F11 = 122
-- Keys.F12 = 123
-- Keys.F13 = 124
-- Keys.F14 = 125
-- Keys.F15 = 126
-- Keys.F16 = 127
-- Keys.F17 = 128
-- Keys.F18 = 129
-- Keys.F19 = 130
-- Keys.F20 = 131
-- Keys.F21 = 132
-- Keys.F22 = 133
-- Keys.F23 = 134
-- Keys.F24 = 135
-- Keys.NumLock = 144
-- Keys.Scroll = 145
-- Keys.LShiftKey = 160
-- Keys.RShiftKey = 161
-- Keys.LControlKey = 162
-- Keys.RControlKey = 163
-- Keys.LMenu = 164
-- Keys.RMenu = 165
-- Keys.BrowserBack = 166
-- Keys.BrowserForward = 167
-- Keys.BrowserRefresh = 168
-- Keys.BrowserStop = 169
-- Keys.BrowserSearch = 170
-- Keys.BrowserFavorites = 171
-- Keys.BrowserHome = 172
-- Keys.VolumeMute = 173
-- Keys.VolumeDown = 174
-- Keys.VolumeUp = 175
-- Keys.MediaNextTrack = 176
-- Keys.MediaPreviousTrack = 177
-- Keys.MediaStop = 178
-- Keys.MediaPlayPause = 179
-- Keys.LaunchMail = 180
-- Keys.SelectMedia = 181
-- Keys.LaunchApplication1 = 182
-- Keys.LaunchApplication2 = 183
-- Keys.Oem1 = 186
-- Keys.Oemplus = 187
-- Keys.Oemcomma = 188
-- Keys.OemMinus = 189
-- Keys.OemPeriod = 190
-- Keys.OemQuestion = 191
-- Keys.Oemtilde = 192
-- Keys.OemOpenBrackets = 219
-- Keys.Oem5 = 220
-- Keys.Oem6 = 221
-- Keys.Oem7 = 222
-- Keys.Oem8 = 223
-- Keys.OemBackslash = 226
-- Keys.ProcessKey = 229
-- Keys.Packet = 231
-- Keys.Attn = 246
-- Keys.Crsel = 247
-- Keys.Exsel = 248
-- Keys.EraseEof = 249
-- Keys.Play = 250
-- Keys.Zoom = 251
-- Keys.NoName = 252
-- Keys.Pa1 = 253
-- Keys.OemClear = 254
-- Keys.KeyCode = 65535
-- Keys.Shift = 65536
-- Keys.Control = 131072
-- Keys.Alt = 262144
-- Keys.Modifiers = -65536
------------------------------------
local rvc = {}
local isDoorOpen = false
local isAllLightsOn = false
local isLeftIndicatorOn = false
local isRightIndicatorOn = false
local isEmergencyIndicatorOn = false
local isInteriorLightOn = false
local isBrakeLightOn = false
local isExtraLightOn = false
local isEngineOn = true
local isBrakeLightOnWhenStopped = false
local isAutoDriveOn = false
local isAutoPatrolOn = false
local isUInotificationsOn = true
local setCruiseSpeed = 0
local texttick = 0
local ui = {}
function rvc.tick()
-- variables
playerPed = PLAYER.PLAYER_PED_ID()
player = PLAYER.GET_PLAYER_PED(playerPed)
playerVehicle = PED.GET_VEHICLE_PED_IS_USING(playerPed)
playerVehicleSpeed = ENTITY.GET_ENTITY_SPEED(playerVehicle)
isPlayerDriving = (VEHICLE.GET_PED_IN_VEHICLE_SEAT(playerVehicle, -1) == playerPed)
playerVehicleHealth = VEHICLE.GET_VEHICLE_ENGINE_HEALTH(playerVehicle)
-- variables end
-- run UI
rvc.rvcGUI.tick()
-- hide UI
if(get_key_pressed(key.closemenu)) then
rvc.rvcGUI.hidden = true
end
-- show UI
if(get_key_pressed(key.openmenu) or get_key_pressed(key.openmenu2)) then
if rvc.rvcGUI.hidden == true then
rvc.rvcGUI.hidden = false
else
rvc.rvcGUI.hidden = true
end
wait(200)
end
-- "F" leave vehicle with engine on, hold "F" leave to leav veh with engine off
if(get_key_pressed(key.enterveh)) and isPlayerDriving then
rvc.keyDelay()
if(get_key_pressed(key.enterveh)) then
rvc.leaveVehicleEngineOff()
else
rvc.leaveVehicle()
end
end
-- "Ctrl+F" leave veh with engine off, alternative
if(get_key_pressed(key.enterveh) and get_key_pressed(key.ctrl)) and isPlayerDriving then
if (isPlayerDriving == true) then
rvc.leaveVehicleEngineOff()
end
end
-- "Ctrl+A" toggle left indicator
if get_key_pressed(key.turnleft) and get_key_pressed(key.ctrl) and isPlayerDriving then
rvc.toggleLeftIndicator()
end
-- "Ctrl+D" toggle right indicator
if get_key_pressed(key.turnright) and get_key_pressed(key.ctrl) and isPlayerDriving then
rvc.toggleRightIndicator()
end
-- "Shift+S" toggle emergency lights indicator
if get_key_pressed(key.emergencylights) and get_key_pressed(key.ctrl) and isPlayerDriving then
rvc.toggleEmergencyIndicator()
end
-- "Ctrl+S" toggle brake lights
if get_key_pressed(key.brakelights) and get_key_pressed(key.shift) and isPlayerDriving then
isBrakeLightOn = not isBrakeLightOn
rvc.updateMenus("BRAKE LIGHTS - ", isBrakeLightOn)
rvc.keyDelay()
end
if (isBrakeLightOn == true) then
VEHICLE.SET_VEHICLE_BRAKE_LIGHTS(playerVehicle, true)
end
-- blip siren "Ctrl+Z" (police cars only)
if get_key_pressed(key.siren) and get_key_pressed(key.ctrl) then
rvc.blipSiren()
end
-- cruise control
if (setCruiseSpeed ~= 0) and (VEHICLE.IS_VEHICLE_ON_ALL_WHEELS(playerVehicle)) then
-- turn on cruise only if player veh speed is above 10
if (playerVehicleSpeed > 5) then
VEHICLE.SET_VEHICLE_FORWARD_SPEED(playerVehicle, setCruiseSpeed)
rvc.updateMenus("CRUISE MODE - ON ", nil)
end
-- turn off cruise if slowing down/speeding up/ flying
if get_key_pressed(key.drivebackwards) or get_key_pressed(key.driveforwards) or get_key_pressed(key.handbrake) or (VEHICLE.IS_VEHICLE_ON_ALL_WHEELS(playerVehicle) == false) or (playerVehicleSpeed < 4) then
setCruiseSpeed = 0
rvc.updateMenus("CRUISE MODE - OFF ", nil)
end
end
-- "Ctrl+W" turn on cruise control
if get_key_pressed(key.cruise) and get_key_pressed(key.ctrl) and isPlayerDriving then
rvc.toggleCruise()
end
-- "Shift+W" auto-drive to waypoint
if get_key_pressed(key.autodrive) and get_key_pressed(key.shift) and isPlayerDriving then
rvc.toggleAIDriveToWaypoint()
end
-- turn off auto-drive if slowing down/speeding up/ flying
if isAutoDriveOn and isPlayerDriving then
if get_key_pressed(key.drivebackwards) or get_key_pressed(key.driveforwards) or get_key_pressed(key.handbrake) then
isAutoDriveOn = false
AI.TASK_PAUSE(playerPed, 1)
rvc.updateMenus("AUTO DRIVE MODE TO WAYPOINT - OFF", nil)
end
end
-- "Shift+X" turn on auto patrol
if get_key_pressed(key.patrol) and get_key_pressed(key.shift) and isPlayerDriving then
rvc.toggleAIPatrol()
end
-- turn off auto-patrol if slowing down/speeding up/flying
if isAutoPatrolOn and isPlayerDriving then
if get_key_pressed(key.drivebackwards) or get_key_pressed(key.driveforwards) or get_key_pressed(key.handbrake) then
isAutoPatrolOn = false
AI.TASK_PAUSE(playerPed, 1)
rvc.updateMenus("AUTO PATROL MODE - OFF", nil)
end
end
-- "Ctrl+X" toggle engine
if get_key_pressed(key.engine) and get_key_pressed(key.ctrl) and isPlayerDriving then
rvc.toggleEngine()
rvc.keyDelay()
end
if (isEngineOn == false) then
VEHICLE.SET_VEHICLE_ENGINE_ON(playerVehicle, false, true)
end
-- turn engine on if moving forward or backward
if get_key_pressed(key.drivebackwards) or get_key_pressed(key.driveforwards) then
isEngineOn = true
end
-- "+" skip radio song
if get_key_pressed(key.skipsong) then
rvc.skipSong()
end
--toggle brake lights on when stationary and enabled
if (math.floor(playerVehicleSpeed) == 0) and (isAllLightsOn == false) and (isBrakeLightOnWhenStopped == true) then
VEHICLE.SET_VEHICLE_BRAKE_LIGHTS(playerVehicle, true)
end
-- show HUD status messages
texttick = texttick + 1
rvc.draw_text2(textmsg)
end
function rvc.booltoint(bool)
if bool then
return 1
else
return 0
end
end
function rvc.booltochar(bool)
if bool then
return "ON"
else
return "OFF"
end
end
-- draw text on screen
function rvc.draw_text(text, x, y, scale)
UI.SET_TEXT_FONT(1)
UI.SET_TEXT_SCALE(scale, scale)
UI.SET_TEXT_COLOUR(255, 255, 255, 255)
UI.SET_TEXT_WRAP(0.0, 1.0)
UI.SET_TEXT_CENTRE(true)
UI.SET_TEXT_DROPSHADOW(2, 2, 0, 0, 0)
UI.SET_TEXT_EDGE(1, 0, 0, 0, 205)
UI._SET_TEXT_ENTRY("STRING")
UI._ADD_TEXT_COMPONENT_STRING(text)
UI._DRAW_TEXT(y, x)
end
function rvc.draw_text2(text)
if texttick < 100 then
rvc.draw_text(text, 0.95, 0.5, 0.5)
end
end
-- update screen text message, eg. "EMERGENCY LIGHTS - ON"
function rvc.updateMenus(text, bool)
if bool ~= nil then
if isUInotificationsOn then
textmsg = text .. rvc.booltochar(bool)
end
-- update menu button
rvc.rvcGUI.updateButtonStatus(rvc.booltochar(bool))
else
if isUInotificationsOn then
textmsg = text
end
end
if (isUInotificationsOn == false) then
textmsg = ""
end
texttick = 0
end
function rvc.keyDelay()
wait(100)
end
function rvc.toggleUINotifications()
isUInotificationsOn = not isUInotificationsOn
rvc.updateMenus("UI NOTIFICATIONS - ", isUInotificationsOn)
end
function rvc.brakeLightsWhenStopped()
isBrakeLightOnWhenStopped = not isBrakeLightOnWhenStopped
rvc.updateMenus("BRAKE LIGHTS WHEN STOPPED - ", isBrakeLightOnWhenStopped)
end
function rvc.fixTyre()
VEHICLE.SET_VEHICLE_TYRE_FIXED(playerVehicle, 0)
VEHICLE.SET_VEHICLE_TYRE_FIXED(playerVehicle, 1)
VEHICLE.SET_VEHICLE_TYRE_FIXED(playerVehicle, 2)
VEHICLE.SET_VEHICLE_TYRE_FIXED(playerVehicle, 3)
VEHICLE.SET_VEHICLE_TYRE_FIXED(playerVehicle, 4)
VEHICLE.SET_VEHICLE_TYRE_FIXED(playerVehicle, 5)
rvc.updateMenus("CHANGING TYRES", nil)
end
function rvc.blipSiren()
AUDIO.BLIP_SIREN(playerVehicle)
end
function rvc.toggleEngine()
isEngineOn = not isEngineOn
rvc.updateMenus("ENGINE - ", isEngineOn)
end
function rvc.cleanVehicle()
VEHICLE.SET_VEHICLE_DIRT_LEVEL(playerVehicle, 0)
rvc.updateMenus("CLEANING VEHICLE", nil)
end
function rvc.fixVehicle()
VEHICLE.SET_VEHICLE_FIXED(playerVehicle)
rvc.updateMenus("FIXING VEHICLE", nil)
end
function rvc.toggleCruise()
setCruiseSpeed = playerVehicleSpeed
setCruiseSpeed = math.floor(setCruiseSpeed)
end
function rvc.toggleAIDriveToWaypoint()
isAutoDriveOn = not isAutoDriveOn
if isAutoDriveOn and UI.IS_WAYPOINT_ACTIVE() and isPlayerDriving then
waypointID = UI.GET_FIRST_BLIP_INFO_ID(UI._GET_BLIP_INFO_ID_ITERATOR())
waypointCoord = UI.GET_BLIP_COORDS(waypointID)
AI.TASK_VEHICLE_DRIVE_TO_COORD(playerPed, playerVehicle, waypointCoord.x, waypointCoord.y, waypointCoord.z, 30, 1,ENTITY.GET_ENTITY_MODEL(playerVehicle), 1, 0xC00AB, -1)
rvc.updateMenus("AUTO DRIVE TO WAYPOINT - ON", nil)
elseif (UI.IS_WAYPOINT_ACTIVE() == false) then
rvc.updateMenus("NO WAYPOINT SELECTED", nil)
else
isAutoDriveOn = false
AI.TASK_PAUSE(playerPed, 1)
rvc.updateMenus("AUTO DRIVE TO WAYPOINT - OFF", nil)
end
rvc.keyDelay()
end
function rvc.toggleAIPatrol()
isAutoPatrolOn = not isAutoPatrolOn
if isAutoPatrolOn and isPlayerDriving then
AI.TASK_VEHICLE_DRIVE_WANDER(playerPed, playerVehicle, 30, 0xC00AB)
rvc.updateMenus("PATROL MODE - ON", nil)
else
isAutoPatrolOn = false
AI.TASK_PAUSE(playerPed, 1)
rvc.updateMenus("PATROL MODE - OFF", nil)
end
rvc.keyDelay()
end
function rvc.toggleAllLights()
isAllLightsOn = not isAllLightsOn
VEHICLE.SET_VEHICLE_LIGHTS(playerVehicle, rvc.booltoint(isAllLightsOn))
rvc.updateMenus("TURN OFF ALL LIGHTS - ", isAllLightsOn)
end
function rvc.toggleEmergencyIndicator()
isEmergencyIndicatorOn = not isEmergencyIndicatorOn
isLeftIndicatorOn = false
isRightIndicatorOn = false
VEHICLE.SET_VEHICLE_INDICATOR_LIGHTS(playerVehicle, true, isEmergencyIndicatorOn)
VEHICLE.SET_VEHICLE_INDICATOR_LIGHTS(playerVehicle, false, isEmergencyIndicatorOn)
rvc.updateMenus("EMERGENCY LIGHTS - ", isEmergencyIndicatorOn)
rvc.keyDelay()
end
function rvc.toggleLeftIndicator()
isLeftIndicatorOn = not isLeftIndicatorOn
if isRightIndicatorOn then
VEHICLE.SET_VEHICLE_INDICATOR_LIGHTS(playerVehicle, false, false)
isRightIndicatorOn = not isRightIndicatorOn
end
if isEmergencyIndicatorOn then
VEHICLE.SET_VEHICLE_INDICATOR_LIGHTS(playerVehicle, false, false)
isEmergencyIndicatorOn = not false
end
VEHICLE.SET_VEHICLE_INDICATOR_LIGHTS(playerVehicle, true, isLeftIndicatorOn)
rvc.updateMenus("LEFT INDICATOR - ", isLeftIndicatorOn)
rvc.keyDelay()
end
function rvc.toggleRightIndicator()
isRightIndicatorOn = not isRightIndicatorOn
if isLeftIndicatorOn then
VEHICLE.SET_VEHICLE_INDICATOR_LIGHTS(playerVehicle, true, false)
isLeftIndicatorOn = not isLeftIndicatorOn
end
if isEmergencyIndicatorOn then
VEHICLE.SET_VEHICLE_INDICATOR_LIGHTS(playerVehicle, true, false)
isEmergencyIndicatorOn = false
end
VEHICLE.SET_VEHICLE_INDICATOR_LIGHTS(playerVehicle, false, isRightIndicatorOn)
rvc.updateMenus("RIGHT INDICATOR - ", isRightIndicatorOn)
rvc.keyDelay()
end
function rvc.toggleBrakeLights()
isBrakeLightOn = not isBrakeLightOn
rvc.updateMenus("BRAKE LIGHTS - ", isBrakeLightOn)
rvc.keyDelay()
end
function rvc.openDoors(doorIndex)
isDoorOpen = not isDoorOpen
if isDoorOpen and texttick < 10 then
VEHICLE.SET_VEHICLE_DOOR_OPEN(playerVehicle, doorIndex, true, false)
elseif texttick > 10 then
VEHICLE.SET_VEHICLE_DOOR_SHUT(playerVehicle, doorIndex, true)
end
rvc.updateMenus("OPENING DOOR - ".. doorIndex, nil)
end
function rvc.closeDoors()
VEHICLE.SET_VEHICLE_DOORS_SHUT(playerVehicle, true)
rvc.updateMenus("CLOSING DOORS", nil)
end
function rvc.openWindows()
VEHICLE.ROLL_DOWN_WINDOWS(playerVehicle)
rvc.updateMenus("OPENING WINDOWS", nil)
end
function rvc.closeWindows()
VEHICLE.ROLL_UP_WINDOW(playerVehicle,0)
VEHICLE.ROLL_UP_WINDOW(playerVehicle,1)
VEHICLE.ROLL_UP_WINDOW(playerVehicle,2)
VEHICLE.ROLL_UP_WINDOW(playerVehicle,3)
rvc.updateMenus("CLOSING WINDOWS", nil)
end
function rvc.leaveVehicle()
AI.TASK_LEAVE_VEHICLE(playerPed, playerVehicle, 8)
VEHICLE.SET_VEHICLE_ENGINE_ON(playerVehicle, true, true)
end
function rvc.leaveVehicleEngineOff()
AI.TASK_LEAVE_VEHICLE(playerPed, playerVehicle, 8)
VEHICLE.SET_VEHICLE_ENGINE_ON(playerVehicle, false, true)
end
function rvc.toggleInteriorLight()
isInteriorLightOn = not isInteriorLightOn
VEHICLE.SET_VEHICLE_INTERIORLIGHT(playerVehicle, isInteriorLightOn)
rvc.updateMenus("INTERIOR LIGHT - ", isInteriorLightOn)
rvc.keyDelay()
end
function rvc.toggleExtraLight()
isExtraLightOn = not isExtraLightOn
VEHICLE.SET_TAXI_LIGHTS(playerVehicle, isExtraLightOn)
VEHICLE.SET_VEHICLE_SEARCHLIGHT(playerVehicle, isExtraLightOn, isExtraLightOn)
rvc.updateMenus("EXTRA LIGHT - ", isExtraLightOn)
rvc.keyDelay()
end
function rvc.skipSong()
AUDIO.SKIP_RADIO_FORWARD()
rvc.updateMenus("NEXT SONG", nil)
rvc.keyDelay()
end
function rvc.init()
rvc.rvcGUI = Libs["rvcGUI"]
-- add all buttons to UI
ui = {0.01,0.31,0.025,0.035}
rvc.rvcGUI.addButton("Fix Vehicle",rvc.fixVehicle,0,ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Fix Tyres",rvc.fixTyre,0,ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Clean Vehicle",rvc.cleanVehicle,0,ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Auto Drive to Waypoint",rvc.toggleAIDriveToWaypoint,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Auto Patrol Around",rvc.toggleAIPatrol,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Cruise Control",rvc.toggleCruise,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Engine - " .. rvc.booltochar(isEngineOn),rvc.toggleEngine,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Left Indicator - " .. rvc.booltochar(isLeftIndicatorOn) ,rvc.toggleLeftIndicator,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Right Indicator - " .. rvc.booltochar(isRightIndicatorOn),rvc.toggleRightIndicator,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Toggle Emergency Light - " .. rvc.booltochar(isEmergencyIndicatorOn),rvc.toggleEmergencyIndicator,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Brake Lights Always On - " .. rvc.booltochar(isBrakeLightOn),rvc.toggleBrakeLights,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Brake Lights When Stopped - " .. rvc.booltochar(isBrakeLightOnWhenStopped),rvc.brakeLightsWhenStopped,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Interior Light - " .. rvc.booltochar(isInteriorLightOn),rvc.toggleInteriorLight,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Extra Lights - " .. rvc.booltochar(isExtraLightOn),rvc.toggleExtraLight,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Turn Off All Lights - " .. rvc.booltochar(isAllLightsOn),rvc.toggleAllLights,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Open Front Left Door",rvc.openDoors,0,ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Open Front Right Door",rvc.openDoors,1,ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Open Back Left Door",rvc.openDoors,2,ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Open Back Right Door",rvc.openDoors,3,ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Open Hood",rvc.openDoors,4,ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Open Trunk",rvc.openDoors,5,ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Open Alt Trunk",rvc.openDoors,1,ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Close All Doors",rvc.closeDoors,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Open Windows",rvc.openWindows,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Close Windows",rvc.closeWindows,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Blip Police Siren",rvc.blipSiren,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Radio Skip Song",rvc.skipSong,"",ui[1],ui[2],ui[3],ui[4])
rvc.rvcGUI.addButton("Show Notifications - " .. rvc.booltochar(isUInotificationsOn),rvc.toggleUINotifications,0,ui[1],ui[2],ui[3],ui[4])
-- hide UI at the start
rvc.rvcGUI.hidden = true
end
function rvc.unload()
end
return rvc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment