├── image ├── ad_fob.png ├── ad_kit.png ├── ad_osd.png ├── ad_darts.png ├── ad_speed.png ├── ad_styles.png ├── ad_tagger.png └── ad_destinations.png ├── fxmanifest.lua ├── LICENSE.md ├── server └── server.lua ├── client ├── commands.lua ├── functions.lua ├── autodriveradialmenu.lua ├── client.lua ├── menu.lua └── events.lua ├── qbcore ├── adconfig-qb.lua ├── adserver-qb.lua └── adclient-qb.lua ├── shared ├── config.lua ├── speedlimits.lua └── tables.lua └── README.md /image/ad_fob.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TAGaming20/ta-autodrive/HEAD/image/ad_fob.png -------------------------------------------------------------------------------- /image/ad_kit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TAGaming20/ta-autodrive/HEAD/image/ad_kit.png -------------------------------------------------------------------------------- /image/ad_osd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TAGaming20/ta-autodrive/HEAD/image/ad_osd.png -------------------------------------------------------------------------------- /image/ad_darts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TAGaming20/ta-autodrive/HEAD/image/ad_darts.png -------------------------------------------------------------------------------- /image/ad_speed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TAGaming20/ta-autodrive/HEAD/image/ad_speed.png -------------------------------------------------------------------------------- /image/ad_styles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TAGaming20/ta-autodrive/HEAD/image/ad_styles.png -------------------------------------------------------------------------------- /image/ad_tagger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TAGaming20/ta-autodrive/HEAD/image/ad_tagger.png -------------------------------------------------------------------------------- /image/ad_destinations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TAGaming20/ta-autodrive/HEAD/image/ad_destinations.png -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | game 'gta5' 3 | 4 | name "ta-autodrive" 5 | description "Autodrive script" 6 | author "Theory Affinity" 7 | version "2.9.0" 8 | 9 | shared_scripts { 10 | 'shared/config.lua', 11 | 'shared/speedlimits.lua', 12 | 'shared/tables.lua', 13 | 'qbcore/adconfig-qb.lua', 14 | } 15 | 16 | client_scripts { 17 | 'client/functions.lua', 18 | 'client/client.lua', 19 | 'client/commands.lua', 20 | 'client/events.lua', 21 | 'client/NativeUI.lua', 22 | 'client/menu.lua', 23 | 'client/autodriveradialmenu.lua', 24 | 'qbcore/locations.lua', 25 | 'qbcore/adclient-qb.lua', 26 | } 27 | 28 | server_scripts { 29 | 'server/*.lua', 30 | 'qbcore/adserver-qb.lua', 31 | 32 | } 33 | 34 | lua54 'yes' 35 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2022, Theory Affinity 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the organization nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | * Redistribution of this software in source or binary forms shall be free 15 | of all charges or fees to the recipient of this software. 16 | * This software may not be resold, redistributed or otherwise conveyed to a 17 | third party for commercial use. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THEORY AFFINITY BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /server/server.lua: -------------------------------------------------------------------------------- 1 | print("##############ta-autodrive server file") 2 | 3 | local function PreloadModel(model) 4 | -- print("IsModelInCdimage(model)", model, IsModelInCdimage(model)) 5 | -- if not IsModelInCdimage(model) then model = GetHashKey('adder') end 6 | -- print("IsModelInCdimage(model)", model, IsModelInCdimage(model)) 7 | if not HasModelLoaded(model) then 8 | RequestModel(model) 9 | while not HasModelLoaded(model) do 10 | Wait(100) 11 | end 12 | end 13 | -- print("Has model loaded", HasModelLoaded(model)) 14 | end 15 | print("Server Commands") 16 | -- local serverVeh1 17 | RegisterServerEvent('ta-autodrive:server:spawnvehicle') 18 | AddEventHandler('ta-autodrive:server:spawnvehicle', function(source) 19 | print("Server Spawn Vehicle") 20 | -- PreloadModel(GetHashKey('adder')) 21 | -- CreateVehicle() 22 | if DoesEntityExist(serverVeh1) then print(serverVeh1) DeleteEntity(serverVeh1) end 23 | 24 | -- ##############################################################################-- 25 | local servLoc1 = vector3(-1662.20, -913.59, 8.37) -- GetOffsetFromEntityInWorldCoords(PlayerPedId(), -10.0, 3.0, 0) 26 | serverVeh1 = CreateVehicle(GetHashKey('adder'), servLoc1, 139.5, true, false) 27 | -- returnVeh1 = entityVeh1 28 | Citizen.Wait(100) 29 | -- -- ##############################################################################-- 30 | -- local vehLoc2 = GetOffsetFromEntityInWorldCoords(entityVeh1, 3.1, 0.0, 0) -- vector3(-1662.20, -913.59, 8.37) --GetObjectOffsetFromCoords(vehLoc1, 139, 5.0, 0.0, 0.0) 31 | -- entityVeh2 = CreateVehicle(vehHash2, vehLoc2, 139.5, true, false) 32 | -- returnVeh2 = entityVeh2 33 | -- Citizen.Wait(100) 34 | end) 35 | 36 | RegisterCommand('serverspawn', function() 37 | TriggerEvent('ta-autodrive:server:spawnvehicle') 38 | 39 | end) -------------------------------------------------------------------------------- /client/commands.lua: -------------------------------------------------------------------------------- 1 | -- ##############################################################################-- Key Mapping 2 | -- Registered Keymappings once enabled, won't delete after disabling 3 | -- Edit keymapping in \AppData\Roaming\CitizenFX\fivem.cfg 4 | -- ##############################################################################-- 5 | local cmdPrint = false 6 | if ADDefaults.EnableCommands then 7 | -- ##########################################-------------------------------------- Trigger autodrive event command 8 | RegisterCommand(ADCommands.Start, function() 9 | if cmdPrint then print("Start Autodrive Command") end 10 | if not IsAutoDriveEnabled then 11 | TriggerEvent(EventsTable.Start) 12 | else 13 | TriggerEvent(EventsTable.Stop) 14 | end 15 | end) 16 | -- ##########################################-------------------------------------- Autodrive off command 17 | RegisterCommand(ADCommands.Stop, function(source, args, rawcommand) 18 | if IsAutoDriveEnabled then TriggerEvent(EventsTable.Stop) end 19 | end) 20 | -- ##########################################-------------------------------------- Driving destination command 21 | RegisterCommand(ADCommands.Destination, function(source, args, rawcommand) 22 | if cmdPrint then print("Destination Command", type(args[1]), args[1]) end 23 | TriggerEvent(EventsTable.Destination.name, args[1]) 24 | end) 25 | -- ##########################################-------------------------------------- Driving style command 26 | RegisterCommand(ADCommands.Style, function(source, args, rawcommand) 27 | if cmdPrint then print("Set Driving Style command") end 28 | TriggerEvent(EventsTable.Style.name, args[1]) 29 | end) 30 | -- ##########################################-------------------------------------- Driving speed command 31 | RegisterCommand(ADCommands.Speed, function(source, args, rawcommand) 32 | if cmdPrint then print("Set Driving speed command") end 33 | TriggerEvent(EventsTable.Speed.name, args[1]) 34 | end) 35 | -- ##########################################-------------------------------------- Driving speed command 36 | RegisterCommand(ADCommands.Settings, function(source, args, rawcommand) 37 | if cmdPrint then print("Settings command") end 38 | TriggerEvent(EventsTable.Settings.name, args[1]) 39 | end) 40 | -- ##########################################-------------------------------------- Speed up command 41 | RegisterCommand(ADCommands.SpeedUp, function(source, args, rawcommand) 42 | if cmdPrint then print("Speed up command") end 43 | TriggerEvent(EventsTable.Speed.name, 'speedup') 44 | end) 45 | -- ##########################################-------------------------------------- Speed down command 46 | RegisterCommand(ADCommands.SpeedDown, function(source, args, rawcommand) 47 | if cmdPrint then print("Speed down command") end 48 | TriggerEvent(EventsTable.Speed.name, 'speeddown') 49 | end) 50 | -- ##########################################-------------------------------------- Tag vehicle command 51 | RegisterCommand(ADCommands.Tag, function() 52 | if cmdPrint then print("Tag vehicle command") end 53 | TriggerEvent(EventsTable.Destination.name, DestTable.Args.Tag.id) 54 | end) 55 | -- ##########################################-------------------------------------- Follow car toggle command 56 | 57 | RegisterCommand(ADCommands.Follow, function() 58 | if cmdPrint then print("Follow vehicle command") end 59 | TriggerEvent(EventsTable.Destination.name, DestTable.Args.Follow.id) 60 | end) 61 | end 62 | -- ##########################################-------------------------------------- Registered Keymappings 63 | if ADDefaults.RegisterKeys then 64 | if cmdPrint then print("Registering Autodrive keymaps") end 65 | -- ##############################################################################-- tag car key mapping 66 | RegisterKeyMapping(ADCommands.Tag, "Tag Vehicle", "keyboard", "RBRACKET") 67 | -- ##############################################################################-- follow car key mapping 68 | RegisterKeyMapping(ADCommands.Follow, "Follow Vehicle", "keyboard", "APOSTROPHE") 69 | -- ##############################################################################-- register speed change key mappings 70 | RegisterKeyMapping(ADCommands.SpeedUp, "Speed Increase", "keyboard", "plus") 71 | RegisterKeyMapping(ADCommands.SpeedDown, "Speed Decrease", "keyboard", "minus") 72 | -- ##############################################################################-- autodrive on keymapping 73 | RegisterKeyMapping(ADCommands.Start, "Autodrive On", "keyboard", "0") 74 | -- ##############################################################################-- autodrive off keymapping 75 | RegisterKeyMapping(ADCommands.Stop, "Autodrive off", "keyboard", "s") 76 | end 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /qbcore/adconfig-qb.lua: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------------------------------------------------------------------- 2 | ----------------------------------------------------------------------------------------------------------------------------------------- 3 | ----------------------------------------------------------------------------------------------------------- QBCore Config --------------- 4 | ----------------------------------------------------------------------------------------------------------------------------------------- 5 | ----------------------------------------------------------------------------------------------------------------------------------------- 6 | if not ADDefaults.UseQBCore then return end 7 | 8 | ------------------------------------------------------------------------------------------------------------------ 9 | --------------------------------------- Autodrive Default Settings ----------------------------------------------- 10 | ------------------------------------------------------------------------------------------------------------------ 11 | 12 | Config = {} 13 | 14 | Config.QBNotify = true 15 | -- -- ##########################################-------------------------------------- AUTODRIVE INSTALLATION CONFIG 16 | ------------------------------------------------------------------------------------------------------------------ 17 | --------------------------------------- Autodrive Part Installation Settings ------------------------------------- 18 | ------------------------------------------------------------------------------------------------------------------ 19 | 20 | Config.KitInstallTime = 3000 21 | Config.UpgradeInstallTime = 1500 22 | Config.RequireParts = false 23 | Config.RequirePartUpgrades = false 24 | Config.UseQBTarget = GetConvar('UseTarget', 'false') == 'true' 25 | Config.RequireJobInstall = true 26 | 27 | -- -- ##########################################-------------------------------------- AUTODRIVE USAGE CONFIG 28 | ------------------------------------------------------------------------------------------------------------------ 29 | --------------------------------------- Autodrive Permission Settings -------------------------------------------- 30 | ------------------------------------------------------------------------------------------------------------------ 31 | 32 | -- Blacklist certain vehicles. Use names or hashes 33 | -- https://wiki.gtanet.work/index.php?title=Vehicle_Models 34 | 35 | Config.Blacklist = {} 36 | Config.Blacklist.Vehicles = {['none'] = true, ['police'] = false, } 37 | 38 | Config.Whitelist = {} 39 | Config.Whitelist.Jobs = {['all'] = false, ['mechanic'] = true, ['police'] = true, ['ambulance'] = true, ['unemployed'] = false, } 40 | Config.Whitelist.Jobs.Install = {['all'] = false, ['mechanic'] = true, ['police'] = true, ['ambulance'] = true, ['unemployed'] = false, } 41 | Config.Whitelist.Jobs.Usage = {['all'] = false, ['mechanic'] = true, ['police'] = true, ['ambulance'] = true, ['unemployed'] = false, } 42 | Config.Whitelist.Levels = {['all'] = true, } 43 | Config.Whitelist.Upgrade = {['all'] = true, } 44 | Config.Whitelist.Vehicles = {['all'] = true, ['police']= true, ['police2']= true, ['police3']= true, ['police4']= true, ['ambulance']= true, } 45 | Config.RestrictUpgrades = {['none'] = true, } 46 | 47 | ------------------------------------------------------------------------------------------------------------------ 48 | --------------------------------------- Autodrive Language Translations ------------------------------------------ 49 | ------------------------------------------------------------------------------------------------------------------ 50 | 51 | Config.Lang = {} 52 | Config.Lang.Notify = { 53 | ['notinvehicle'] = 'Must be in a vehicle', 54 | ['notowned'] = 'You must own the vehicle', 55 | ['ad_install_progbar'] = 'Installing parts...', 56 | ['adkit'] = 'Autodrive Kit Installed Successfully!', 57 | ['adkitfail'] = 'Autodrive Kit Not Installed!', 58 | ['adupgrade'] = 'Autodrive Upgrade Installed Successfully!', 59 | ['adupgradef'] = 'Upgrade Install Failed!', 60 | ['missingparts'] = 'Missing Required Parts!', 61 | ['tryagain'] = 'Something went wrong. Try again', 62 | ['partremoved'] = 'Part Removed', 63 | ['notjob'] = 'Not right for the job', 64 | ['notvehicle'] = "Not the right vehicle" 65 | } 66 | 67 | Config.Lang.Subtitle = { 68 | ['notinvehicle'] = 'Must be in a vehicle', 69 | ['notowned'] = 'You must own the vehicle', 70 | ['ad_install_progbar'] = 'Installing parts...', 71 | ['adkit'] = 'Autodrive Kit ~g~Installed Successfully!', 72 | ['adkitfail'] = 'Autodrive Kit ~r~Not Installed!', 73 | ['adupgrade'] = 'Autodrive Upgrade ~g~Installed Successfully!', 74 | ['adupgradef'] = 'Upgrade Install ~r~Failed!', 75 | ['missingparts'] = 'Missing Required ~y~Parts!', 76 | ['tryagain'] = 'Something went wrong. Try again', 77 | ['partremoved'] = 'Successfully ~g~Installed!', 78 | ['notjob'] = 'Not right for the job', 79 | ['notvehicle'] = "Not the right vehicle" 80 | } 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /qbcore/adserver-qb.lua: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------------------------------------------------------------------- 2 | ----------------------------------------------------------------------------------------------------------------------------------------- 3 | ----------------------------------------------------------------------------------------------------------- QBCore Server --------------- 4 | ----------------------------------------------------------------------------------------------------------------------------------------- 5 | ----------------------------------------------------------------------------------------------------------------------------------------- 6 | if not ADDefaults.UseQBCore then return end 7 | -- ######################################################################################################################################## 8 | -- ##########################################-------------------------------------- 9 | local QBCore = exports['qb-core']:GetCoreObject() 10 | 11 | exports['qb-core']:AddItems({ 12 | ["ad_fob"] = { 13 | ["name"] = "ad_fob", 14 | ["label"] = "Autodrive FOB", 15 | ["weight"] = 1, 16 | ["type"] = "item", 17 | ["image"] = "ad_fob.png", 18 | ["unique"] = true, 19 | ["useable"] = true, 20 | ["shouldClose"] = true, 21 | ["combinable"] = nil, 22 | ["description"] = "Bro, where's the remote!" 23 | }, 24 | ["ad_tagger"] = { 25 | ["name"] = "ad_tagger", 26 | ["label"] = "Autodrive Tagger", 27 | ["weight"] = 50, 28 | ["type"] = "item", 29 | ["image"] = "ad_tagger.png", 30 | ["unique"] = false, 31 | ["useable"] = true, 32 | ["shouldClose"] = true, 33 | ["combinable"] = nil, 34 | ["description"] = "Follow that car!" 35 | }, 36 | ["ad_kit"] = { 37 | ["name"] = "ad_kit", 38 | ["label"] = "Autodrive Kit", 39 | ["weight"] = 50, 40 | ["type"] = "item", 41 | ["image"] = "ad_kit.png", 42 | ["unique"] = false, 43 | ["useable"] = true, 44 | ["shouldClose"] = true, 45 | ["combinable"] = nil, 46 | ["description"] = "Take your hands off the wheel!" 47 | }, 48 | ["ad_speed"] = { 49 | ["name"] = "ad_speed", 50 | ["label"] = "AD Speed Upgrade", 51 | ["weight"] = 50, 52 | ["type"] = "item", 53 | ["image"] = "ad_speed.png", 54 | ["unique"] = true, 55 | ["useable"] = true, 56 | ["shouldClose"] = true, 57 | ["combinable"] = nil, 58 | ["description"] = "Bro, where's the remote!" 59 | }, 60 | ["ad_styles"] = { 61 | ["name"] = "ad_styles", 62 | ["label"] = "AD Styles Upgrade", 63 | ["weight"] = 50, 64 | ["type"] = "item", 65 | ["image"] = "ad_styles.png", 66 | ["unique"] = false, 67 | ["useable"] = true, 68 | ["shouldClose"] = true, 69 | ["combinable"] = nil, 70 | ["description"] = "Follow that car!" 71 | }, 72 | ["ad_destinations"] = { 73 | ["name"] = "ad_destinations", 74 | ["label"] = "AD Desinations Upgrade", 75 | ["weight"] = 50, 76 | ["type"] = "item", 77 | ["image"] = "ad_destinations.png", 78 | ["unique"] = false, 79 | ["useable"] = true, 80 | ["shouldClose"] = true, 81 | ["combinable"] = nil, 82 | ["description"] = "Take your hands off the wheel!" 83 | }, 84 | ["ad_darts"] = { 85 | ["name"] = "ad_darts", 86 | ["label"] = "AD Darts", 87 | ["weight"] = 1, 88 | ["type"] = "item", 89 | ["image"] = "ad_darts.png", 90 | ["unique"] = false, 91 | ["useable"] = true, 92 | ["shouldClose"] = true, 93 | ["combinable"] = nil, 94 | ["description"] = "Take your hands off the wheel!" 95 | }, 96 | ["ad_osd"] = { 97 | ["name"] = "ad_osd", 98 | ["label"] = "AD OSD Upgrade", 99 | ["weight"] = 50, 100 | ["type"] = "item", 101 | ["image"] = "ad_darts.png", 102 | ["unique"] = false, 103 | ["useable"] = true, 104 | ["shouldClose"] = true, 105 | ["combinable"] = nil, 106 | ["description"] = "Take your hands off the wheel!" 107 | }, 108 | }) 109 | 110 | -- ######################################################################################################################################## 111 | -- ##########################################-------------------------------------- 112 | 113 | -- fob 114 | QBCore.Functions.CreateUseableItem('ad_fob', function(source, item) 115 | local Player = QBCore.Functions.GetPlayer(source) 116 | if not Player.Functions.GetItemByName(item.name) then return end 117 | -- Trigger code here for what item should do 118 | 119 | TriggerClientEvent('ta-autodrive:client:qbmenu:main', source) 120 | end) 121 | 122 | -- darts 123 | QBCore.Functions.CreateUseableItem('ad_darts', function(source, item) 124 | local Player = QBCore.Functions.GetPlayer(source) 125 | if not Player.Functions.GetItemByName(item.name) then return end 126 | -- Trigger code here for what item should do 127 | 128 | end) 129 | 130 | -- ######################################################################################################################################## 131 | -- ##########################################-------------------------------------- 132 | 133 | RegisterNetEvent('ta-autodrive:server:remove:part') 134 | AddEventHandler('ta-autodrive:server:remove:part', function(ad_part) 135 | local Player = QBCore.Functions.GetPlayer(source) 136 | local adPart = tostring(ad_part) 137 | Player.Functions.RemoveItem(adPart, 1) 138 | TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items[adPart], "remove", 1) 139 | end) 140 | 141 | 142 | -------------------------------------------------------------------------------- /shared/config.lua: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------------------------------------------------------------------- 2 | ----------------------------------------------------------------------------------------------------------------------------------------- 3 | ----------------------------------------------------------------------------------------------------------- Autodrive Configurations ---- 4 | ----------------------------------------------------------------------------------------------------------------------------------------- 5 | ----------------------------------------------------------------------------------------------------------------------------------------- 6 | 7 | ------------------------------------------------------------------------------------------------------------------ 8 | --------------------------------------- Autodrive Default Settings ----------------------------------------------- 9 | ------------------------------------------------------------------------------------------------------------------ 10 | ADDefaults = {} 11 | 12 | ADDefaults.UseMPH = true 13 | ADDefaults.OnScreenDisplay = true -- set this true to have OSD on all the time, may impact performance 14 | ADDefaults.OSDtimed = false -- set this true to have OSD toggle off after 3 seconds 15 | ADDefaults.Subtitles = true 16 | ADDefaults.ToggleDriverCreation = false -- ** experimental features ** 17 | 18 | ------------------------------------------------------------------------------------------------------------------ 19 | --------------------------------------- Autodrive Integrations --------------------------------------------------- 20 | ------------------------------------------------------------------------------------------------------------------ 21 | 22 | ADDefaults.UseQBCore = true 23 | ADDefaults.UseNativeUI = true 24 | ADDefaults.UseRadialMenu = true 25 | ADDefaults.UseQBMenu = true 26 | ADDefaults.RegisterKeys = true 27 | ADDefaults.EnableHotKeys = false -- non registered hot keys not fully tested in this version 28 | ADDefaults.EnableCommands = true 29 | ADDefaults.UsePostals = true -- must have nearest postal loaded 30 | ADDefaults.ForceDrivers = false 31 | ADDefaults.VisibleDrivers = false 32 | ADDefaults.CreateDrivers = false 33 | ------------------------------------------------------------------------------------------------------------------ 34 | --------------------------------------- Autodrive Advanced Settings ---------------------------------------------- 35 | ------------------------------------------------------------------------------------------------------------------ 36 | 37 | ADDefaults.DefaultDestination = "Freeroam" 38 | ADDefaults.DefaultBlip = 60 39 | ADDefaults.DefaultDriveStyleName = "Safe" 40 | ADDefaults.DefaultDriveSpeed = 25.0 41 | ADDefaults.TagVehicleScanTime = 3000 -- how long to scan for vehicles 42 | ADDefaults.MPH = 2.236936 43 | ADDefaults.KMH = 3.6 44 | ADDefaults.OSDX = 0.69 -- OnScreenDisplay x location, {min = 0.0 , max = 1.0} 45 | ADDefaults.OSDY = 0.75 -- OnScreenDisplay y location, {min = 0.0 , max = 1.0} 46 | 47 | ------------------------------------------------------------------------------------------------------------------ 48 | --------------------------------------- Autodrive Commands ------------------------------------------------------- 49 | ------------------------------------------------------------------------------------------------------------------ 50 | 51 | -- // Autodrive Commands 52 | -- // -- keymappings enabled won't delete after disabling 53 | -- // -- delete keymappings in \AppData\Roaming\CitizenFX\fivem.cfg 54 | ADCommands = {} 55 | ADCommands.Start = "adstart" 56 | ADCommands.Stop = "adstop" 57 | ADCommands.Destination = "addest" 58 | ADCommands.Style = "adstyle" 59 | ADCommands.Speed = "adspeed" 60 | ADCommands.Settings = "adsettings" 61 | ADCommands.Tag = "adtag" 62 | ADCommands.Follow = "adfollow" 63 | ADCommands.SpeedUp = "adspeedup" 64 | ADCommands.SpeedDown = "adspeeddown" 65 | 66 | ------------------------------------------------------------------------------------------------------------------ 67 | --------------------------------------- Autodrive Hotkeys -------------------------------------------------------- 68 | ------------------------------------------------------------------------------------------------------------------ 69 | 70 | -- Non registered hotkeys are not fully tested 71 | ADHotkeys = {} -- These are still a work in progress and may not function in this version 72 | ADHotkeys.Start = 110 -- numpad 5 73 | ADHotkeys.Stop = 72 -- s 74 | ADHotkeys.Tag = 41 -- [ 75 | ADHotkeys.Follow = 40 -- ] 76 | ADHotkeys.SpeedUp = 109 -- numpad 6 77 | ADHotkeys.SpeedDown = 108 -- numpad 4 78 | 79 | ------------------------------------------------------------------------------------------------------------------ 80 | --------------------------------------- Autodrive Tables --------------------------------------------------------- 81 | ------------------------------------------------------------------------------------------------------------------ 82 | 83 | ADDefaults.GasStations = { 84 | vector3(49.4187, 2778.793, 58.043), 85 | vector3(263.894, 2606.463, 44.983), 86 | vector3(1039.958, 2671.134, 39.550), 87 | vector3(1207.260, 2660.175, 37.899), 88 | vector3(2539.685, 2594.192, 37.944), 89 | vector3(2679.858, 3263.946, 55.240), 90 | vector3(2005.055, 3773.887, 32.403), 91 | vector3(1687.156, 4929.392, 42.078), 92 | vector3(1701.314, 6416.028, 32.763), 93 | vector3(179.857, 6602.839, 31.868), 94 | vector3(-94.4619, 6419.594, 31.489), 95 | vector3(-2554.996, 2334.40, 33.078), 96 | vector3(-1800.375, 803.661, 138.651), 97 | vector3(-1437.622, -276.747, 46.207), 98 | vector3(-2096.243, -320.286, 13.168), 99 | vector3(-724.619, -935.1631, 19.213), 100 | vector3(-526.019, -1211.003, 18.184), 101 | vector3(-70.2148, -1761.792, 29.534), 102 | vector3(265.648, -1261.309, 29.292), 103 | vector3(819.653, -1028.846, 26.403), 104 | vector3(1208.951, -1402.567,35.224), 105 | vector3(1181.381, -330.847, 69.316), 106 | vector3(620.843, 269.100, 103.089), 107 | vector3(2581.321, 362.039, 108.468), 108 | vector3(176.631, -1562.025, 29.263), 109 | vector3(176.631, -1562.025, 29.263), 110 | vector3(-319.292, -1471.715, 30.549), 111 | vector3(1784.324, 3330.55, 41.253), 112 | vector3(-66.48, -2532.57, 6.14), 113 | } 114 | 115 | DriverList = { 116 | 'ig_benny', 117 | -- 's_f_y_cop_01', 118 | 119 | } 120 | 121 | ------------------------------------------------------------------------------------------------------------------ 122 | --------------------------------------- QBCore Add Items --------------------------------------------------------- 123 | ------------------------------------------------------------------------------------------------------------------ 124 | 125 | exports['qb-core']:AddItems({ 126 | ["ad_fob"] = { 127 | ["name"] = "ad_fob", 128 | ["label"] = "Autodrive FOB", 129 | ["weight"] = 1, 130 | ["type"] = "item", 131 | ["image"] = "ad_fob.png", 132 | ["unique"] = true, 133 | ["useable"] = true, 134 | ["shouldClose"] = true, 135 | ["combinable"] = nil, 136 | ["description"] = "Bro, where's the remote!" 137 | }, 138 | ["ad_tagger"] = { 139 | ["name"] = "ad_tagger", 140 | ["label"] = "Autodrive Tagger", 141 | ["weight"] = 50, 142 | ["type"] = "item", 143 | ["image"] = "ad_tagger.png", 144 | ["unique"] = false, 145 | ["useable"] = true, 146 | ["shouldClose"] = true, 147 | ["combinable"] = nil, 148 | ["description"] = "Follow that car!" 149 | }, 150 | ["ad_kit"] = { 151 | ["name"] = "ad_kit", 152 | ["label"] = "Autodrive Kit", 153 | ["weight"] = 50, 154 | ["type"] = "item", 155 | ["image"] = "ad_kit.png", 156 | ["unique"] = false, 157 | ["useable"] = true, 158 | ["shouldClose"] = true, 159 | ["combinable"] = nil, 160 | ["description"] = "Take your hands off the wheel!" 161 | }, 162 | ["ad_speed"] = { 163 | ["name"] = "ad_speed", 164 | ["label"] = "AD Speed Upgrade", 165 | ["weight"] = 50, 166 | ["type"] = "item", 167 | ["image"] = "ad_speed.png", 168 | ["unique"] = true, 169 | ["useable"] = true, 170 | ["shouldClose"] = true, 171 | ["combinable"] = nil, 172 | ["description"] = "Bro, where's the remote!" 173 | }, 174 | ["ad_styles"] = { 175 | ["name"] = "ad_styles", 176 | ["label"] = "AD Styles Upgrade", 177 | ["weight"] = 50, 178 | ["type"] = "item", 179 | ["image"] = "ad_styles.png", 180 | ["unique"] = false, 181 | ["useable"] = true, 182 | ["shouldClose"] = true, 183 | ["combinable"] = nil, 184 | ["description"] = "Follow that car!" 185 | }, 186 | ["ad_destinations"] = { 187 | ["name"] = "ad_destinations", 188 | ["label"] = "AD Desinations Upgrade", 189 | ["weight"] = 50, 190 | ["type"] = "item", 191 | ["image"] = "ad_destinations.png", 192 | ["unique"] = false, 193 | ["useable"] = true, 194 | ["shouldClose"] = true, 195 | ["combinable"] = nil, 196 | ["description"] = "Take your hands off the wheel!" 197 | }, 198 | ["ad_darts"] = { 199 | ["name"] = "ad_darts", 200 | ["label"] = "AD Darts", 201 | ["weight"] = 1, 202 | ["type"] = "item", 203 | ["image"] = "ad_darts.png", 204 | ["unique"] = false, 205 | ["useable"] = true, 206 | ["shouldClose"] = true, 207 | ["combinable"] = nil, 208 | ["description"] = "Take your hands off the wheel!" 209 | }, 210 | ["ad_osd"] = { 211 | ["name"] = "ad_osd", 212 | ["label"] = "AD OSD Upgrade", 213 | ["weight"] = 50, 214 | ["type"] = "item", 215 | ["image"] = "ad_darts.png", 216 | ["unique"] = false, 217 | ["useable"] = true, 218 | ["shouldClose"] = true, 219 | ["combinable"] = nil, 220 | ["description"] = "Take your hands off the wheel!" 221 | }, 222 | }) 223 | 224 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Autodrive is a resource for FiveM servers 2 | 3 | Features: 4 | Autodrive 5 | Hotkey support 6 | FiveM registered hotkeys 7 | Radial Menu support 8 | NativeUI support 9 | 10 | Autodrive to locations: 11 | Custom destinations 12 | Free Roam 13 | Fuel stations 14 | 15 | Driving Styles: 16 | Custom preset driving styles 17 | Custom user input driving styles 18 | 19 | Driving Speeds: 20 | Custom input with hotkey support 21 | Follow speed limits on roads 22 | (thanks to big yoda for the street names) 23 | 24 | Vehicle Tagging: 25 | Tag vehicles and mark them on the map 26 | Follow tagged vehicles with autodrive 27 | 28 | Radial Menu not included. This is needed for autodrive to use Radial Menu 29 | 30 | 31 | Keys: 32 | NativeUI Menu = LSHIFT + DEL 33 | Autodrive = 0 34 | SpeedUP = + 35 | SpeedDOWN = - 36 | Tag Vehicle = ] 37 | Follow Vehicle = ' 38 | 39 | 40 | Installation: 41 | To use QB integrations requires a few edits to qbcore and qb-inventory. 42 | We also need to add the items to purchase from shops. 43 | First we need to add vehicle data to qbcore. This edit saves vehicle installations. 44 | Included in this mod is the code to edit qbcore items so no need to add items in qb shared items. 45 | Next we need to add the parts to shops and qb-inventory. Add the files from the images folder to 46 | qb-inventory images folder. Then make the edit to qb-shops. 47 | Then the parts will be added to install, installations will be persistent, and autodrive will function with qb. 48 | Whitelisting, part requirements, persitence and more! 49 | 50 | 51 | Download the latest version 52 | Copy to the server resources folder 53 | Add ensure ta-autodrive in the server.cfg 54 | If using QB then make sure ta-autodrive loads after [qb] 55 | ta-autodrive uses qb-core, qb-inventory, qb-menu, and qb-radialmenu 56 | 57 | 58 | ----------------------------------------------------------------------------------------------- 59 | ----------------------------------------------------------------------------------------------- 60 | ----------------------------------------------------------------------------------------------- 61 | 62 | -- add this block to qb-core/client/functions.lua 63 | 64 | -- Multiple Add Items 65 | local function AddItems(items) 66 | local shouldContinue = true 67 | local message = "success" 68 | local errorItem = nil 69 | 70 | for key, value in pairs(items) do 71 | if type(key) ~= "string" then 72 | message = "invalid_item_name" 73 | shouldContinue = false 74 | errorItem = items[key] 75 | break 76 | end 77 | 78 | if QBCore.Shared.Items[key] then 79 | message = "item_exists" 80 | shouldContinue = false 81 | errorItem = items[key] 82 | break 83 | end 84 | 85 | QBCore.Shared.Items[key] = value 86 | end 87 | 88 | if not shouldContinue then return false, message, errorItem end 89 | TriggerClientEvent('QBCore:Client:OnSharedUpdateMultiple', -1, 'Items', items) 90 | TriggerEvent('QBCore:Server:UpdateObject') 91 | return true, message, nil 92 | end 93 | 94 | QBCore.Functions.AddItems = AddItems 95 | exports('AddItems', AddItems) 96 | 97 | ----------------------------------------------------------------------------------------------- 98 | ----------------------------------------------------------------------------------------------- 99 | ----------------------------------------------------------------------------------------------- 100 | 101 | -- insert into qbcore/functions.lua 102 | -- insert into GetVehicleProperties function 103 | function QBCore.Functions.GetVehicleProperties(vehicle) -- do not include 104 | if DoesEntityExist(vehicle) then -- do not include 105 | local autodrive = {} -- copy lines below and add under "DoesEntityExist" 106 | 107 | autodrive = { ["Id"] = vehicle, ["Order"] = 0, ["ad_destinations"] = false, ["ad_kit"] = false, ["ad_osd"] = false, 108 | ["ad_speed"] = false, ["ad_styles"] = false, ["ad_tagger"] = false, } -- check this line if errors, remove it 109 | 110 | if exports['ta-autodrive']:vehicleswithautodrive() == nil then 111 | return 112 | else 113 | local taEx =exports['ta-autodrive']:vehicleswithautodrive() 114 | 115 | autodrive = taEx[vehicle] 116 | end 117 | 118 | ----------------------------------------------------------------------------------------------- 119 | ----------------------------------------------------------------------------------------------- 120 | ----------------------------------------------------------------------------------------------- 121 | 122 | -- insert into SetVehicleProperties function 123 | function QBCore.Functions.SetVehicleProperties(vehicle, props) -- do not include 124 | if DoesEntityExist(vehicle) then -- do not include 125 | if props.autodrive then -- copy lines below and add under "DoesEntityExist" 126 | local autodrive = props.autodrive 127 | end 128 | 129 | ----------------------------------------------------------------------------------------------- 130 | ----------------------------------------------------------------------------------------------- 131 | ----------------------------------------------------------------------------------------------- 132 | 133 | -- example product list 134 | -- insert into qb-shops Config.Products 135 | ["hardware"] = { 136 | [1] = { 137 | name = "ad_fob", 138 | price = 10000, 139 | amount = 50, 140 | info = {}, 141 | type = "item", 142 | slot = 1, 143 | }, 144 | [2] = { 145 | name = "ad_kit", 146 | price = 5000, 147 | amount = 50, 148 | info = {}, 149 | type = "item", 150 | slot = 2, 151 | }, 152 | [3] = { 153 | name = "ad_tagger", 154 | price = 5000, 155 | amount = 50, 156 | info = {}, 157 | type = "item", 158 | slot = 3, 159 | }, 160 | [4] = { 161 | name = "ad_speed", 162 | price = 5000, 163 | amount = 50, 164 | info = {}, 165 | type = "item", 166 | slot = 4, 167 | }, 168 | [5] = { 169 | name = "ad_styles", 170 | price = 5000, 171 | amount = 50, 172 | info = {}, 173 | type = "item", 174 | slot = 5, 175 | }, 176 | [6] = { 177 | name = "ad_destinations", 178 | price = 5000, 179 | amount = 50, 180 | info = {}, 181 | type = "item", 182 | slot = 6, 183 | }, 184 | [7] = { 185 | name = "ad_osd", 186 | price = 5000, 187 | amount = 50, 188 | info = {}, 189 | type = "item", 190 | slot = 7, 191 | }, 192 | [8] = { 193 | name = "ad_darts", 194 | price = 500, 195 | amount = 50, 196 | info = {}, 197 | type = "item", 198 | slot = 8, 199 | }, 200 | } 201 | 202 | ----------------------------------------------------------------------------------------------- 203 | ----------------------------------------------------------------------------------------------- 204 | ----------------------------------------------------------------------------------------------- 205 | 206 | -- QBShared.Items 207 | 208 | ["ad_fob"] = { 209 | ["name"] = "ad_fob", 210 | ["label"] = "Autodrive FOB", 211 | ["weight"] = 1, 212 | ["type"] = "item", 213 | ["image"] = "ad_fob.png", 214 | ["unique"] = true, 215 | ["useable"] = true, 216 | ["shouldClose"] = true, 217 | ["combinable"] = nil, 218 | ["description"] = "Bro, where's the remote!" 219 | }, 220 | ["ad_tagger"] = { 221 | ["name"] = "ad_tagger", 222 | ["label"] = "Autodrive Tagger", 223 | ["weight"] = 50, 224 | ["type"] = "item", 225 | ["image"] = "ad_tagger.png", 226 | ["unique"] = false, 227 | ["useable"] = true, 228 | ["shouldClose"] = true, 229 | ["combinable"] = nil, 230 | ["description"] = "Follow that car!" 231 | }, 232 | ["ad_kit"] = { 233 | ["name"] = "ad_kit", 234 | ["label"] = "Autodrive Kit", 235 | ["weight"] = 50, 236 | ["type"] = "item", 237 | ["image"] = "ad_kit.png", 238 | ["unique"] = false, 239 | ["useable"] = true, 240 | ["shouldClose"] = true, 241 | ["combinable"] = nil, 242 | ["description"] = "Take your hands off the wheel!" 243 | }, 244 | ["ad_speed"] = { 245 | ["name"] = "ad_speed", 246 | ["label"] = "AD Speed Upgrade", 247 | ["weight"] = 50, 248 | ["type"] = "item", 249 | ["image"] = "ad_speed.png", 250 | ["unique"] = true, 251 | ["useable"] = true, 252 | ["shouldClose"] = true, 253 | ["combinable"] = nil, 254 | ["description"] = "Bro, where's the remote!" 255 | }, 256 | ["ad_styles"] = { 257 | ["name"] = "ad_styles", 258 | ["label"] = "AD Styles Upgrade", 259 | ["weight"] = 50, 260 | ["type"] = "item", 261 | ["image"] = "ad_styles.png", 262 | ["unique"] = false, 263 | ["useable"] = true, 264 | ["shouldClose"] = true, 265 | ["combinable"] = nil, 266 | ["description"] = "Follow that car!" 267 | }, 268 | ["ad_destinations"] = { 269 | ["name"] = "ad_destinations", 270 | ["label"] = "AD Desinations Upgrade", 271 | ["weight"] = 50, 272 | ["type"] = "item", 273 | ["image"] = "ad_destinations.png", 274 | ["unique"] = false, 275 | ["useable"] = true, 276 | ["shouldClose"] = true, 277 | ["combinable"] = nil, 278 | ["description"] = "Take your hands off the wheel!" 279 | }, 280 | ["ad_darts"] = { 281 | ["name"] = "ad_darts", 282 | ["label"] = "AD Darts", 283 | ["weight"] = 1, 284 | ["type"] = "item", 285 | ["image"] = "ad_darts.png", 286 | ["unique"] = false, 287 | ["useable"] = true, 288 | ["shouldClose"] = true, 289 | ["combinable"] = nil, 290 | ["description"] = "Take your hands off the wheel!" 291 | }, 292 | ["ad_osd"] = { 293 | ["name"] = "ad_osd", 294 | ["label"] = "AD OSD Upgrade", 295 | ["weight"] = 50, 296 | ["type"] = "item", 297 | ["image"] = "ad_darts.png", 298 | ["unique"] = false, 299 | ["useable"] = true, 300 | ["shouldClose"] = true, 301 | ["combinable"] = nil, 302 | ["description"] = "Take your hands off the wheel!" 303 | }, 304 | 305 | 306 | 307 | 308 | 309 | Copyright © 2022 310 | 311 | You can use and edit this code to your liking as long as you don't ever claim it to be your own code and always provide proper credit. You're not allowed to sell ta-autodrive or any code you take from it. If you want to release your own version of ta-autodrive, you have to link the original GitHub repo, or release it via a Forked repo. -------------------------------------------------------------------------------- /shared/speedlimits.lua: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------------------------------------------------------------------- 2 | ----------------------------------------------------------------------------------------------------------------------------------------- 3 | ----------------------------------------------------------------------------------------------------------- Speed Limts ----------------- 4 | ----------------------------------------------------------------------------------------------------------------------------------------- 5 | ----------------------------------------------------------------------------------------------------------------------------------------- 6 | local speedLimits = {} 7 | Street = {} 8 | 9 | if ADDefaults.UseMPH then 10 | speedLimits = { 11 | s0 = 20.0, 12 | s1 = 20.0, 13 | s2 = 25.0, 14 | s3 = 30.0, 15 | s4 = 35.0, 16 | s5 = 40.0, 17 | s6 = 45.0, 18 | s7 = 50.0, 19 | s8 = 65.0, 20 | s9 = 70.0, 21 | } 22 | else 23 | speedLimits = { 24 | s0 = 32.0, 25 | s1 = 32.0, 26 | s2 = 40.0, 27 | s3 = 48.0, 28 | s4 = 56.0, 29 | s5 = 64.0, 30 | s6 = 72.0, 31 | s7 = 80.0, 32 | s8 = 104.0, 33 | s9 = 112.0, 34 | } 35 | end 36 | 37 | Street.Speed = { 38 | ["Abattoir Ave"] = speedLimits.s3, 39 | ["Abe Milton Pkwy"] = speedLimits.s3, 40 | ["Ace Jones Dr"] = speedLimits.s3, 41 | ["Adam's Apple Blvd"] = speedLimits.s4, 42 | ["Aguja St"] = speedLimits.s1, 43 | ["Algonquin Blvd"] = speedLimits.s3, 44 | ["Alhambra Dr"] = speedLimits.s3, 45 | ["Alta Pl"] = speedLimits.s2, 46 | ["Alta St"] = speedLimits.s4, 47 | ["Amarillo Vista"] = speedLimits.s1, 48 | ["Amarillo Way"] = speedLimits.s3, 49 | ["Americano Way"] = speedLimits.s1, 50 | ["Armadillo Ave"] = speedLimits.s3, 51 | ["Atlee St"] = speedLimits.s2, 52 | ["Autopia Pkwy"] = speedLimits.s3, 53 | ["Banham Canyon Dr"] = speedLimits.s4, 54 | ["Barbareno Rd"] = speedLimits.s2, 55 | ["Bay City Ave"] = speedLimits.s2, 56 | ["Bay City Incline"] = speedLimits.s4, 57 | ["Baytree Canyon Rd"] = speedLimits.s4, 58 | ["Boulevard Del Perro"] = speedLimits.s3, 59 | ["Bridge St"] = speedLimits.s3, 60 | ["Brouge Ave"] = speedLimits.s2, 61 | ["Buccaneer Way"] = speedLimits.s6, 62 | ["Buen Vino Rd"] = speedLimits.s4, 63 | ["Caesars Place"] = speedLimits.s1, 64 | ["Calafia Rd"] = speedLimits.s2, 65 | ["Calais Ave"] = speedLimits.s3, 66 | ["Capital Blvd"] = speedLimits.s2, 67 | ["Carcer Way"] = speedLimits.s4, 68 | ["Carson Ave"] = speedLimits.s3, 69 | ["Cascabel Ave"] = speedLimits.s2, 70 | ["Cassidy Trail"] = speedLimits.s1, 71 | ["Cat-Claw Ave"] = speedLimits.s3, 72 | ["Catfish View"] = speedLimits.s3, 73 | ["Cavalry Blvd"] = speedLimits.s3, 74 | ["Chianski Passage"] = speedLimits.s2, 75 | ["Cholla Rd"] = speedLimits.s3, 76 | ["Cholla Springs Ave"] = speedLimits.s3, 77 | ["Chum St"] = speedLimits.s4, 78 | ["Chupacabra St"] = speedLimits.s2, 79 | ["Clinton Ave"] = speedLimits.s3, 80 | ["Cockingend Dr"] = speedLimits.s3, 81 | ["Conquistador St"] = speedLimits.s1, 82 | ["Cortes St"] = speedLimits.s1, 83 | ["Cougar Ave"] = speedLimits.s2, 84 | ["Covenant Ave"] = speedLimits.s2, 85 | ["Cox Way"] = speedLimits.s3, 86 | ["Crusade Rd"] = speedLimits.s2, 87 | ["Davis Ave"] = speedLimits.s4, 88 | ["Decker St"] = speedLimits.s3, 89 | ["Del Perro Fwy"] = speedLimits.s8, 90 | ["Didion Dr"] = speedLimits.s3, 91 | ["Dorset Dr"] = speedLimits.s4, 92 | ["Duluoz Ave"] = speedLimits.s3, 93 | ["Dunstable Dr"] = speedLimits.s3, 94 | ["Dunstable Ln"] = speedLimits.s3, 95 | ["Dutch London St"] = speedLimits.s4, 96 | ["East Galileo Ave"] = speedLimits.s3, 97 | ["East Joshua Road"] = speedLimits.s6, 98 | ["East Mirror Dr"] = speedLimits.s3, 99 | ["Eastbourne Way"] = speedLimits.s2, 100 | ["Eclipse Blvd"] = speedLimits.s3, 101 | ["Edwood Way"] = speedLimits.s1, 102 | ["El Burro Blvd"] = speedLimits.s3, 103 | ["El Rancho Blvd"] = speedLimits.s4, 104 | ["Elgin Ave"] = speedLimits.s4, 105 | ["Elysian Fields Fwy"] = speedLimits.s6, 106 | ["Equality Way"] = speedLimits.s2, 107 | ["Exceptionalists Way"] = speedLimits.s3, 108 | ["Fenwell Pl"] = speedLimits.s3, 109 | ["Fort Zancudo Approach Rd"] = speedLimits.s1, 110 | ["Forum Dr"] = speedLimits.s3, 111 | ["Fudge Ln"] = speedLimits.s1, 112 | ["Galileo Park"] = speedLimits.s3, 113 | ["Galileo Rd"] = speedLimits.s4, 114 | ["Gentry Lane"] = speedLimits.s2, 115 | ["Ginger St"] = speedLimits.s2, 116 | ["Glory Way"] = speedLimits.s3, 117 | ["Goma St"] = speedLimits.s1, 118 | ["Grapeseed Ave"] = speedLimits.s3, 119 | ["Grapeseed Main St"] = speedLimits.s3, 120 | ["Great Ocean Hwy"] = speedLimits.s8, 121 | ["Greenwich Pkwy"] = speedLimits.s3, 122 | ["Greenwich Pl"] = speedLimits.s3, 123 | ["Greenwich Way"] = speedLimits.s3, 124 | ["Grove St"] = speedLimits.s2, 125 | ["Hanger Way"] = speedLimits.s2, 126 | ["Hangman Ave"] = speedLimits.s3, 127 | ["Hardy Way"] = speedLimits.s3, 128 | ["Hawick Ave"] = speedLimits.s3, 129 | ["Heritage Way"] = speedLimits.s3, 130 | ["Hillcrest Ave"] = speedLimits.s3, 131 | ["Hillcrest Ridge Access Rd"] = speedLimits.s3, 132 | ["Imagination Ct"] = speedLimits.s1, 133 | ["Ineseno Road"] = speedLimits.s2, 134 | ["Innocence Blvd"] = speedLimits.s4, 135 | ["Integrity Way"] = speedLimits.s2, 136 | ["Invention Ct"] = speedLimits.s1, 137 | ["Jamestown St"] = speedLimits.s2, 138 | ["Joad Ln"] = speedLimits.s3, 139 | ["Joshua Rd"] = speedLimits.s6, 140 | ["Kimble Hill Dr"] = speedLimits.s3, 141 | ["Kortz Dr"] = speedLimits.s2, 142 | ["La Puerta Fwy"] = speedLimits.s8, 143 | ["Labor Pl"] = speedLimits.s3, 144 | ["Laguna Pl"] = speedLimits.s2, 145 | ["Lake Vinewood Dr"] = speedLimits.s3, 146 | ["Lake Vinewood Est"] = speedLimits.s3, 147 | ["Las Lagunas Blvd"] = speedLimits.s4, 148 | ["Lesbos Ln"] = speedLimits.s3, 149 | ["Liberty St"] = speedLimits.s2, 150 | ["Lindsay Circus"] = speedLimits.s2, 151 | ["Little Bighorn Ave"] = speedLimits.s3, 152 | ["Lolita Ave"] = speedLimits.s3, 153 | ["Los Santos Freeway"] = speedLimits.s8, 154 | ["Low Power St"] = speedLimits.s3, 155 | ["Macdonald St"] = speedLimits.s3, 156 | ["Mad Wayne Thunder Dr"] = speedLimits.s3, 157 | ["Magellan Ave"] = speedLimits.s1, 158 | ["Marathon Ave"] = speedLimits.s2, 159 | ["Marina Dr"] = speedLimits.s3, 160 | ["Marlowe Dr"] = speedLimits.s4, 161 | ["Melanoma St"] = speedLimits.s1, 162 | ["Meringue Ln"] = speedLimits.s3, 163 | ["Meteor St"] = speedLimits.s2, 164 | ["Milton Rd"] = speedLimits.s3, 165 | ["Miriam Turner Overpass"] = speedLimits.s2, 166 | ["Mirror Park Blvd"] = speedLimits.s3, 167 | ["Mirror Pl"] = speedLimits.s3, 168 | ["Morningwood Blvd"] = speedLimits.s3, 169 | ["Mountain View Dr"] = speedLimits.s3, 170 | ["Movie Star Way"] = speedLimits.s3, 171 | ["Mt Haan Rd"] = speedLimits.s4, 172 | ["Mt Vinewood Dr"] = speedLimits.s4, 173 | ["Mutiny Rd"] = speedLimits.s3, 174 | ["New Empire Way"] = speedLimits.s2, 175 | ["Nikola Ave"] = speedLimits.s3, 176 | ["Nikola Pl"] = speedLimits.s1, 177 | ["Niland Ave"] = speedLimits.s3, 178 | ["Normandy Dr"] = speedLimits.s3, 179 | ["North Calafia Way"] = speedLimits.s2, 180 | ["North Conker Ave"] = speedLimits.s3, 181 | ["North Rockford Dr"] = speedLimits.s3, 182 | ["North Sheldon Ave"] = speedLimits.s3, 183 | ["Nowhere Rd"] = speedLimits.s1, 184 | ["O'Neil Way"] = speedLimits.s1, 185 | ["Occupation Ave"] = speedLimits.s3, 186 | ["Olympic Fwy"] = speedLimits.s8, 187 | ["Orchardville Ave"] = speedLimits.s2, 188 | ["Paleto Blvd"] = speedLimits.s3, 189 | ["Palomino Ave"] = speedLimits.s3, 190 | ["Palomino Fwy"] = speedLimits.s8, 191 | ["Panorama Dr"] = speedLimits.s4, 192 | ["Perth St"] = speedLimits.s1, 193 | ["Picture Perfect Drive"] = speedLimits.s3, 194 | ["Plaice Pl"] = speedLimits.s2, 195 | ["Playa Vista"] = speedLimits.s2, 196 | ["Popular St"] = speedLimits.s4, 197 | ["Portola Dr"] = speedLimits.s2, 198 | ["Power St"] = speedLimits.s4, 199 | ["Procopio Dr"] = speedLimits.s3, 200 | ["Procopio Promenade"] = speedLimits.s1, 201 | ["Prosperity St"] = speedLimits.s2, 202 | ["Pyrite Ave"] = speedLimits.s2, 203 | ["Red Desert Ave"] = speedLimits.s2, 204 | ["Richman St"] = speedLimits.s3, 205 | ["Rockford Dr"] = speedLimits.s3, 206 | ["Route 68 Approach"] = speedLimits.s7, 207 | ["Route 68"] = speedLimits.s7, 208 | ["Roy Lowenstein Blvd"] = speedLimits.s3, 209 | ["Rub St"] = speedLimits.s1, 210 | ["Runway1"] = speedLimits.s9, 211 | ["Sam Austin Dr"] = speedLimits.s1, 212 | ["San Andreas Ave"] = speedLimits.s4, 213 | ["San Vitus Blvd"] = speedLimits.s4, 214 | ["Sandcastle Way"] = speedLimits.s2, 215 | ["Seaview Rd"] = speedLimits.s3, 216 | ["Senora Fwy"] = speedLimits.s8, 217 | ["Senora Rd"] = speedLimits.s4, 218 | ["Senora Way"] = speedLimits.s4, 219 | ["Shank St"] = speedLimits.s1, 220 | ["Signal St"] = speedLimits.s2, 221 | ["Sinner St"] = speedLimits.s2, 222 | ["Sinners Passage"] = speedLimits.s2, 223 | ["Smoke Tree Rd"] = speedLimits.s3, 224 | ["South Arsenal St"] = speedLimits.s3, 225 | ["South Boulevard Del Perro"] = speedLimits.s3, 226 | ["South Mo Milton Dr"] = speedLimits.s3, 227 | ["South Rockford Dr"] = speedLimits.s3, 228 | ["South Shambles St"] = speedLimits.s2, 229 | ["Spanish Ave"] = speedLimits.s2, 230 | ["Strawberry Ave"] = speedLimits.s4, 231 | ["Supply St"] = speedLimits.s2, 232 | ["Sustancia Rd"] = speedLimits.s6, 233 | ["Swiss St"] = speedLimits.s2, 234 | ["Tackle St"] = speedLimits.s1, 235 | ["Tongva Dr"] = speedLimits.s4, 236 | ["Tower Way"] = speedLimits.s3, 237 | ["Tug St"] = speedLimits.s1, 238 | ["Union Rd"] = speedLimits.s4, 239 | ["Utopia Gardens"] = speedLimits.s1, 240 | ["Vespucci Blvd"] = speedLimits.s4, 241 | ["Vinewood Blvd"] = speedLimits.s4, 242 | ["Vinewood Park Dr"] = speedLimits.s3, 243 | ["Vitus St"] = speedLimits.s1, 244 | ["Voodoo Place"] = speedLimits.s2, 245 | ["West Eclipse Blvd"] = speedLimits.s3, 246 | ["West Galileo Ave"] = speedLimits.s3, 247 | ["West Mirror Drive"] = speedLimits.s3, 248 | ["Whispymound Dr"] = speedLimits.s3, 249 | ["Wild Oats Dr"] = speedLimits.s3, 250 | ["Zancudo Ave"] = speedLimits.s3, 251 | ["Zancudo Barranca"] = speedLimits.s4, 252 | ["Zancudo Grande Valley"] = speedLimits.s4, 253 | ["Zancudo Rd"] = speedLimits.s3, 254 | } -------------------------------------------------------------------------------- /client/functions.lua: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------------------------------------------------------------------- 2 | ----------------------------------------------------------------------------------------------------------------------------------------- 3 | ----------------------------------------------------------------------------------------------------------- Functions ------------------- 4 | ----------------------------------------------------------------------------------------------------------------------------------------- 5 | ----------------------------------------------------------------------------------------------------------------------------------------- 6 | 7 | -- ######################################################################################################################################## 8 | -- ##########################################-------------------------------------- Globals 9 | DisplayStyleName = ADDefaults.DefaultDriveStyleName 10 | DisplaySpeed = ADDefaults.DefaultDriveSpeed 11 | IsAutoDriveEnabled = false 12 | DisplayDestination = ADDefaults.DefaultDestination 13 | 14 | ChosenBlip = ADDefaults.DefaultBlip 15 | ChosenDrivingStyleName = ADDefaults.DefaultDriveStyleName 16 | ChosenDrivingStyle = 0 17 | ChosenSpeed = ADDefaults.DefaultDriveSpeed 18 | SpeedUnits = ADDefaults.MPH 19 | 20 | GameBlip = ADDefaults.DefaultBlip 21 | GameDestination = 'freeroam' 22 | GameSpeed = ChosenSpeed / SpeedUnits 23 | PostedLimits = false 24 | 25 | IsPlayerInVehicle = nil 26 | DriverPed = nil 27 | 28 | ---@type integer blip id 29 | TaggedBlip = nil 30 | ---@type integer vehicle id 31 | TargetVeh = nil 32 | ---@type boolean is vehicle tagged 33 | IsVehicleTagged = false 34 | PedInTaggedVehicle = nil 35 | 36 | toggleSpeedUnits = false 37 | toggleDriverVisible = ADDefaults.VisibleDrivers 38 | toggleDriverCreation = ADDefaults.CreateDrivers 39 | toggleDriverForced = ADDefaults.ForceDrivers 40 | 41 | -- ######################################################################################################################################## 42 | -- ##########################################-------------------------------------- Subtitle function 43 | 44 | -- Subtitle function 45 | function Subtitle(message, timer) 46 | if ADDefaults.Subtitles then 47 | BeginTextCommandPrint("STRING") 48 | AddTextComponentString(message) 49 | EndTextCommandPrint(timer, true) 50 | end 51 | end 52 | 53 | -- ######################################################################################################################################## 54 | -- ##########################################-------------------------------------- Autodrive off command 55 | 56 | -- Autodrive subtitle 57 | function isAutodriveSubtitle() 58 | local styleName = ChosenDrivingStyleName 59 | local autodriveBool = "false" 60 | if ADDefaults.Subtitles then 61 | BeginTextCommandPrint("STRING") 62 | if IsAutoDriveEnabled then 63 | autodriveBool = DisplayDestination:gsub("^%l", string.upper) 64 | AddTextComponentString(string.format("Autodrive ~y~%s~s~ ~y~%s~s~", autodriveBool, styleName)) 65 | else 66 | autodriveBool = "Disabled" 67 | AddTextComponentString("Autodrive ~y~" .. autodriveBool) 68 | end 69 | EndTextCommandPrint(3000, true) 70 | end 71 | end 72 | 73 | -- ######################################################################################################################################## 74 | -- ##########################################-------------------------------------- Get User Input function 75 | function GetUserInput(windowTitle, defaultText, maxInputLength) 76 | -- Create the window title string. 77 | local resourceName = string.upper(GetCurrentResourceName()) 78 | local textEntry = resourceName .. "_WINDOW_TITLE" 79 | if windowTitle == nil then 80 | windowTitle = "Enter:" 81 | end 82 | AddTextEntry(textEntry, windowTitle) 83 | 84 | -- Display the input box. 85 | DisplayOnscreenKeyboard(1, textEntry, "", defaultText or "", "", "", "", maxInputLength or 30) 86 | Citizen.Wait(0) 87 | -- Wait for a result. 88 | while true do 89 | Citizen.Wait(0) 90 | local keyboardStatus = UpdateOnscreenKeyboard(); 91 | if keyboardStatus == 3 then -- not displaying input field anymore somehow 92 | return nil 93 | elseif keyboardStatus == 2 then -- cancelled 94 | return nil 95 | elseif keyboardStatus == 1 then -- finished editing 96 | return GetOnscreenKeyboardResult() 97 | else 98 | Citizen.Wait(0) 99 | end 100 | end 101 | end 102 | 103 | -- ######################################################################################################################################## 104 | -- ##########################################-------------------------------------- Get Keys/Values 105 | 106 | ---@param t table 107 | function get_key_for_value(t, value) 108 | for k, v in pairs(t) do 109 | if v == value then return k end 110 | end 111 | return nil 112 | end 113 | ---@params t table 114 | function get_value_for_key(t, key) 115 | for k, v in pairs(t) do 116 | if k == key then return v end 117 | end 118 | return nil 119 | end 120 | 121 | -- ######################################################################################################################################## 122 | -- ##########################################-------------------------------------- Get Driver Ped 123 | 124 | function GetDriverPed() 125 | local playerPed = PlayerPedId() 126 | local playerVeh = nil 127 | local retval = playerPed 128 | if not IsPedInAnyVehicle(playerPed, false) then 129 | -- print("GetDriverPed() PlayerPed not in vehicle. Ped is ", retval) 130 | return retval 131 | else 132 | playerVeh = GetVehiclePedIsIn(playerPed, false) 133 | if GetPedInVehicleSeat(playerVeh, -1) ~= playerPed then 134 | DriverPed = GetPedInVehicleSeat(playerVeh, -1) 135 | retval = GetPedInVehicleSeat(playerVeh, -1) 136 | end 137 | end 138 | -- print("GetDriverPed()", retval) 139 | return retval 140 | end 141 | 142 | -- ######################################################################################################################################## 143 | ----------------------------------------------------------------------------------------------------------- Permissions ------------------- 144 | -- ######################################################################################################################################## 145 | -- ##########################################-------------------------------------- Vehicle Whitelisted Check 146 | 147 | -- is vehicle whitelisted 148 | ---@param vehicle integer vehicle id 149 | ---@return boolean retval is vehicle whitelisted 150 | function whitelistedVehicle(vehicle) 151 | local retval = false 152 | if Config.Whitelist.Vehicles['all'] == true then retval = true --[[print("Whitelisted Vehicle", retval)]] return retval end 153 | for k, v in pairs(Config.Whitelist.Vehicles) do 154 | if GetEntityModel(vehicle) == GetHashKey(k) then 155 | retval = v 156 | -- print("Whitelisted Vehicle", retval) 157 | return retval 158 | end 159 | end 160 | -- print("Whitelisted Vehicle", retval) 161 | return retval 162 | end 163 | 164 | -- ######################################################################################################################################## 165 | -- ##########################################-------------------------------------- Is Part Installed Check 166 | 167 | -- is ad_kit installed, used in InstallPartsByVehicle 168 | ---@param vehicle integer vehicle id 169 | ---@param ad_part string autodrive part 170 | ---@return boolean bool is part installed 171 | function IsPartInstalled(vehicle, ad_part) 172 | -- print("IsPartInstalled", vehicle, ad_part) 173 | local ret = false 174 | if VehiclesWithAutodrive[vehicle] == nil then return ret end 175 | if VehiclesWithAutodrive[vehicle][ad_part] == true then 176 | ret = true 177 | return ret 178 | end 179 | return ret 180 | end 181 | 182 | -- ######################################################################################################################################## 183 | -- ##########################################-------------------------------------- Vehicle Blacklist Check 184 | 185 | -- is vehicle blacklisted 186 | ---@param vehicle integer vehicle id 187 | ---@return boolean retval is vehicle blacklisted 188 | function blacklistedVehicle(vehicle) 189 | local retval = false 190 | if Config.Blacklist.Vehicles['none'] == true then 191 | retval = false 192 | -- print("Blacklisted Vehicle", retval) 193 | return retval 194 | end 195 | for k, v in pairs(Config.Blacklist.Vehicles) do 196 | if GetEntityModel(vehicle) == GetHashKey(k) then 197 | retval = v 198 | -- print("Blacklisted Vehicle", retval) 199 | return retval 200 | end 201 | end 202 | -- print("Blacklisted Vehicle", retval) 203 | return retval 204 | end 205 | 206 | -- ######################################################################################################################################## 207 | -- ##########################################-------------------------------------- Whitlelisted job install check 208 | 209 | -- is job whitelsited 210 | ---@param ped integer player id 211 | ---@return boolean retval is job whitelisted to install 212 | function WhitelistedJobsInstall(ped) 213 | local QBCore = exports['qb-core']:GetCoreObject() 214 | local PlayerData = QBCore.Functions.GetPlayerData() 215 | local job = PlayerData.job.name 216 | local retval = false 217 | if Config.Whitelist.Jobs.Install['all'] == true then retval = true return retval end 218 | for k, v in pairs(Config.Whitelist.Jobs.Install) do 219 | if job == k then 220 | retval = v 221 | -- print("Whitelisted Job Install", retval) 222 | return retval 223 | end 224 | end 225 | -- print("Whitelisted Job Install", retval) 226 | return retval 227 | end 228 | 229 | -- ######################################################################################################################################## 230 | -- ##########################################-------------------------------------- Whitelisted job use check 231 | 232 | function WhitelistedJobsUsage(ped) 233 | -- if not ADDefaults.UseQBCore then return end 234 | local QBCore = exports['qb-core']:GetCoreObject() 235 | local PlayerData = QBCore.Functions.GetPlayerData() 236 | local job = PlayerData.job.name 237 | local retval = false 238 | if Config.Whitelist.Jobs.Usage['all'] == true then 239 | retval = true 240 | -- print("Whitelisted Job Usage", retval) 241 | return retval 242 | end 243 | for k, v in pairs(Config.Whitelist.Jobs.Usage) do 244 | if job == k then 245 | retval = v 246 | -- print("Whitelisted Job Usage", retval) 247 | return retval 248 | end 249 | end 250 | -- print("Whitelisted Job Usage", retval) 251 | return retval 252 | end 253 | 254 | -- ######################################################################################################################################## 255 | -- ##########################################-------------------------------------- Allowed to install function 256 | 257 | -- are autodrive functions allowed 258 | ---@param ped integer player id 259 | ---@param vehicle integer vehicle id 260 | ---@return boolean retval are autodrive functions allowed 261 | function IsAllowedToInstall(ped, vehicle) 262 | local retval = false 263 | -- if not IsADPartInstalled(vehicle, 'ad_kit') then NotifyAutodrive('notvehicle', 'error') return retval end 264 | if not WhitelistedJobsInstall(ped) then NotifyAutodrive('notjob', 'error') return retval end 265 | if blacklistedVehicle(vehicle) then NotifyAutodrive('notvehicle', 'error') return retval end 266 | if not whitelistedVehicle(vehicle) then NotifyAutodrive('notvehicle', 'error') return retval end 267 | retval = true 268 | -- print("IsAllowedToInstall()", retval) 269 | return retval 270 | end 271 | 272 | exports('isallowedtoinstall', function() 273 | return IsAllowedToInstall 274 | end) 275 | 276 | -- ######################################################################################################################################## 277 | -- ##########################################-------------------------------------- Allowed to use function 278 | 279 | function IsAllowedToUse(ped, vehicle) 280 | local retval = false 281 | -- if not IsADPartInstalled(vehicle, 'ad_kit') then NotifyAutodrive('notvehicle', 'error') return retval end 282 | if not WhitelistedJobsUsage(ped) then NotifyAutodrive('notjob', 'error') return retval end 283 | if blacklistedVehicle(vehicle) then NotifyAutodrive('notvehicle', 'error') return retval end 284 | if not whitelistedVehicle(vehicle) then NotifyAutodrive('notvehicle', 'error') return retval end 285 | 286 | if Config.RequirePartUpgrades then 287 | if not IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_destinations) then 288 | -- print("IsAllowedToUse() ad_dest not installed") 289 | Subtitle("ISPART()Autodrive Destinations ~r~Not Installed", 3000) 290 | return retval 291 | end 292 | end 293 | 294 | retval = true 295 | -- print("IsAllowedToUse()", retval) 296 | return retval 297 | 298 | end 299 | 300 | -- ######################################################################################################################################## 301 | ----------------------------------------------------------------------------------------------------------- Vehicles ------------------- 302 | 303 | -- get closest vehicle to ped 304 | ---@param ped integer player ped 305 | ---@return integer vehicle vehicle id 306 | function GetVehicle(ped) 307 | local pLoc = GetEntityCoords(ped) 308 | local vehicle = nil 309 | if IsAnyVehicleNearPoint(pLoc.x, pLoc.y, pLoc.z, 5.0) then 310 | if IsPedInAnyVehicle(ped, false) then 311 | vehicle = GetVehiclePedIsIn(ped, false) 312 | else 313 | vehicle = GetClosestVehicle(pLoc.x, pLoc.y, pLoc.z, 5.0, 0, 71) 314 | end 315 | end 316 | -- print("functions.lua, GetVehicle()", vehicle) 317 | return vehicle 318 | end 319 | 320 | 321 | 322 | 323 | 324 | -------------------------------------------------------------------------------- /client/autodriveradialmenu.lua: -------------------------------------------------------------------------------- 1 | 2 | function AddRadialParkingOption() 3 | local playerPed = PlayerPedId() 4 | if ADDefaults.UseQBCore and ADDefaults.UseRadialMenu then 5 | if Config.RequireParts then 6 | if IsPedInAnyVehicle(PlayerPedId(), false) then 7 | if not IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_kit) then 8 | -- print("ad_kit not installed") 9 | Subtitle("Autodrive ~r~Not Installed", 3000) 10 | return 11 | end 12 | end 13 | end 14 | 15 | if not WhitelistedJobsUsage(PlayerPedId()) then 16 | -- print("Job now allowed to use autodrive") 17 | Subtitle("Autodrive ~r~Not Allowed", 3000) 18 | return 19 | end 20 | 21 | if Config.RequirePartUpgrades then 22 | if not IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_destinations) then 23 | -- print("ad_dest not installed", IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_destinations)) 24 | Subtitle("Autodrive Destinations ~r~Not Installed", 3000) 25 | return 26 | end 27 | end 28 | 29 | if not IsAllowedToUse then 30 | -- print("Not Allowed to use", EventsTable.Destination) 31 | Subtitle("~r~Not Allowed to use", 3000) 32 | return 33 | end 34 | end 35 | if IsPedInAnyVehicle(playerPed) then -- Radial menu item 1 36 | local eventDest = EventsTable.Destination.name 37 | local eventStyle = EventsTable.Style.name 38 | local eventSpeed = EventsTable.Speed.name 39 | local eventSettings = EventsTable.Settings.name 40 | local eventType = 'client' 41 | 42 | local tableId = BlipDestination.BlipNames 43 | -- ############################################################################################################# 44 | -- ############################################################################################################# Radial Tables 45 | -- ############################################################################################################# 46 | 47 | local radialBlipsTable = {} 48 | for k,v in pairs(BlipDestination.BlipNames) do -- loop through our table 49 | radialBlipsTable[#radialBlipsTable + 1] = { -- insert data from our loop into the menu 50 | id = v.sprite, --k, 51 | title = v.title, 52 | icon = v.icon, --fa-face-grin-tears 53 | type = eventType, 54 | event = EventsTable.Destination.name, -- event name 55 | shouldClose = true 56 | } 57 | end 58 | 59 | local radialStylesTable = {} 60 | for k,v in pairs(StylesTable.Args) do -- loop through our table 61 | radialStylesTable[#radialStylesTable + 1] = { -- insert data from our loop into the menu 62 | id = v.id, --k, 63 | title = v.title, 64 | icon = v.icon, --fa-face-grin-tears 65 | type = eventType, 66 | event = EventsTable.Style.name, -- event name 67 | shouldClose = true 68 | } 69 | end 70 | 71 | local radialSettingsTable = {} 72 | for k,v in pairs(SettingsTable.Args) do -- loop through our table 73 | radialSettingsTable[#radialSettingsTable + 1] = { -- insert data from our loop into the menu 74 | id = v.id, --k, 75 | title = v.title, 76 | icon = v.icon, --fa-face-grin-tears 77 | type = eventType, 78 | event = EventsTable.Settings.name, -- event name 79 | shouldClose = true 80 | } 81 | end 82 | -- ############################################################################################################# 83 | -- ############################################################################################################# 84 | -- ############################################################################################################# 85 | 86 | MenuItemId = exports['qb-radialmenu']:AddOption({ 87 | id = 'autodrive', 88 | title = 'Autodrive', 89 | icon = 'paper-plane', 90 | type = eventType, 91 | items = 92 | { 93 | { -- Autodrive: Submenu level 1: Item 1: Destination 94 | id = DestTable.Info.id, 95 | title = DestTable.Info.title, 96 | icon = DestTable.Info.icon, 97 | items = 98 | { 99 | { -- Submenu level 2: Destination: Item 1: Free Roam 100 | id = DestTable.Args.Freeroam.id, 101 | title = DestTable.Args.Freeroam.title, 102 | icon = DestTable.Args.Freeroam.icon, 103 | type = eventType, 104 | event = eventDest, 105 | shouldClose = true 106 | }, 107 | { -- Submenu level 2: Destination: Item 2: Waypoint 108 | id = DestTable.Args.Waypoint.id, 109 | title = DestTable.Args.Waypoint.title, 110 | icon = DestTable.Args.Waypoint.icon, 111 | type = eventType, 112 | event = eventDest, 113 | shouldClose = true 114 | }, 115 | { -- Submenu level 2: Destination: Item 3: Fuel 116 | id = DestTable.Args.Fuel.id, 117 | title = DestTable.Args.Fuel.title, 118 | icon = DestTable.Args.Fuel.icon, 119 | type = eventType, 120 | event = eventDest, 121 | shouldClose = true 122 | }, 123 | { -- Submenu level 2: Destination: Item 4: Blip 124 | id = DestTable.Args.Blip.id, 125 | title = DestTable.Args.Blip.title, 126 | icon = DestTable.Args.Blip.icon, 127 | type = eventType, 128 | event = eventDest, 129 | items = radialBlipsTable, 130 | }, 131 | }, 132 | }, 133 | { -- Autodrive: Submenu level 1: Item 2: Driving Styles 134 | id = StylesTable.Info.id, 135 | title = StylesTable.Info.title, 136 | icon = StylesTable.Info.icon, 137 | items = radialStylesTable --{ 138 | -- { -- Submenu level 2: Driving Styles: Item 1: Safe 139 | -- id = StylesTable.Args.Safe.id, 140 | -- title = StylesTable.Args.Safe.title, 141 | -- icon = StylesTable.Args.Safe.icon, 142 | -- type = eventType, 143 | -- event = eventStyle, 144 | -- shouldClose = true 145 | -- }, 146 | -- { -- Submenu level 2: Driving Styles: Item 2: Code1 147 | -- id = StylesTable.Args.Code1.id, 148 | -- title = StylesTable.Args.Code1.title, 149 | -- icon = StylesTable.Args.Code1.icon, 150 | -- type = eventType, 151 | -- event = eventStyle, 152 | -- shouldClose = true 153 | -- }, 154 | -- { -- Submenu level 2: Driving Styles: Item 3: Aggressive 155 | -- id = StylesTable.Args.Aggressive.id, 156 | -- title = StylesTable.Args.Aggressive.title, 157 | -- icon = StylesTable.Args.Aggressive.icon, 158 | -- type = eventType, 159 | -- event = eventStyle, 160 | -- shouldClose = true 161 | -- }, 162 | -- { -- Submenu level 2: Driving Styles: Item 4: Wreckless 163 | -- id = StylesTable.Args.Wreckless.id, 164 | -- title = StylesTable.Args.Wreckless.title, 165 | -- icon = StylesTable.Args.Wreckless.icon, 166 | -- type = eventType, 167 | -- event = eventStyle, 168 | -- shouldClose = true 169 | -- }, 170 | -- { -- Submenu level 2: Driving Styles: Item 5: Code3 171 | -- id = StylesTable.Args.Code3.id, 172 | -- title = StylesTable.Args.Code3.title, 173 | -- icon = StylesTable.Args.Code3.icon, 174 | -- type = eventType, 175 | -- event = eventStyle, 176 | -- shouldClose = true 177 | -- }, 178 | -- { -- Submenu level 2: Driving Styles: Item 6: Custom Input 179 | -- id = StylesTable.Args.Custom.id, 180 | -- title = StylesTable.Args.Custom.title, 181 | -- icon = StylesTable.Args.Custom.icon, 182 | -- type = eventType, 183 | -- event = eventStyle, 184 | -- shouldClose = true 185 | -- }, 186 | -- }, 187 | }, 188 | { -- Autodrive: Submenu level 1: Item 3: Speed Limits 189 | id = SpeedTable.Info.id, 190 | title = SpeedTable.Info.title, 191 | icon = SpeedTable.Info.icon, 192 | items = { 193 | { -- Submenu level 2: Speed Limits: Item 1: posted speed 194 | id = 'postedspeed', 195 | title = 'Road Limits', 196 | icon = 'car-on', 197 | type = eventType, 198 | event = eventSpeed, 199 | shouldClose = true 200 | }, 201 | { -- Submenu level 2: Speed Limits: Item 1: manual speed 202 | id = 'setspeed', 203 | title = 'Input Limits', 204 | icon = 'keyboard', 205 | type = eventType, 206 | event = eventSpeed, 207 | shouldClose = true 208 | }, 209 | { -- Submenu level 2: Speed Limits: Item 1: reset speed 210 | id = 'resetspeed', 211 | title = 'Reset Limits', 212 | icon = 'recycle', 213 | type = eventType, 214 | event = eventSpeed, 215 | shouldClose = true 216 | } 217 | }, 218 | }, 219 | { -- Autodrive: Submenu level 1: Item 4: Settings 220 | id = SettingsTable.Info.id, 221 | title = SettingsTable.Info.title, 222 | icon = SettingsTable.Info.icon, 223 | items = radialSettingsTable -- { 224 | -- { -- Submenu level 2: Settings : Item 1: Osd toggle 225 | -- id = SettingsTable.Args.ToggleOsd.id, 226 | -- title = SettingsTable.Args.ToggleOsd.title, 227 | -- icon = SettingsTable.Args.ToggleOsd.icon, 228 | -- type = eventType, 229 | -- event = eventSettings, 230 | -- shouldClose = true 231 | -- }, 232 | -- { -- Submenu level 2: Settings: Item 2: Osd timed toggle 233 | -- id = SettingsTable.Args.TimedOsd.id, 234 | -- title = SettingsTable.Args.TimedOsd.title, 235 | -- icon = 'clock', 236 | -- type = SettingsTable.Args.TimedOsd.icon, 237 | -- event = eventSettings, 238 | -- shouldClose = true 239 | -- }, 240 | -- { -- Submenu level 2: Settings: Item 3: Speed Units Toggle 241 | -- id = SettingsTable.Args.SetSpeedUnits.id, 242 | -- title = SettingsTable.Args.SetSpeedUnits.title, 243 | -- icon = SettingsTable.Args.SetSpeedUnits.icon, 244 | -- type = eventType, 245 | -- event = 'ta-autodrive:client:settings:setspeedunits', 246 | -- shouldClose = true 247 | -- }, 248 | -- }, 249 | }, 250 | { -- Autodrive: Submenu level 1: Item 5: OSD Toggle 251 | id = SettingsTable.Args.OSD.id, 252 | title = SettingsTable.Args.OSD.title, 253 | icon = SettingsTable.Args.OSD.icon, 254 | type = eventType, 255 | event = eventSettings, -- ExecuteCommand(ADCommands.OSDToggle), 256 | shouldClose = true, 257 | }, 258 | { -- Autodrive: Submenu level 1: Item 6: Autodrive toggle 259 | id = 'autodrive', 260 | title = 'Autodrive', 261 | icon = 'paper-plane', 262 | type = eventType, 263 | event = EventsTable.Start, -- ExecuteCommand(ADCommands.OSDToggle), 264 | shouldClose = true, 265 | }, 266 | } 267 | }, MenuItemId) 268 | end 269 | if DoesEntityExist(TargetVeh) and IsPedInAnyVehicle(playerPed) then -- Radial menu item 2 270 | MenuItemId1 = exports['qb-radialmenu']:AddOption({ 271 | -- Submenu level 1: Destination: Item 4: Follow car 272 | id = DestTable.Args.Follow.id, 273 | title = DestTable.Args.Follow.title, 274 | icon = DestTable.Args.Follow.icon, 275 | type = 'client', 276 | event = EventsTable.Destination.name, 277 | shouldClose = true 278 | }, MenuItemId1) 279 | end 280 | end 281 | 282 | -- event to add autodrive to qb-radialmenu 283 | AddEventHandler('qb-radialmenu:client:onRadialmenuOpen', function() 284 | if ADDefaults.UseRadialMenu then AddRadialParkingOption() end 285 | end) 286 | 287 | 288 | -------------------------------------------------------------------------------- /client/client.lua: -------------------------------------------------------------------------------- 1 | local QBCore = nil 2 | if ADDefaults.UseQBCore then 3 | QBCore = exports['qb-core']:GetCoreObject() 4 | end 5 | -- local TADev = exports['ta-dev']:GetTADevObject() 6 | 7 | ----------------------------------------------------------------------------------------------------------------------------------------- 8 | ----------------------------------------------------------------------------------------------------------------------------------------- 9 | ----------------------------------------------------------------------------------------------------------- Set Client Defaults --------- 10 | ----------------------------------------------------------------------------------------------------------------------------------------- 11 | ----------------------------------------------------------------------------------------------------------------------------------------- 12 | 13 | Values = { 14 | ["Safe"] = 411, 15 | ["Code1"] = 283, 16 | ["Aggressive"] = 318, 17 | ["Wreckless"] = 786988, 18 | ["Code3"] = 787007, 19 | ["Chase"] = 262685, 20 | ["Follow"] = 262719, 21 | ["Custom"] = ChosenDrivingStyle, 22 | } 23 | 24 | local runTagger = false 25 | local speedString = "" 26 | 27 | ----------------------------------------------------------------------------------------------------------------------------------------- 28 | ----------------------------------------------------------------------------------------------------------------------------------------- 29 | ----------------------------------------------------------------------------------------------------------- Set Globals ----------------- 30 | ----------------------------------------------------------------------------------------------------------------------------------------- 31 | ----------------------------------------------------------------------------------------------------------------------------------------- 32 | 33 | -- set mph or kmh 34 | ChosenDrivingStyle = get_value_for_key(Values, ChosenDrivingStyleName) 35 | if ADDefaults.UseMPH then 36 | SpeedUnits = ADDefaults.MPH 37 | ChosenSpeed = ADDefaults.DefaultDriveSpeed 38 | speedString = "mph" 39 | else 40 | SpeedUnits = ADDefaults.KMH 41 | ChosenSpeed = ADDefaults.DefaultDriveSpeed 42 | speedString = "kmh" 43 | end 44 | 45 | -- ##########################################-------------------------------------- Print Settings function 46 | function PrintSettings() 47 | local toggle = false 48 | if toggle then 49 | print(string.format( 'Destination ^3%s ^7| Style ^3%s ^7| Name ^3%s ^7| Speed ^3%s ^7| GameSpeed ^3%s ^7| GameDestination ^3%s', 50 | DisplayDestination:gsub("^%l", string.upper), ChosenDrivingStyle, ChosenDrivingStyleName, 51 | ChosenSpeed, ChosenSpeed/SpeedUnits, GameDestination)) 52 | end 53 | end 54 | -- ##########################################-------------------------------------- Driving Style Events function 55 | ---@param dsName string driving style name 56 | function DrivingStyleEvents(dsName) 57 | local playerPed = PlayerPedId() 58 | local ped = nil 59 | ped = SetDriverPed() 60 | ChosenDrivingStyleName = dsName -- tostring(dsName:gsub("^%l", string.upper)) 61 | ChosenDrivingStyle = get_value_for_key(Values, ChosenDrivingStyleName) 62 | SetDriveTaskDrivingStyle(ped, ChosenDrivingStyle) 63 | Subtitle("Driving Style: ~y~" .. ChosenDrivingStyleName, 1000) 64 | TimedOSD() 65 | PrintSettings() 66 | end 67 | -- ##########################################-------------------------------------- Destination Events function 68 | 69 | ---@param dest string destination name 70 | function DestinationEvents(dest) 71 | local playerPed = PlayerPedId() 72 | local ped = nil 73 | ped = SetDriverPed() 74 | DisplayDestination = dest:gsub("^%l", string.upper) 75 | SetDriverAbility(ped, 1.0) 76 | isAutodriveSubtitle() 77 | TimedOSD() 78 | PrintSettings() 79 | end 80 | -- ##########################################-------------------------------------- Remove target function 81 | function RemoveTarget() 82 | if DoesBlipExist(TaggedBlip) then RemoveBlip(TaggedBlip) end 83 | TargetVeh = 0 84 | IsVehicleTagged = false 85 | PedInTaggedVehicle = nil 86 | TaggedBlip = 0 87 | Subtitle("Target Removed", 3000) 88 | end 89 | -- ##########################################-------------------------------------- Raycast function 90 | local raycastCounter = 0 91 | local hitCounter = 0 92 | function Raycast(ped) 93 | runTagger = true 94 | 95 | raycastCounter = raycastCounter +1 96 | local whileCounter = 0 97 | local wait = true 98 | local vehicle 99 | local offSet 100 | local offSet2 101 | local shapeTest 102 | local retval, hit, endCoords, surfaceNormal, entityHit = nil 103 | 104 | -- run raycast while wait == true 105 | while wait do 106 | Citizen.Wait(100) 107 | Citizen.SetTimeout(ADDefaults.TagVehicleScanTime, function() 108 | if entityHit == nil then 109 | Subtitle("No vehicle ~y~Tagged", 3000) 110 | end 111 | wait = false 112 | end) 113 | RemoveTarget() 114 | whileCounter = whileCounter +1 115 | hitCounter = hitCounter +1 116 | 117 | vehicle = GetVehiclePedIsIn(ped, false) 118 | offSet = GetOffsetFromEntityInWorldCoords(ped, 0.0, 1.0, 0.0) -- distance start point 119 | offSet2 = GetOffsetFromEntityInWorldCoords(ped, 0.0, 31.0, 0.0) -- distance end point 120 | shapeTest = StartShapeTestCapsule(offSet.x, offSet.y, offSet.z, offSet2.x, offSet2.y, offSet2.z, 6.0, 10, vehicle, 0) 121 | retval, hit, endCoords, surfaceNormal, entityHit = GetShapeTestResult(shapeTest) 122 | if hit == 1 then break end 123 | end 124 | -- wait = false 125 | if entityHit == nil then 126 | -- print(entityHit) 127 | Subtitle("No vehicle ~y~Tagged", 3000) 128 | end 129 | runTagger = false 130 | 131 | return entityHit 132 | end 133 | -- ##########################################-------------------------------------- Tag vehicle function 134 | function TagVehicle() 135 | local playerPed = PlayerPedId() 136 | TargetVeh = Raycast(playerPed) 137 | -- print("TagVehicle() TargetVeh", TargetVeh) 138 | PedInTaggedVehicle = GetPedInVehicleSeat(TargetVeh, -1) 139 | TaggedBlip = AddBlipForEntity(TargetVeh) 140 | -- SetBlipFlashes(TaggedBlip, true) 141 | SetBlipColour(TaggedBlip, 5) 142 | if DoesEntityExist(TargetVeh) then IsVehicleTagged = true end 143 | end 144 | -- ##########################################-------------------------------------- Is vehicle tagged function 145 | function GetVehicleTarget() 146 | while not IsVehicleTagged do 147 | Citizen.Wait(10) 148 | Subtitle("Scanning ~y~Vehicles", 3000) 149 | if not runTagger then TagVehicle() end 150 | if not IsVehicleTagged then break end 151 | end 152 | end 153 | -- ##########################################-------------------------------------- Does target already exist function 154 | function DoesTargetExist() 155 | if DoesBlipExist(TaggedBlip) then RemoveBlip(TaggedBlip) end 156 | TargetVeh = nil 157 | IsVehicleTagged = false 158 | PedInTaggedVehicle = nil 159 | TaggedBlip = nil 160 | if not runTagger then TagVehicle() end 161 | end 162 | -- ##########################################-------------------------------------- Create a vehicle tag function 163 | createTagSpam = false 164 | function CreateTag() 165 | if IsPedInAnyVehicle(PlayerPedId()) then 166 | if not createTagSpam then 167 | if DoesEntityExist(TargetVeh) then 168 | RemoveTarget() 169 | elseif not IsVehicleTagged then 170 | GetVehicleTarget() 171 | elseif DoesEntityExist(TargetVeh) == false then 172 | DoesTargetExist() 173 | end 174 | if DoesEntityExist(TargetVeh) then 175 | Subtitle("Vehicle ~y~Tagged", 3000) 176 | end 177 | end 178 | createTagSpam = false 179 | end 180 | end 181 | 182 | function GetTaggedVehicle() 183 | return TargetVeh 184 | end 185 | 186 | exports('GetTaggedVehicle', function() 187 | return GetTaggedVehicle() 188 | end) 189 | ----------------------------------------------------------------------------------------------------------------------------------------- 190 | ----------------------------------------------------------------------------------------------------------------------------------------- 191 | ----------------------------------------------------------------------------------------------------------- Hotkeys --------------------- 192 | ----------------------------------------------------------------------------------------------------------------------------------------- 193 | ----------------------------------------------------------------------------------------------------------------------------------------- 194 | 195 | if ADCommands.EnableHotKeys then 196 | local keyDebug = false 197 | Citizen.CreateThread(function() 198 | while true do 199 | Citizen.Wait(0) 200 | if IsPedInAnyVehicle(PlayerPedId()) then 201 | if IsControlJustPressed(1, ADHotkeys.Start) then -- Tag car with key "numpad 5" 202 | TriggerEvent("autodrive:client:startautodrive") 203 | if keyDebug then print("^6Key Pressed numpad 5") end 204 | end 205 | if IsControlJustPressed(1, ADHotkeys.Stop) then -- Stop Autodrive with key "s" 206 | TriggerEvent("autodrive:client:stopautodrive") 207 | if keyDebug then print("^6Key Pressed s") end 208 | end 209 | if IsControlJustPressed(1, ADHotkeys.Tag) then -- Tag car with key "[" 210 | if not tagCarTrue then 211 | TriggerEvent("autodrive:client:destination:followcar") 212 | tagCarTrue = true 213 | Subtitle("Tagging ~y~Vehicle", 3000) 214 | if keyDebug then print("^6Key Pressed [") end 215 | else 216 | TriggerEvent("autodrive:client:stopautodrive") 217 | tagCarTrue = false 218 | end 219 | end 220 | if IsControlJustPressed(1, ADHotkeys.Follow) then -- FOllow car with key "]"" 221 | TriggerEvent("autodrive:client:destination:followcar") 222 | if keyDebug then print("^6Key Pressed ]") end 223 | end 224 | -- if IsControlJustPressed(1, ADHotkeys.SpeedUp) then -- Speed Up with key "numpad 6" 225 | -- -- TriggerEvent("autodrive:client:destination:followcar") 226 | 227 | -- end 228 | -- if IsControlJustPressed(1, ADHotkeys.SpeedDown) then -- Speed Down with key "numpad 4" 229 | -- -- TriggerEvent("autodrive:client:destination:followcar") 230 | 231 | -- end 232 | end 233 | end 234 | end) 235 | end 236 | 237 | ----------------------------------------------------------------------------------------------------------------------------------------- 238 | ----------------------------------------------------------------------------------------------------------------------------------------- 239 | ----------------------------------------------------------------------------------------------------------- On Screen Display ----------- 240 | ----------------------------------------------------------------------------------------------------------------------------------------- 241 | ----------------------------------------------------------------------------------------------------------------------------------------- 242 | 243 | local function Draw2DText(content, font, colour, scale, x, y) 244 | SetTextFont(font) 245 | SetTextScale(scale, scale) 246 | SetTextColour(colour[1],colour[2],colour[3], 255) 247 | SetTextEntry("STRING") 248 | SetTextDropShadow(0, 0, 0, 0,255) 249 | SetTextDropShadow() 250 | SetTextEdge(4, 0, 0, 0, 255) 251 | SetTextOutline() 252 | AddTextComponentString(content) 253 | DrawText(x, y) 254 | end 255 | 256 | local vehicleOSDMode = false 257 | function ToggleOSDMode() 258 | vehicleOSDMode = not vehicleOSDMode 259 | 260 | local x = ADDefaults.OSDX 261 | local y = ADDefaults.OSDY 262 | local scaleSpacingX = -.025 * 0 263 | local scaleSpacingY = -.025 * 2 264 | local string1 = nil 265 | local string2 = nil 266 | local string3 = nil 267 | local colorText = { 255, 255, 255 } 268 | local colorValue = { 66, 182, 245 } 269 | 270 | local playerPed = PlayerPedId() 271 | 272 | local drawText1 = nil 273 | local drawText2 = nil 274 | local drawText3 = nil 275 | local autodriveString = nil 276 | 277 | if SpeedUnits == ADDefaults.MPH then 278 | -- print("ToggleOSDMode(): SpeedUnits", SpeedUnits) 279 | speedString = "mph" 280 | else 281 | -- print("ToggleOSDMode(): SpeedUnits", SpeedUnits) 282 | 283 | speedString = "kmh" 284 | end 285 | Citizen.CreateThread(function() 286 | while vehicleOSDMode and IsPedInAnyVehicle(playerPed) do 287 | Citizen.Wait(0) 288 | 289 | if not IsAutoDriveEnabled then autodriveString = "Off" else autodriveString = "On" end 290 | 291 | string1 = '~w~VehId ~b~%s~s~ ~w~| Plates ~b~%s~s~ ~w~| Ped ~b~%s~s~' 292 | if DoesEntityExist(TargetVeh) then 293 | drawText1 = Draw2DText(string.format(string1, GetDisplayNameFromVehicleModel(GetEntityModel(TargetVeh)), 294 | GetVehicleNumberPlateText(TargetVeh), PedInTaggedVehicle), 4, colorValue, 0.6, 295 | x + 0.0 + scaleSpacingX, y + 0.0 + scaleSpacingY) end 296 | 297 | string2 = 'Autodrive ~b~%s~s~ | Destination ~b~%s~s~' 298 | drawText2 = Draw2DText(string.format(string2, autodriveString, DisplayDestination), 4, colorText, 0.6, 299 | x + 0.0 + scaleSpacingX, y + 0.025 + scaleSpacingY) 300 | 301 | string3 = 'Style ~b~%s~s~ | Speed ~b~%s~s~ ~b~%s~s~' 302 | drawText3 = Draw2DText(string.format(string3, ChosenDrivingStyleName, math.floor(ChosenSpeed), speedString), 4, colorText, 0.6, 303 | x + 0.0 + scaleSpacingX , y + 0.050 + scaleSpacingY) 304 | 305 | if not IsPedInAnyVehicle(playerPed) then vehicleOSDMode = false end 306 | end 307 | end) 308 | end 309 | 310 | function TimedOSD() 311 | if ADDefaults.OnScreenDisplay then 312 | if not vehicleOSDMode and IsPedInAnyVehicle(PlayerPedId()) then 313 | ToggleOSDMode() 314 | end 315 | 316 | if ADDefaults.OSDtimed then 317 | if vehicleOSDMode then ToggleOSDMode() end 318 | ToggleOSDMode() 319 | Citizen.Wait(3000) 320 | if vehicleOSDMode then ToggleOSDMode() end 321 | end 322 | end 323 | end 324 | 325 | ----------------------------------------------------------------------------------------------------------------------------------------- 326 | ----------------------------------------------------------------------------------------------------------------------------------------- 327 | ----------------------------------------------------------------------------------------------------------- Cleanup --------------------- 328 | ----------------------------------------------------------------------------------------------------------------------------------------- 329 | ----------------------------------------------------------------------------------------------------------------------------------------- 330 | 331 | --*********************----*********************----*********************-- 332 | --*********************-- Disable/Cleanup Events --*********************-- 333 | -- ##############################################################################-- onResoureStart 334 | AddEventHandler('onResourceStart', function(resource) 335 | if resource == GetCurrentResourceName() then 336 | end 337 | end) 338 | 339 | -- ##############################################################################-- onResoureStop 340 | AddEventHandler('onResourceStop', function(resource) 341 | local playerPed = PlayerPedId() 342 | local playerVeh = GetVehiclePedIsIn(playerPed, false) 343 | if resource == GetCurrentResourceName() then 344 | TriggerEvent(EventsTable.Stop) 345 | IsAutoDriveEnabled = false 346 | PostedLimits = false 347 | SetBlipRoute(GetClosestBlipOfType(ChosenBlip), false) 348 | if DoesEntityExist(DriverPed) and DriverPed ~= PlayerPedId() then DeleteEntity(DriverPed) end 349 | ClearPedTasks(playerPed) 350 | if ADDefaults.UseRadialMenu and MenuItemId ~=nil then -- remove from radial menu 351 | exports['qb-radialmenu']:RemoveOption(MenuItemId) 352 | exports['qb-radialmenu']:RemoveOption(MenuItemId1) 353 | MenuItemId = nil 354 | end 355 | TriggerEvent(EventsTable.QBMenu.close) 356 | isAutodriveSubtitle() 357 | end 358 | end) 359 | 360 | 361 | -------------------------------------------------------------------------------- /client/menu.lua: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------------------------------------------------------------------- 2 | ----------------------------------------------------------------------------------------------------------------------------------------- 3 | ----------------------------------------------------------------------------------------------------------- Native Menu ----------------- 4 | ----------------------------------------------------------------------------------------------------------------------------------------- 5 | ----------------------------------------------------------------------------------------------------------------------------------------- 6 | 7 | _menuPool = NativeUI.CreatePool() 8 | mainMenu = NativeUI.CreateMenu("Autodrive", "~b~-- Menu Options -- ") 9 | _menuPool:Add(mainMenu) 10 | 11 | --*********************-- Toggle Autodrive Events --*********************-- 12 | 13 | -- Used in "FirstMenu" to toggle autodrive 14 | function FirstItem(menu) 15 | local playerPed = PlayerPedId() 16 | local toggle = NativeUI.CreateItem("Autodrive", "-- Toggle Autodrive --") 17 | toggle.Activated = function(sender, item) 18 | if IsPedInAnyVehicle(playerPed, false) then 19 | if item == toggle then 20 | if not IsAutoDriveEnabled then 21 | TriggerEvent(EventsTable.Start) 22 | elseif IsAutoDriveEnabled then 23 | TriggerEvent(EventsTable.Stop) 24 | end 25 | end 26 | end 27 | end 28 | menu:AddItem(toggle) 29 | end 30 | 31 | --*********************-- Driving Style Events --*********************-- 32 | 33 | -- Used in "SecondItem" to select driving style 34 | 35 | function SecondItem(menu) -- Driving style menu item 36 | local playerPed = PlayerPedId() 37 | 38 | local submenu = _menuPool:AddSubMenu(menu, "~y~Driving Style", "-- Open Driving Style Submenu --") 39 | local dsSafe = NativeUI.CreateItem("Safe", "") 40 | local dsCode1 = NativeUI.CreateItem("Code 1", "") 41 | local dsAggressive = NativeUI.CreateItem("Aggressive", "") 42 | local dsWreckless = NativeUI.CreateItem("Wreckless", "") 43 | local dsCode3 = NativeUI.CreateItem("Code 3", "") 44 | local dsChase = NativeUI.CreateItem("Chase", "") 45 | local dsCustom = NativeUI.CreateItem("Custom Input", "") 46 | local eventStyle = EventsTable.Style.name 47 | -- Driving style Submenu item 1 Safe 48 | dsSafe.Activated = function(sender, item) 49 | if item == dsSafe then 50 | ChosenDrivingStyleName = StylesTable.Args.Safe.id 51 | TriggerEvent(eventStyle, ChosenDrivingStyleName) 52 | end end 53 | 54 | -- Driving style Submenu item 2 Code1 55 | dsCode1.Activated = function(sender, item) 56 | if item == dsCode1 then 57 | ChosenDrivingStyleName = StylesTable.Args.Code1.id 58 | TriggerEvent(eventStyle, ChosenDrivingStyleName) 59 | end end 60 | 61 | -- Driving style Submenu item 5 Code3 62 | dsCode3.Activated = function(sender, item) 63 | if item == dsCode3 then 64 | ChosenDrivingStyleName = StylesTable.Args.Code3.id 65 | TriggerEvent(eventStyle, ChosenDrivingStyleName) 66 | end end 67 | 68 | -- Driving style Submenu item 3 Aggressive 69 | dsAggressive.Activated = function(sender, item) 70 | if item == dsAggressive then 71 | ChosenDrivingStyleName = StylesTable.Args.Aggressive.id 72 | TriggerEvent(eventStyle, ChosenDrivingStyleName) 73 | end end 74 | 75 | -- Driving style Submenu item 4 Wreckless 76 | dsWreckless.Activated = function(sender, item) 77 | if item == dsWreckless then 78 | ChosenDrivingStyleName = StylesTable.Args.Wreckless.id 79 | TriggerEvent(eventStyle, ChosenDrivingStyleName) 80 | end end 81 | 82 | -- Driving style Submenu item 6 Chase 83 | dsChase.Activated = function(sender, item) 84 | if item == dsChase then 85 | ChosenDrivingStyleName = StylesTable.Args.Chase.id 86 | TriggerEvent(eventStyle, ChosenDrivingStyleName) 87 | end end 88 | 89 | -- Driving style Submenu item 7 Custom 90 | dsCustom.Activated = function(sender, item) 91 | if item == dsCustom then 92 | -- TriggerEvent('ta-autodrive:client:drivingstyle', 'Custom') 93 | 94 | local customDrivingStyle = GetUserInput("Custom Driving Style", "") 95 | ChosenDrivingStyle = customDrivingStyle 96 | ChosenDrivingStyleName = "Custom" 97 | SetDriveTaskDrivingStyle(playerPed, ChosenDrivingStyle) 98 | TimedOSD() 99 | Subtitle("Driving Style: ~y~Custom", 1000) 100 | 101 | end end 102 | 103 | submenu:AddItem(dsSafe) 104 | submenu:AddItem(dsCode1) 105 | submenu:AddItem(dsCode3) 106 | submenu:AddItem(dsAggressive) 107 | submenu:AddItem(dsWreckless) 108 | submenu:AddItem(dsChase) 109 | submenu:AddItem(dsCustom) 110 | end 111 | 112 | --*********************-- Destination Events --*********************-- 113 | 114 | -- Used in "ThirdItem" to select destination type: FreeRoam, Waypoint, etc 115 | local destinationType = { 116 | "Freeroam", 117 | "Blip", 118 | "Waypoint", 119 | "Fuel", 120 | "Tag Vehicle", 121 | "Follow Vehicle" 122 | } 123 | 124 | function ThirdItem(menu) -- Select destination 125 | local submenu = _menuPool:AddSubMenu(menu, "~y~Destination", "-- Open Destination Menu --") 126 | local dtFreeroam = NativeUI.CreateItem("Free Roam", "") 127 | local dtWaypoint = NativeUI.CreateItem("Waypoint", "") 128 | local submenuBlips = _menuPool:AddSubMenu(submenu, "~y~Blips", "-- Open Blips Menu --") 129 | -- local dtBlip = NativeUI.CreateItem("Blip", "") 130 | local dtFuel = NativeUI.CreateItem("Fuel", "") 131 | local dtTag = NativeUI.CreateItem("Tag Vehicle", "") 132 | local dtFollow = NativeUI.CreateItem("Follow Vehicle", "") 133 | 134 | -- local blipsTable = BlipsDestination.BlipNames 135 | local blipPolice = NativeUI.CreateItem("Police", "") 136 | local blipHospital = NativeUI.CreateItem("Hospital", "") 137 | local blipAmmunation = NativeUI.CreateItem("Ammunation", "") 138 | local blipGarage = NativeUI.CreateItem("Garage", "") 139 | 140 | local eventDest = EventsTable.Destination.name 141 | local stopAD = function() TriggerEvent(EventsTable.Stop) end 142 | -- Destination Submenu item 1 Freeroam 143 | dtFreeroam.Activated = function(sender, item) 144 | if item == dtFreeroam then 145 | stopAD() 146 | DisplayDestination = DestTable.Args.Freeroam.title 147 | local args = DestTable.Args.Freeroam.id 148 | TriggerEvent(eventDest, args) 149 | end end 150 | 151 | -- Destination Submenu item 2 Waypoint 152 | dtWaypoint.Activated = function(sender, item) 153 | if item == dtWaypoint then 154 | stopAD() 155 | DisplayDestination = DestTable.Args.Waypoint.title 156 | local args = DestTable.Args.Waypoint.id 157 | TriggerEvent(eventDest, args) 158 | end end 159 | 160 | -- -- Destination Submenu item 3 Blip 161 | -- dtBlip.Activated = function(sender, item) 162 | -- if item == dtBlip then 163 | -- TriggerEvent("ta-autodrive:client:stopautodrive") 164 | -- DisplayDestination = "blip" 165 | -- TriggerEvent("ta-autodrive:client:destination", DisplayDestination) 166 | -- end end 167 | 168 | -- Destination Submenu item 4 Fuel 169 | dtFuel.Activated = function(sender, item) 170 | if item == dtFuel then 171 | stopAD() 172 | DisplayDestination = DestTable.Args.Fuel.title 173 | local args = DestTable.Args.Fuel.id 174 | TriggerEvent(eventDest, args) 175 | end end 176 | 177 | -- Destination Submenu item 5 Tag Car 178 | dtTag.Activated = function(sender, item) 179 | if item == dtTag then 180 | stopAD() 181 | DisplayDestination = DestTable.Args.Tag.title 182 | local args = DestTable.Args.Tag.id 183 | TriggerEvent(eventDest, args) 184 | end end 185 | -- Destination Submenu item 6 Follow Car 186 | dtFollow.Activated = function(sender, item) 187 | if item == dtFollow then 188 | stopAD() 189 | DisplayDestination = DestTable.Args.Follow.title 190 | local args = DestTable.Args.Follow.id 191 | TriggerEvent(eventDest, args) 192 | end end 193 | 194 | -- ########## Blips Submenu ########## -- 195 | blipPolice.Activated = function(sender, item) 196 | if item == blipPolice then 197 | stopAD() 198 | DisplayDestination = BlipDestination.BlipNames.Police.title 199 | local args = BlipDestination.BlipNames.Police.sprite 200 | TriggerEvent(eventDest, args) 201 | end end 202 | blipHospital.Activated = function(sender, item) 203 | if item == blipHospital then 204 | stopAD() 205 | DisplayDestination = BlipDestination.BlipNames.Hospital.title 206 | local args = BlipDestination.BlipNames.Hospital.sprite 207 | TriggerEvent(eventDest, args) 208 | end end 209 | blipAmmunation.Activated = function(sender, item) 210 | if item == blipAmmunation then 211 | stopAD() 212 | DisplayDestination = BlipDestination.BlipNames.Ammunation.title 213 | local args = BlipDestination.BlipNames.Ammunation.sprite 214 | TriggerEvent(eventDest, args) 215 | end end 216 | blipGarage.Activated = function(sender, item) 217 | if item == blipGarage then 218 | stopAD() 219 | DisplayDestination = BlipDestination.BlipNames.Garage.title 220 | local args = BlipDestination.BlipNames.Garage.sprite 221 | TriggerEvent(eventDest, args) 222 | end end 223 | 224 | 225 | 226 | submenu:AddItem(dtFreeroam) 227 | submenu:AddItem(dtWaypoint) 228 | -- submenu:AddItem(dtBlip) 229 | submenu:AddItem(dtFuel) 230 | submenu:AddItem(dtTag) 231 | submenu:AddItem(dtFollow) 232 | 233 | submenuBlips:AddItem(blipPolice) 234 | submenuBlips:AddItem(blipHospital) 235 | submenuBlips:AddItem(blipAmmunation) 236 | submenuBlips:AddItem(blipGarage) 237 | 238 | end 239 | 240 | --*********************-- Speed Limit Events --*********************-- 241 | 242 | -- Used in "speedLimiter" to select autodrive speed limits 243 | function speedLimiter(menu) 244 | 245 | -- variables 246 | local playerPed = PlayerPedId() 247 | local submenu = _menuPool:AddSubMenu(menu, "~y~Speed Limit", "-- Open Speed Limit Submenu --") 248 | local smiPostedSpeed = NativeUI.CreateItem("Posted Speed Limit", "") 249 | local smiManualSpeed = NativeUI.CreateItem("Manual Speed Limit", "") 250 | local smiResetSpeed = NativeUI.CreateItem("Reset Speed Limit", "") 251 | 252 | local eventSpeed = EventsTable.Speed.name 253 | -- Driving Style Submenu item 1 Posted Speed Limit 254 | smiPostedSpeed.Activated = function(sender, item) 255 | if item == smiPostedSpeed then 256 | PostedLimits = true 257 | TriggerEvent(eventSpeed, SpeedTable.Args.PostedLimits.id) 258 | end end 259 | 260 | -- Driving Style Submenu item 2 Manul Speed Limit 261 | smiManualSpeed.Activated = function(sender, item) 262 | if item == smiManualSpeed then 263 | PostedLimits = false 264 | local manualSpeed = GetUserInput("Speed Limit", "", 10) 265 | ChosenSpeed = manualSpeed 266 | if IsAutoDriveEnabled then 267 | SetDriveTaskCruiseSpeed(playerPed, ChosenSpeed/SpeedUnits) 268 | end 269 | TimedOSD() 270 | Subtitle("Manual Speed: ~y~" .. manualSpeed, 1000) 271 | end end 272 | 273 | -- Driving Style Submenu item 3 Reset Speed Limit 274 | smiResetSpeed.Activated = function(sender, item) 275 | if item == smiResetSpeed then 276 | TriggerEvent(eventSpeed, SpeedTable.Args.ResetSpeed.id) 277 | end end 278 | 279 | submenu:AddItem(smiPostedSpeed) 280 | submenu:AddItem(smiManualSpeed) 281 | submenu:AddItem(smiResetSpeed) 282 | end 283 | 284 | --*********************-- Settings Events --*********************-- 285 | 286 | function OSDToggleSettings(menu) 287 | local submenu = _menuPool:AddSubMenu(menu, "~y~Settings", "-- Open Settings Submenu --") 288 | local timedOsd = NativeUI.CreateItem("OSD Timed", "-- Toggle OSD Timed on/off --") 289 | local toggleOsd = NativeUI.CreateItem("OSD Toggle", "-- Toggle OSD Default on/off --") 290 | local toggleSpeedUnits = NativeUI.CreateItem("Speed Units Toggle", "-- Toggle MPH/KMH --") 291 | local driverCreation = NativeUI.CreateItem("Driver Creation", "-- Toggle Drivers --") 292 | local driverForced = NativeUI.CreateItem("Driver Forced", "-- Force Drivers --") 293 | local driverVisibility = NativeUI.CreateItem("Driver Visible", "-- Toggle Visiblity --") 294 | local eventSettings = EventsTable.Settings.name 295 | toggleOsd.Activated = function(sender, item) 296 | if item == toggleOsd then 297 | TriggerEvent(eventSettings, SettingsTable.Args.ToggleOsd.id) 298 | end end 299 | timedOsd.Activated = function(sender, item) 300 | if item == timedOsd then 301 | TriggerEvent(eventSettings, SettingsTable.Args.TimedOsd.id) 302 | end end 303 | toggleSpeedUnits.Activated = function(sender, item) 304 | if item == toggleSpeedUnits then 305 | TriggerEvent(eventSettings, SettingsTable.Args.SetSpeedUnits.id) 306 | end end 307 | driverCreation.Activated = function(sender, item) 308 | if item == driverCreation then 309 | TriggerEvent(eventSettings, SettingsTable.Args.DriverCreate.id) 310 | end end 311 | driverForced.Activated = function(sender, item) 312 | if item == driverForced then 313 | TriggerEvent(eventSettings, SettingsTable.Args.DriverForced.id) 314 | end end 315 | driverVisibility.Activated = function(sender, item) 316 | if item == driverVisibility then 317 | TriggerEvent(eventSettings, SettingsTable.Args.DriverVisible.id) 318 | end end 319 | 320 | submenu:AddItem(toggleOsd) 321 | submenu:AddItem(timedOsd) 322 | submenu:AddItem(toggleSpeedUnits) 323 | submenu:AddItem(driverCreation) 324 | submenu:AddItem(driverForced) 325 | submenu:AddItem(driverVisibility) 326 | end 327 | 328 | function OSDToggle(menu) 329 | local toggleOSD = NativeUI.CreateItem("OSD Toggle", "-- Toggle OSD on/off --") 330 | toggleOSD.Activated = function(sender, item) 331 | if item == toggleOSD then 332 | TriggerEvent(EventsTable.Settings.name, SettingsTable.Args.OSD.id) 333 | end end 334 | menu:AddItem(toggleOSD) 335 | end 336 | 337 | RegisterNetEvent('ta-autodrive:nativeui') 338 | AddEventHandler('ta-autodrive:nativeui', function() 339 | if ADDefaults.UseNativeUI then 340 | -- print("^6############################################################################ NativeUI Menu allowed") 341 | 342 | if ADDefaults.UseQBCore then 343 | -- print("^6############################################################################ NativeUI Menu allowed") 344 | if Config.RequireParts then 345 | if IsPedInAnyVehicle(PlayerPedId(), false) then 346 | if not IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_kit) then 347 | -- print("ad_kit not installed") 348 | Subtitle("Autodrive ~r~Not Installed", 3000) 349 | return 350 | end 351 | end 352 | end 353 | -- Usage whitelisting 354 | if not WhitelistedJobsUsage(PlayerPedId()) then 355 | -- print("Job now allowed to use autodrive") 356 | Subtitle("Autodrive ~r~Not Allowed", 3000) 357 | return 358 | end 359 | -- is allowed to use 360 | if not IsAllowedToUse then 361 | print("Not Allowed to use", EventsTable.Destination.name) 362 | Subtitle("Autodrive ~r~Not Allowed", 3000) 363 | 364 | return 365 | end 366 | -- part requirements 367 | if Config.RequirePartUpgrades then 368 | -- destinations part requirement 369 | if not IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_destinations) then 370 | -- print("ad_dest not installed", IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_destinations)) 371 | Subtitle("Autodrive Destinations ~r~Not Installed", 3000) 372 | -- return 373 | else 374 | ThirdItem(mainMenu) 375 | end 376 | -- styles part requirement 377 | if not IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_styles) then 378 | -- print("ad_dest not installed", IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_styles)) 379 | Subtitle("Autodrive Styles ~r~Not Installed", 3000) 380 | -- return 381 | else 382 | SecondItem(mainMenu) 383 | end 384 | -- speed part requirement 385 | if not IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_styles) then 386 | -- print("ad_dest not installed", IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_styles)) 387 | Subtitle("Autodrive Speed ~r~Not Installed", 3000) 388 | -- return 389 | else 390 | speedLimiter(mainMenu) 391 | end 392 | else 393 | FirstItem(mainMenu) 394 | SecondItem(mainMenu) 395 | ThirdItem(mainMenu) 396 | speedLimiter(mainMenu) 397 | OSDToggleSettings(mainMenu) 398 | OSDToggle(mainMenu) 399 | -- _menuPool:RefreshIndex() 400 | -- mainMenu:Visible(not mainMenu:Visible()) 401 | end 402 | else 403 | FirstItem(mainMenu) 404 | SecondItem(mainMenu) 405 | ThirdItem(mainMenu) 406 | speedLimiter(mainMenu) 407 | OSDToggleSettings(mainMenu) 408 | OSDToggle(mainMenu) 409 | end 410 | _menuPool:RefreshIndex() 411 | mainMenu:Visible(not mainMenu:Visible()) 412 | end 413 | -- print("^6############################################################################ NativeUI Menu allowed") 414 | -- FirstItem(mainMenu) 415 | -- SecondItem(mainMenu) 416 | -- ThirdItem(mainMenu) 417 | -- speedLimiter(mainMenu) 418 | -- OSDToggleSettings(mainMenu) 419 | -- OSDToggle(mainMenu) 420 | -- _menuPool:RefreshIndex() 421 | -- mainMenu:Visible(not mainMenu:Visible()) 422 | end) 423 | -- activate/display NativeUI menu 424 | if ADDefaults.UseNativeUI then 425 | Citizen.CreateThread(function() 426 | while true do 427 | Citizen.Wait(0) 428 | _menuPool:ProcessMenus() 429 | --[[ The "e" button will activate the menu ]] 430 | if IsControlPressed(1, 21) and IsControlJustPressed(1, 214) then -- left shift 21 and ] 40 431 | TriggerEvent('ta-autodrive:nativeui') 432 | 433 | -- mainMenu:Visible(not mainMenu:Visible()) 434 | end 435 | end 436 | end) 437 | end 438 | 439 | 440 | 441 | 442 | 443 | -------------------------------------------------------------------------------- /shared/tables.lua: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------------------------------------------------------------------- 2 | ----------------------------------------------------------------------------------------------------------------------------------------- 3 | ----------------------------------------------------------------------------------------------------------- Tables ---------------------- 4 | ----------------------------------------------------------------------------------------------------------------------------------------- 5 | ----------------------------------------------------------------------------------------------------------------------------------------- 6 | AutodriveTables ={} 7 | DestTable = { 8 | Info = { id = 'destination', title = 'Destinations', icon = 'map-location-dot', txt = 'Where do you want to go?', }, 9 | Toggle = { 10 | Start = { id = 'start', title = 'Toggle Autodrive', icon = 'paper-plane', txt = 'Just Go'}, 11 | Stop = { id = 'stop', title = 'Stop Autodrive', icon = 'paper-plane', txt = 'Just Stop'}, 12 | }, 13 | Args = { 14 | Freeroam = { id = "freeroam", title = "Freeroam", icon = 'helmet-safety', }, 15 | Waypoint = { id = "waypoint", title = "Waypoint", icon = 'helmet-safety', }, 16 | Fuel = { id = "fuel", title = "Fuel", icon = 'helmet-safety', }, 17 | Blip = { id = "blip", title = "Blip", icon = 'helmet-safety', txt = "Pick a BLIP any BLIP",}, 18 | Tag = { id = "tag", title = "Tag Vehicle", icon = 'helmet-safety', }, 19 | Follow = { id = "follow", title = "Follow", icon = 'helmet-safety', }, 20 | Postal = { id = "postal", title = "Postal", icon = 'helmet-safety', }, 21 | }, 22 | } 23 | StylesTable = { 24 | Info = { id = 'styles', title = 'Driving Styles', icon = 'car-burst', txt = "Don't get too crazy",}, 25 | Args = { 26 | Safe = { id = "Safe", title = "Safe", icon = 'helmet-safety', code = 411 }, 27 | Code1 = { id = "Code1", title = "Code 1", icon = 'circle-exclamation', code = 283 }, 28 | Code3 = { id = "Code3", title = "Code 3", icon = 'triangle-exclamation', code = 787007 }, 29 | Aggressive = { id = "Aggressive", title = "Aggressive", icon = 'gauge-high', code = 318 }, 30 | Wreckless = { id = "Wreckless", title = "Wreckless", icon = 'car-burst', code = 786988 }, 31 | Follow = { id = "Follow", title = "Follow", icon = 'helmet-safety', code = 262719 }, 32 | Chase = { id = "Chase", title = "Chase", icon = 'helmet-safety', code = 262685 }, 33 | Custom = { id = "Custom", title = "Custom", icon = 'keyboard', code = 0 }, 34 | }, 35 | } 36 | SpeedTable = { 37 | Info = { id = 'speed', title = 'Speed Settings', icon = 'gauge-high', txt = "Take it easy.. ",}, 38 | Args = { 39 | PostedLimits = { id = "postedspeed", title = "Posted Limits", icon = 'helmet-safety', }, 40 | SetSpeed = { id = "setspeed", title = "Set Speed", icon = 'helmet-safety', }, 41 | ResetSpeed = { id = "resetspeed", title = "Reset Speed", icon = 'helmet-safety', }, 42 | }, 43 | } 44 | 45 | SettingsTable = { 46 | Info = { id = 'settings', title = 'Autodrive Settings', icon = 'wrench', txt = "Fine Tuning",}, 47 | Args = { 48 | OSD = { id = "osd", title = "OSD on/off", icon = 'car-on', txt = 'Heads Up!'}, 49 | ToggleOsd = { id = "toggleosd", title = "OSD Always on/off",icon = 'car-on', }, 50 | TimedOsd = { id = "timedosd", title = "Timed OSD", icon = 'clock', }, 51 | SetSpeedUnits = { id = "setspeedunits", title = "Toggle mph/kmh", icon = 'ruler', }, 52 | DriverCreate = { id = "drivercreate", title = "Driver Creation", icon = 'ruler', }, 53 | DriverForced = { id = "driverforced", title = "Driver Forced", icon = 'ruler', }, 54 | DriverVisible = { id = "drivervisible", title = "Driver Visiblity", icon = 'ruler', }, 55 | -- Start = { id = "start", title = "Toggle Autodrive", icon = 'paper-plane', }, 56 | -- Stop = { id = "stop", title = "Stop", icon = 'paper-plane', }, 57 | }, 58 | } 59 | 60 | QBMenuTable = { 61 | Info = { id = 'main', title = 'Autodrive Menu', icon = 'wrench', }, 62 | Args = { 63 | OSD = { id = "osd", title = "OSD on/off", icon = 'car-on', }, 64 | ToggleOsd = { id = "toggleosd", title = "Toggle OSD", icon = 'car-on', }, 65 | TimedOsd = { id = "timedosd", title = "Timed OSD", icon = 'clock', }, 66 | SetSpeedUnits = { id = "setspeedunits", title = "Toggle mph/kmh", icon = 'ruler', }, 67 | DriverCreation = { id = "drivercreate", title = "Driver Creation", icon = 'ruler', }, 68 | DriverForced = { id = "driverforced", title = "Driver Forced", icon = 'ruler', }, 69 | DriverVisible = { id = "drivervisible", title = "Driver Visiblity", icon = 'ruler', }, 70 | }, 71 | } 72 | 73 | 74 | EventsTable = { 75 | Start = 'ta-autodrive:client:startautodrive', 76 | Stop = 'ta-autodrive:client:stopautodrive', 77 | Destination = { 78 | name = 'ta-autodrive:client:destination', 79 | Args = DestTable.Args, 80 | }, 81 | Speed = { 82 | name = 'ta-autodrive:client:speed', 83 | Args = SpeedTable.Args, 84 | }, 85 | Style = { 86 | name = 'ta-autodrive:client:style', 87 | Args = StylesTable.Args, 88 | }, 89 | Settings = { 90 | name = 'ta-autodrive:client:settings', 91 | Args = SettingsTable.Args, 92 | }, 93 | QBMenu = { 94 | main = 'ta-autodrive:client:qbmenu:main', 95 | Submenu = { 96 | name = 'ta-autodrive:client:qbmenu:submenu', 97 | Args = { 98 | 'destinations', 99 | 'styles', 100 | 'speed', 101 | 'blips', 102 | 'postals' 103 | }, 104 | }, 105 | close = 'ta-autodrive:client:qbmenu:closemenu' 106 | } 107 | } 108 | 109 | ADItems = { 110 | ad_darts = "ad_darts", 111 | ad_destinations = "ad_destinations", 112 | ad_fob = "ad_fob", 113 | ad_kit = "ad_kit", 114 | ad_osd = "ad_osd", 115 | ad_speed = "ad_speed", 116 | ad_styles = "ad_styles", 117 | ad_tagger = "ad_tagger", 118 | 119 | } 120 | 121 | Values = { 122 | ["Safe"] = 411, 123 | ["Code1"] = 283, 124 | ["Aggressive"] = 318, 125 | ["Wreckless"] = 786988, 126 | ["Code3"] = 787007, 127 | ["Chase"] = 262685, 128 | ["Follow"] = 262719, 129 | ["Custom"] = ChosenDrivingStyle, 130 | } 131 | 132 | AreaNames = { 133 | AIRP = 'Los Santos International Airport', 134 | ALAMO = 'Alamo Sea', 135 | ALTA = 'Alta', 136 | ARMYB = 'Fort Zancudo', 137 | BANHAMC = 'Banham Canyon Dr', 138 | BANNING = 'Banning', 139 | BEACH = 'Vespucci Beach', 140 | BHAMCA = 'Banham Canyon', 141 | BRADP = 'Braddock Pass', 142 | BRADT = 'Braddock Tunnel', 143 | BURTON = 'Burton', 144 | CALAFB = 'Calafia Bridge', 145 | CANNY = 'Raton Canyon', 146 | CCREAK = 'Cassidy Creek', 147 | CHAMH = 'Chamberlain Hills', 148 | CHIL = 'Vinewood Hills', 149 | CHU = 'Chumash', 150 | CMSW = 'Chiliad Mountain State Wilderness', 151 | CYPRE = 'Cypress Flats', 152 | DAVIS = 'Davis', 153 | DELBE = 'Del Perro Beach', 154 | DELPE = 'Del Perro', 155 | DELSOL = 'La Puerta', 156 | DESRT = 'Grand Senora Desert', 157 | DOWNT = 'Downtown', 158 | DTVINE = 'Downtown Vinewood', 159 | EAST_V = 'East Vinewood', 160 | EBURO = 'El Burro Heights', 161 | ELGORL = 'El Gordo Lighthouse', 162 | ELYSIAN = 'Elysian Island', 163 | GALFISH = 'Galilee', 164 | GOLF = 'GWC and Golfing Society', 165 | GRAPES = 'Grapeseed', 166 | GREATC = 'Great Chaparral', 167 | HARMO = 'Harmony', 168 | HAWICK = 'Hawick', 169 | HORS = 'Vinewood Racetrack', 170 | HUMLAB = 'Humane Labs and Research', 171 | JAIL = 'Bolingbroke Penitentiary', 172 | KOREAT = 'Little Seoul', 173 | LACT = 'Land Act Reservoir', 174 | LAGO = 'Lago Zancudo', 175 | LDAM = 'Land Act Dam', 176 | LEGSQU = 'Legion Square', 177 | LMESA = 'La Mesa', 178 | LOSPUER = 'La Puerta', 179 | MIRR = 'Mirror Park', 180 | MORN = 'Morningwood', 181 | MOVIE = 'Richards Majestic', 182 | MTCHIL = 'Mount Chiliad', 183 | MTGORDO = 'Mount Gordo', 184 | MTJOSE = 'Mount Josiah', 185 | MURRI = 'Murrieta Heights', 186 | NCHU = 'North Chumash', 187 | NOOSE = 'N.O.O.S.E', 188 | OCEANA = 'Pacific Ocean', 189 | PALCOV = 'Paleto Cove', 190 | PALETO = 'Paleto Bay', 191 | PALFOR = 'Paleto Forest', 192 | PALHIGH = 'Palomino Highlands', 193 | PALMPOW = 'Palmer-Taylor Power Station', 194 | PBLUFF = 'Pacific Bluffs', 195 | PBOX = 'Pillbox Hill', 196 | PROCOB = 'Procopio Beach', 197 | RANCHO = 'Rancho', 198 | RGLEN = 'Richman Glen', 199 | RICHM = 'Richman', 200 | ROCKF = 'Rockford Hills', 201 | RTRAK = 'Redwood Lights Track', 202 | SANAND = 'San Andreas', 203 | SANCHIA = 'San Chianski Mountain Range', 204 | SANDY = 'Sandy Shores', 205 | SKID = 'Mission Row', 206 | SLAB = 'Stab City', 207 | STAD = 'Maze Bank Arena', 208 | STRAW = 'Strawberry', 209 | TATAMO = 'Tataviam Mountains', 210 | TERMINA = 'Terminal', 211 | TEXTI = 'Textile City', 212 | TONGVAH = 'Tongva Hills', 213 | TONGVAV = 'Tongva Valley', 214 | VCANA = 'Vespucci Canals', 215 | VESP = 'Vespucci', 216 | VINE = 'Vinewood', 217 | WINDF = 'Ron Alternates Wind Farm', 218 | WVINE = 'West Vinewood', 219 | ZANCUDO = 'Zancudo River', 220 | ZP_ORT = 'Port of South Los Santos', 221 | ZQ_UAR = 'Davis Quartz', 222 | PROL = 'Prologue / North Yankton', 223 | ISHeist = 'Cayo Perico Island', 224 | } 225 | 226 | local speedLimits = {} 227 | Street = {} 228 | 229 | if ADDefaults.UseMPH then 230 | speedLimits = { 231 | s0 = 20.0, 232 | s1 = 20.0, 233 | s2 = 25.0, 234 | s3 = 30.0, 235 | s4 = 35.0, 236 | s5 = 40.0, 237 | s6 = 45.0, 238 | s7 = 50.0, 239 | s8 = 65.0, 240 | s9 = 70.0, 241 | } 242 | else 243 | speedLimits = { 244 | s0 = 32.0, 245 | s1 = 32.0, 246 | s2 = 40.0, 247 | s3 = 48.0, 248 | s4 = 56.0, 249 | s5 = 64.0, 250 | s6 = 72.0, 251 | s7 = 80.0, 252 | s8 = 104.0, 253 | s9 = 112.0, 254 | } 255 | end 256 | 257 | Street.Speed = { 258 | ["Abattoir Ave"] = speedLimits.s3, 259 | ["Abe Milton Pkwy"] = speedLimits.s3, 260 | ["Ace Jones Dr"] = speedLimits.s3, 261 | ["Adam's Apple Blvd"] = speedLimits.s4, 262 | ["Aguja St"] = speedLimits.s1, 263 | ["Algonquin Blvd"] = speedLimits.s3, 264 | ["Alhambra Dr"] = speedLimits.s3, 265 | ["Alta Pl"] = speedLimits.s2, 266 | ["Alta St"] = speedLimits.s4, 267 | ["Amarillo Vista"] = speedLimits.s1, 268 | ["Amarillo Way"] = speedLimits.s3, 269 | ["Americano Way"] = speedLimits.s1, 270 | ["Armadillo Ave"] = speedLimits.s3, 271 | ["Atlee St"] = speedLimits.s2, 272 | ["Autopia Pkwy"] = speedLimits.s3, 273 | ["Banham Canyon Dr"] = speedLimits.s4, 274 | ["Barbareno Rd"] = speedLimits.s2, 275 | ["Bay City Ave"] = speedLimits.s2, 276 | ["Bay City Incline"] = speedLimits.s4, 277 | ["Baytree Canyon Rd"] = speedLimits.s4, 278 | ["Boulevard Del Perro"] = speedLimits.s3, 279 | ["Bridge St"] = speedLimits.s3, 280 | ["Brouge Ave"] = speedLimits.s2, 281 | ["Buccaneer Way"] = speedLimits.s6, 282 | ["Buen Vino Rd"] = speedLimits.s4, 283 | ["Caesars Place"] = speedLimits.s1, 284 | ["Calafia Rd"] = speedLimits.s2, 285 | ["Calais Ave"] = speedLimits.s3, 286 | ["Capital Blvd"] = speedLimits.s2, 287 | ["Carcer Way"] = speedLimits.s4, 288 | ["Carson Ave"] = speedLimits.s3, 289 | ["Cascabel Ave"] = speedLimits.s2, 290 | ["Cassidy Trail"] = speedLimits.s1, 291 | ["Cat-Claw Ave"] = speedLimits.s3, 292 | ["Catfish View"] = speedLimits.s3, 293 | ["Cavalry Blvd"] = speedLimits.s3, 294 | ["Chianski Passage"] = speedLimits.s2, 295 | ["Cholla Rd"] = speedLimits.s3, 296 | ["Cholla Springs Ave"] = speedLimits.s3, 297 | ["Chum St"] = speedLimits.s4, 298 | ["Chupacabra St"] = speedLimits.s2, 299 | ["Clinton Ave"] = speedLimits.s3, 300 | ["Cockingend Dr"] = speedLimits.s3, 301 | ["Conquistador St"] = speedLimits.s1, 302 | ["Cortes St"] = speedLimits.s1, 303 | ["Cougar Ave"] = speedLimits.s2, 304 | ["Covenant Ave"] = speedLimits.s2, 305 | ["Cox Way"] = speedLimits.s3, 306 | ["Crusade Rd"] = speedLimits.s2, 307 | ["Davis Ave"] = speedLimits.s4, 308 | ["Decker St"] = speedLimits.s3, 309 | ["Del Perro Fwy"] = speedLimits.s8, 310 | ["Didion Dr"] = speedLimits.s3, 311 | ["Dorset Dr"] = speedLimits.s4, 312 | ["Duluoz Ave"] = speedLimits.s3, 313 | ["Dunstable Dr"] = speedLimits.s3, 314 | ["Dunstable Ln"] = speedLimits.s3, 315 | ["Dutch London St"] = speedLimits.s4, 316 | ["East Galileo Ave"] = speedLimits.s3, 317 | ["East Joshua Road"] = speedLimits.s6, 318 | ["East Mirror Dr"] = speedLimits.s3, 319 | ["Eastbourne Way"] = speedLimits.s2, 320 | ["Eclipse Blvd"] = speedLimits.s3, 321 | ["Edwood Way"] = speedLimits.s1, 322 | ["El Burro Blvd"] = speedLimits.s3, 323 | ["El Rancho Blvd"] = speedLimits.s4, 324 | ["Elgin Ave"] = speedLimits.s4, 325 | ["Elysian Fields Fwy"] = speedLimits.s6, 326 | ["Equality Way"] = speedLimits.s2, 327 | ["Exceptionalists Way"] = speedLimits.s3, 328 | ["Fenwell Pl"] = speedLimits.s3, 329 | ["Fort Zancudo Approach Rd"] = speedLimits.s1, 330 | ["Forum Dr"] = speedLimits.s3, 331 | ["Fudge Ln"] = speedLimits.s1, 332 | ["Galileo Park"] = speedLimits.s3, 333 | ["Galileo Rd"] = speedLimits.s4, 334 | ["Gentry Lane"] = speedLimits.s2, 335 | ["Ginger St"] = speedLimits.s2, 336 | ["Glory Way"] = speedLimits.s3, 337 | ["Goma St"] = speedLimits.s1, 338 | ["Grapeseed Ave"] = speedLimits.s3, 339 | ["Grapeseed Main St"] = speedLimits.s3, 340 | ["Great Ocean Hwy"] = speedLimits.s8, 341 | ["Greenwich Pkwy"] = speedLimits.s3, 342 | ["Greenwich Pl"] = speedLimits.s3, 343 | ["Greenwich Way"] = speedLimits.s3, 344 | ["Grove St"] = speedLimits.s2, 345 | ["Hanger Way"] = speedLimits.s2, 346 | ["Hangman Ave"] = speedLimits.s3, 347 | ["Hardy Way"] = speedLimits.s3, 348 | ["Hawick Ave"] = speedLimits.s3, 349 | ["Heritage Way"] = speedLimits.s3, 350 | ["Hillcrest Ave"] = speedLimits.s3, 351 | ["Hillcrest Ridge Access Rd"] = speedLimits.s3, 352 | ["Imagination Ct"] = speedLimits.s1, 353 | ["Ineseno Road"] = speedLimits.s2, 354 | ["Innocence Blvd"] = speedLimits.s4, 355 | ["Integrity Way"] = speedLimits.s2, 356 | ["Invention Ct"] = speedLimits.s1, 357 | ["Jamestown St"] = speedLimits.s2, 358 | ["Joad Ln"] = speedLimits.s3, 359 | ["Joshua Rd"] = speedLimits.s6, 360 | ["Kimble Hill Dr"] = speedLimits.s3, 361 | ["Kortz Dr"] = speedLimits.s2, 362 | ["La Puerta Fwy"] = speedLimits.s8, 363 | ["Labor Pl"] = speedLimits.s3, 364 | ["Laguna Pl"] = speedLimits.s2, 365 | ["Lake Vinewood Dr"] = speedLimits.s3, 366 | ["Lake Vinewood Est"] = speedLimits.s3, 367 | ["Las Lagunas Blvd"] = speedLimits.s4, 368 | ["Lesbos Ln"] = speedLimits.s3, 369 | ["Liberty St"] = speedLimits.s2, 370 | ["Lindsay Circus"] = speedLimits.s2, 371 | ["Little Bighorn Ave"] = speedLimits.s3, 372 | ["Lolita Ave"] = speedLimits.s3, 373 | ["Los Santos Freeway"] = speedLimits.s8, 374 | ["Low Power St"] = speedLimits.s3, 375 | ["Macdonald St"] = speedLimits.s3, 376 | ["Mad Wayne Thunder Dr"] = speedLimits.s3, 377 | ["Magellan Ave"] = speedLimits.s1, 378 | ["Marathon Ave"] = speedLimits.s2, 379 | ["Marina Dr"] = speedLimits.s3, 380 | ["Marlowe Dr"] = speedLimits.s4, 381 | ["Melanoma St"] = speedLimits.s1, 382 | ["Meringue Ln"] = speedLimits.s3, 383 | ["Meteor St"] = speedLimits.s2, 384 | ["Milton Rd"] = speedLimits.s3, 385 | ["Miriam Turner Overpass"] = speedLimits.s2, 386 | ["Mirror Park Blvd"] = speedLimits.s3, 387 | ["Mirror Pl"] = speedLimits.s3, 388 | ["Morningwood Blvd"] = speedLimits.s3, 389 | ["Mountain View Dr"] = speedLimits.s3, 390 | ["Movie Star Way"] = speedLimits.s3, 391 | ["Mt Haan Rd"] = speedLimits.s4, 392 | ["Mt Vinewood Dr"] = speedLimits.s4, 393 | ["Mutiny Rd"] = speedLimits.s3, 394 | ["New Empire Way"] = speedLimits.s2, 395 | ["Nikola Ave"] = speedLimits.s3, 396 | ["Nikola Pl"] = speedLimits.s1, 397 | ["Niland Ave"] = speedLimits.s3, 398 | ["Normandy Dr"] = speedLimits.s3, 399 | ["North Calafia Way"] = speedLimits.s2, 400 | ["North Conker Ave"] = speedLimits.s3, 401 | ["North Rockford Dr"] = speedLimits.s3, 402 | ["North Sheldon Ave"] = speedLimits.s3, 403 | ["Nowhere Rd"] = speedLimits.s1, 404 | ["O'Neil Way"] = speedLimits.s1, 405 | ["Occupation Ave"] = speedLimits.s3, 406 | ["Olympic Fwy"] = speedLimits.s8, 407 | ["Orchardville Ave"] = speedLimits.s2, 408 | ["Paleto Blvd"] = speedLimits.s3, 409 | ["Palomino Ave"] = speedLimits.s3, 410 | ["Palomino Fwy"] = speedLimits.s8, 411 | ["Panorama Dr"] = speedLimits.s4, 412 | ["Perth St"] = speedLimits.s1, 413 | ["Picture Perfect Drive"] = speedLimits.s3, 414 | ["Plaice Pl"] = speedLimits.s2, 415 | ["Playa Vista"] = speedLimits.s2, 416 | ["Popular St"] = speedLimits.s4, 417 | ["Portola Dr"] = speedLimits.s2, 418 | ["Power St"] = speedLimits.s4, 419 | ["Procopio Dr"] = speedLimits.s3, 420 | ["Procopio Promenade"] = speedLimits.s1, 421 | ["Prosperity St"] = speedLimits.s2, 422 | ["Pyrite Ave"] = speedLimits.s2, 423 | ["Red Desert Ave"] = speedLimits.s2, 424 | ["Richman St"] = speedLimits.s3, 425 | ["Rockford Dr"] = speedLimits.s3, 426 | ["Route 68 Approach"] = speedLimits.s7, 427 | ["Route 68"] = speedLimits.s7, 428 | ["Roy Lowenstein Blvd"] = speedLimits.s3, 429 | ["Rub St"] = speedLimits.s1, 430 | ["Runway1"] = speedLimits.s9, 431 | ["Sam Austin Dr"] = speedLimits.s1, 432 | ["San Andreas Ave"] = speedLimits.s4, 433 | ["San Vitus Blvd"] = speedLimits.s4, 434 | ["Sandcastle Way"] = speedLimits.s2, 435 | ["Seaview Rd"] = speedLimits.s3, 436 | ["Senora Fwy"] = speedLimits.s8, 437 | ["Senora Rd"] = speedLimits.s4, 438 | ["Senora Way"] = speedLimits.s4, 439 | ["Shank St"] = speedLimits.s1, 440 | ["Signal St"] = speedLimits.s2, 441 | ["Sinner St"] = speedLimits.s2, 442 | ["Sinners Passage"] = speedLimits.s2, 443 | ["Smoke Tree Rd"] = speedLimits.s3, 444 | ["South Arsenal St"] = speedLimits.s3, 445 | ["South Boulevard Del Perro"] = speedLimits.s3, 446 | ["South Mo Milton Dr"] = speedLimits.s3, 447 | ["South Rockford Dr"] = speedLimits.s3, 448 | ["South Shambles St"] = speedLimits.s2, 449 | ["Spanish Ave"] = speedLimits.s2, 450 | ["Strawberry Ave"] = speedLimits.s4, 451 | ["Supply St"] = speedLimits.s2, 452 | ["Sustancia Rd"] = speedLimits.s6, 453 | ["Swiss St"] = speedLimits.s2, 454 | ["Tackle St"] = speedLimits.s1, 455 | ["Tongva Dr"] = speedLimits.s4, 456 | ["Tower Way"] = speedLimits.s3, 457 | ["Tug St"] = speedLimits.s1, 458 | ["Union Rd"] = speedLimits.s4, 459 | ["Utopia Gardens"] = speedLimits.s1, 460 | ["Vespucci Blvd"] = speedLimits.s4, 461 | ["Vinewood Blvd"] = speedLimits.s4, 462 | ["Vinewood Park Dr"] = speedLimits.s3, 463 | ["Vitus St"] = speedLimits.s1, 464 | ["Voodoo Place"] = speedLimits.s2, 465 | ["West Eclipse Blvd"] = speedLimits.s3, 466 | ["West Galileo Ave"] = speedLimits.s3, 467 | ["West Mirror Drive"] = speedLimits.s3, 468 | ["Whispymound Dr"] = speedLimits.s3, 469 | ["Wild Oats Dr"] = speedLimits.s3, 470 | ["Zancudo Ave"] = speedLimits.s3, 471 | ["Zancudo Barranca"] = speedLimits.s4, 472 | ["Zancudo Grande Valley"] = speedLimits.s4, 473 | ["Zancudo Rd"] = speedLimits.s3, 474 | } -------------------------------------------------------------------------------- /client/events.lua: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------------------------------------------------------------------- 2 | ----------------------------------------------------------------------------------------------------------------------------------------- 3 | ----------------------------------------------------------------------------------------------------------- Events ---------------------- 4 | ----------------------------------------------------------------------------------------------------------------------------------------- 5 | ----------------------------------------------------------------------------------------------------------------------------------------- 6 | if ADDefaults.UseQBCore then 7 | -- print("Is using QBCore?", ADDefaults.UseQBCore) 8 | -- local isAllowed = exports['ta-autodrive']:IsAllowed() 9 | -- print(isAllowed) 10 | -- if not IsAllowed then return end 11 | end 12 | 13 | -- ##########################################-------------------------------------- Start Event -- Modular 14 | 15 | RegisterNetEvent(EventsTable.Start) 16 | AddEventHandler(EventsTable.Start, function() 17 | if not IsAutoDriveEnabled then 18 | TriggerEvent(EventsTable.Destination.name, GameDestination) 19 | else 20 | TriggerEvent(EventsTable.Stop) 21 | end 22 | end) 23 | 24 | -- ##########################################-------------------------------------- Stop Event -- Modular 25 | 26 | 27 | 28 | -- Set ped to driver ped or player ped 29 | ---@return integer ped playerPed or DriverPed 30 | function SetDriverPed() 31 | local playerPed = PlayerPedId() 32 | local playerVeh = GetVehiclePedIsIn(playerPed, false) 33 | local ped = nil 34 | if DoesEntityExist(DriverPed) and not IsPedAPlayer(GetPedInVehicleSeat(playerVeh, -1)) then 35 | ped = DriverPed 36 | -- print("ped", ped, "DriverPed", DriverPed, "PlayerPedId()", PlayerPedId()) 37 | else 38 | ped = playerPed 39 | end 40 | return ped 41 | end 42 | 43 | RegisterNetEvent(EventsTable.Stop) 44 | AddEventHandler(EventsTable.Stop, function() 45 | -- print("^2EventsTable.Stop") 46 | local playerPed = PlayerPedId() 47 | local playerVeh = GetVehiclePedIsIn(playerPed, false) 48 | 49 | if DoesEntityExist(DriverPed) and DriverPed ~= PlayerPedId() then DeleteEntity(DriverPed) end 50 | 51 | if GetPedInVehicleSeat(playerVeh, -1) ~= PlayerPedId() then 52 | playerPed = DriverPed 53 | end 54 | if true then -- brake or s key 72 55 | SetBlipRoute(GetClosestBlipOfType(ChosenBlip), false) 56 | SetBlipRoute(GetClosestBlipOfType(8), false) 57 | DoesBlipExist(GetFirstBlipInfoId(8)) 58 | IsAutoDriveEnabled = false 59 | PostedLimits = false 60 | -- NetworkConcealEntity(GetPedInVehicleSeat(playerVeh, -1), true) 61 | -- ClearPedTasks(GetPedInVehicleSeat(playerVeh, -1)) 62 | ClearPedTasks(GetPedInVehicleSeat(playerVeh, -1)) 63 | if DoesEntityExist(GetPedInVehicleSeat(playerVeh, -1)) and GetPedInVehicleSeat(playerVeh, -1) ~= PlayerPedId() and not IsPedAPlayer(GetPedInVehicleSeat(playerVeh, -1)) then 64 | -- print("^3DriverPed Exists", GetPedInVehicleSeat(playerVeh, -1)) 65 | DeleteEntity(GetPedInVehicleSeat(playerVeh, -1)) 66 | end 67 | 68 | isAutodriveSubtitle() 69 | TimedOSD() 70 | end 71 | if toggleDriverForced then 72 | Citizen.Wait(100) 73 | TaskEnterVehicle(PlayerPedId(), playerVeh, -1, -1, 2.0, 16, 0) 74 | end 75 | end) 76 | 77 | -- ##########################################-------------------------------------- Destination Events -- Modular 78 | 79 | -- function DriverVisibility(ped) end 80 | local function CreateDriverPed() 81 | if DoesEntityExist(DriverPed) and not IsPedAPlayer(DriverPed) then DeleteEntity(DriverPed) end 82 | if IsPedInAnyVehicle(playerPed) and ADDefaults.ToggleDriverCreation then -- is ped in vehicle then do 83 | if GetPedInVehicleSeat(playerVeh, -1) ~= PlayerPedId() then -- is ped not driver then do 84 | if toggleDriverCreation then -- if create drivers and player not driver 85 | if not HasModelLoaded(pedModel) then 86 | RequestModel(pedModel) 87 | while not HasModelLoaded(pedModel) do 88 | Wait(100) 89 | end 90 | end 91 | local entityDriverPed = CreatePedInsideVehicle(playerVeh, 26, GetHashKey(pedModel), -1, true, false) 92 | DriverPed = entityDriverPed 93 | SetEntityAsMissionEntity(DriverPed, true, true) 94 | else 95 | Subtitle("Not in driver seat", 3000) 96 | return 97 | end 98 | else -- if ped is driver then do 99 | if toggleDriverCreation then -- if create drivers but player is driver 100 | if GetPedInVehicleSeat(playerVeh, -1) == PlayerPedId() then -- is player in driver seat 101 | if toggleDriverForced then -- if driver forced then move player to passenger seat 102 | TaskEnterVehicle(playerPed, playerVeh, -1, 0, 2.0, 16, 0) 103 | if not HasModelLoaded(pedModel) then 104 | RequestModel(pedModel) 105 | while not HasModelLoaded(pedModel) do 106 | Wait(100) 107 | end 108 | end 109 | Citizen.Wait(500) 110 | local entityDriverPed = CreatePedInsideVehicle(playerVeh, 26, GetHashKey(pedModel), -1, true, false) 111 | DriverPed = entityDriverPed 112 | SetEntityAsMissionEntity(DriverPed, true, true) 113 | -- if not driver forced and ped is driver then do nothing 114 | end 115 | end 116 | end 117 | end 118 | end 119 | end 120 | 121 | RegisterNetEvent(EventsTable.Destination.name) 122 | AddEventHandler(EventsTable.Destination.name, function(destination, blipNum) 123 | print("Event Triggered", destination) 124 | ---- 125 | ---- Permissions 126 | ---- 127 | if ADDefaults.UseQBCore then 128 | 129 | if Config.RequireParts then 130 | if IsPedInAnyVehicle(PlayerPedId(), false) then 131 | if not IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_kit) then 132 | -- print("ad_kit not installed") 133 | Subtitle("Autodrive ~r~Not Installed", 3000) 134 | return 135 | end 136 | end 137 | end 138 | 139 | if not WhitelistedJobsUsage(PlayerPedId()) then 140 | -- print("Job now allowed to use autodrive") 141 | Subtitle("Autodrive ~r~Not Allowed", 3000) 142 | return 143 | end 144 | 145 | if Config.RequirePartUpgrades then 146 | if not IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_destinations) then 147 | -- print("ad_dest not installed", IsPartInstalled(GetVehiclePedIsIn(PlayerPedId(), false), ADItems.ad_destinations)) 148 | Subtitle("Autodrive Destinations ~r~Not Installed", 3000) 149 | return 150 | end 151 | end 152 | 153 | if not IsAllowedToUse then 154 | -- print("Not Allowed to use", EventsTable.Destination) 155 | Subtitle("~r~Not Allowed to use", 3000) 156 | return 157 | end 158 | end 159 | ---- 160 | ---- End Permissions 161 | ---- 162 | -- ##########################################-------------------------------------- 163 | ---- 164 | ---- Variables 165 | ---- 166 | SetBlipRoute(GetClosestBlipOfType(GetFirstBlipInfoId(8)), false) 167 | RemoveBlip(GetClosestBlipOfType(GetFirstBlipInfoId(8)), false) 168 | SetBlipRoute(GetClosestBlipOfType(ChosenBlip), false) 169 | if type(destination) == 'table' then destination = destination.id end -- code to handle qb-radialmenu triggers 170 | local playerPed = PlayerPedId() 171 | local playerVeh = GetVehiclePedIsIn(playerPed, false) 172 | local dest = destination or GameDestination--:lower() 173 | local blipSprite = ChosenBlip or destination or 60 174 | local blipName = nil 175 | local closestBlip = GetClosestBlipOfType(blipSprite) 176 | local numDest = nil 177 | local pedModel = DriverList[math.random(1, #DriverList)] 178 | local ped = nil 179 | ---- 180 | ---- Driver Creation 181 | ---- 182 | --------------------------------------------------------------------------------------------------------------------------- driver creation 183 | if DoesEntityExist(DriverPed) and not IsPedAPlayer(DriverPed) then DeleteEntity(DriverPed) end 184 | if IsPedInAnyVehicle(playerPed) and ADDefaults.ToggleDriverCreation then -- is ped in vehicle then do 185 | if GetPedInVehicleSeat(playerVeh, -1) ~= PlayerPedId() then -- is ped not driver then do 186 | if toggleDriverCreation then -- if create drivers and player not driver 187 | if not HasModelLoaded(pedModel) then 188 | RequestModel(pedModel) 189 | while not HasModelLoaded(pedModel) do 190 | Wait(100) 191 | end 192 | end 193 | local entityDriverPed = CreatePedInsideVehicle(playerVeh, 26, GetHashKey(pedModel), -1, true, false) 194 | DriverPed = entityDriverPed 195 | SetEntityAsMissionEntity(DriverPed, true, true) 196 | else 197 | Subtitle("Not in driver seat", 3000) 198 | return 199 | end 200 | else -- if ped is driver then do 201 | if toggleDriverCreation then -- if create drivers but player is driver 202 | if GetPedInVehicleSeat(playerVeh, -1) == PlayerPedId() then -- is player in driver seat 203 | if toggleDriverForced then -- if driver forced then move player to passenger seat 204 | TaskEnterVehicle(playerPed, playerVeh, -1, 0, 2.0, 16, 0) 205 | if not HasModelLoaded(pedModel) then 206 | RequestModel(pedModel) 207 | while not HasModelLoaded(pedModel) do 208 | Wait(100) 209 | end 210 | end 211 | Citizen.Wait(500) 212 | local entityDriverPed = CreatePedInsideVehicle(playerVeh, 26, GetHashKey(pedModel), -1, true, false) 213 | DriverPed = entityDriverPed 214 | SetEntityAsMissionEntity(DriverPed, true, true) 215 | end -- if not driver forced and ped is driver then do nothing 216 | end 217 | end 218 | end 219 | end -- End if ped not in vehicle do nothing 220 | if DoesEntityExist(DriverPed) then -- driver visibility 221 | if DriverPed ~= PlayerPedId() then 222 | if toggleDriverVisible then 223 | -- SetEntityVisible(DriverPed, true) 224 | else 225 | SetEntityVisible(DriverPed, false) 226 | end 227 | end 228 | end 229 | ped = SetDriverPed() 230 | ---- 231 | ---- Destinations 232 | ---- 233 | if tonumber(destination) ~= nil then -- check if blip# 234 | -- print("Destination(number) is not nil", destination, numDest) 235 | numDest = tonumber(destination) 236 | if numDest >= 1000 then 237 | GameDestination = 'postal' 238 | dest = 'postal' 239 | ChosenPostal = tonumber(destination) 240 | 241 | -- print(type(numDest), dest) 242 | --ChosenBlip = tonumber(destination) 243 | --blipSprite = ChosenBlip 244 | 245 | else 246 | GameDestination = 'blip' 247 | dest = 'blip' 248 | ChosenBlip = tonumber(destination) 249 | blipSprite = ChosenBlip 250 | 251 | end 252 | end 253 | 254 | local destFollow = dest == DestTable.Args.Follow.id 255 | local destTag = dest == DestTable.Args.Tag.id 256 | local destFreeroam = dest == DestTable.Args.Freeroam.id 257 | local destWaypoint = dest == "waypoint" or dest == 'fuel' or dest == 'blip' or dest == 'postal' 258 | 259 | IsAutoDriveEnabled = false 260 | if not IsAutoDriveEnabled and IsPedInAnyVehicle(PlayerPedId()) then 261 | IsAutoDriveEnabled = true 262 | if destTag then 263 | CreateTag() 264 | -- print("GetTaggedVehicle()", GetTaggedVehicle()) 265 | elseif destFollow then 266 | print("Dest == follow", dest) 267 | if IsVehicleTagged then 268 | 269 | ChosenDrivingStyleName = StylesTable.Args.Code1.title 270 | ChosenDrivingStyle = get_value_for_key(Values, ChosenDrivingStyleName) 271 | GameDestination = DestTable.Args.Follow.id 272 | DestinationEvents(DestTable.Args.Follow.title) 273 | TaskVehicleFollow(ped, playerVeh, TargetVeh, 150.0, ChosenDrivingStyle, 10) 274 | else 275 | -- print("^6Event Triggered: ^7ta-autodrive:client:destination:follow: no target vehicle") 276 | NotifyAutodrive("No vehicle Tagged", "error") 277 | dest = DestTable.Args.Freeroam.id 278 | end 279 | -- -- ##########################################-------------------------------------- Destination Events -- FreeRoam 280 | elseif destFreeroam then 281 | GameDestination = DestTable.Args.Freeroam.id 282 | DestinationEvents(DestTable.Args.Freeroam.title) 283 | TaskVehicleDriveWander(ped, playerVeh, ChosenSpeed/SpeedUnits, ChosenDrivingStyle) 284 | elseif destWaypoint then 285 | -- -- ##########################################-------------------------------------- Destination Events -- Waypoint 286 | if dest == DestTable.Args.Waypoint.id then 287 | if true then 288 | if DoesBlipExist(GetFirstBlipInfoId(8)) then 289 | local dx, dy, dz = table.unpack(GetBlipInfoIdCoord(GetFirstBlipInfoId(8))) 290 | TaskVehicleDriveToCoord(ped, playerVeh, dx, dy, dz, ChosenSpeed/SpeedUnits, 0, 291 | GetEntityModel(playerVeh), ChosenDrivingStyle, 50.0) 292 | GameDestination = DestTable.Args.Waypoint.id 293 | DestinationEvents(DestTable.Args.Waypoint.title) 294 | return 295 | else 296 | Subtitle("Please select a destination..", 3000) 297 | return 298 | end 299 | end 300 | -- -- ##########################################-------------------------------------- Destination Events -- Fuel 301 | elseif dest == DestTable.Args.Fuel.id then 302 | local coords = GetEntityCoords(ped) 303 | local closest = 1000 304 | local closestCoords = nil 305 | for _, gasStationCoords in pairs(ADDefaults.GasStations) do 306 | local dstcheck = Vdist(coords, gasStationCoords) 307 | if dstcheck < closest then 308 | closest = dstcheck 309 | closestCoords = gasStationCoords 310 | end 311 | end 312 | TaskVehicleDriveToCoord(ped, playerVeh, closestCoords.x, closestCoords.y, closestCoords.z, 313 | ChosenSpeed/SpeedUnits, 0, GetEntityModel(playerVeh), ChosenDrivingStyle, 15.0) 314 | GameDestination = DestTable.Args.Fuel.id 315 | DestinationEvents(DestTable.Args.Fuel.title) 316 | PrintSettings() 317 | -- -- ##########################################-------------------------------------- Destination Events -- Blip 318 | elseif dest == DestTable.Args.Blip.id then -- fire blips are radar_hot_property sprite 436 319 | if DoesBlipExist(GetClosestBlipOfType(blipSprite)) then 320 | closestBlip = GetClosestBlipOfType(blipSprite) 321 | local coords = GetBlipInfoIdCoord(closestBlip) 322 | TaskVehicleDriveToCoord(ped, playerVeh, coords.x, coords.y, coords.z, 323 | ChosenSpeed/SpeedUnits, 0, GetEntityModel(playerVeh), ChosenDrivingStyle, 50.0) 324 | for k, v in pairs(BlipDestination.BlipNames) do 325 | if v.sprite == blipSprite then 326 | blipName = v.title 327 | end 328 | end 329 | GameDestination = DestTable.Args.Blip.id 330 | DestinationEvents(tostring(blipName)) 331 | ChosenBlip = blipSprite 332 | SetBlipRoute(closestBlip, true) 333 | PrintSettings() 334 | else 335 | Subtitle("Blip doesn't exist", 3000) 336 | end 337 | -- -- ##########################################-------------------------------------- Destination Events -- Postal 338 | elseif dest == DestTable.Args.Postal.id and ADDefaults.UsePostals then 339 | print("Postal destination Event", dest, tonumber(destination)) 340 | if DoesBlipExist(GetFirstBlipInfoId(8)) then 341 | print("DoesBlipExist(GetFirstBlipInfoId(8))", DoesBlipExist(GetFirstBlipInfoId(8))) 342 | SetDriverAbility(ped, 1.0) 343 | local dx, dy, dz = table.unpack(GetBlipInfoIdCoord(GetFirstBlipInfoId(8))) 344 | local roadCoords, spawnPos, spawnHeading = GetClosestVehicleNodeWithHeading(dx, dy, dz, 0, 3, 0) 345 | TaskVehicleDriveToCoord(ped, playerVeh, spawnPos, ChosenSpeed/SpeedUnits, 0, 346 | GetEntityModel(playerVeh), ChosenDrivingStyle, 50.0) 347 | SetDriverAbility(ped, 1.0) 348 | PrintSettings() 349 | GameDestination = chosenPostal 350 | DestinationEvents(string.format("~b~Postal~b~%s", GameDestination)) 351 | print("^2############################################################################### Blip already exists") 352 | return 353 | end 354 | local locPostalCode = nil 355 | if tonumber(destination) ~= nil then 356 | print("EventsTable.Destination", "tonumber(destination) ~= nil", tonumber(destination)) 357 | if tonumber(destination) < 1000 or chosenPostal == nil then 358 | locPostalCode = GetUserInput("Postal Code", "", 10) 359 | else 360 | locPostalCode = tonumber(destination) 361 | end 362 | else 363 | locPostalCode = GetUserInput("Postal Code", "", 10) 364 | end 365 | local locPostalCodeNum = tonumber(locPostalCode) 366 | numDest = locPostalCodeNum 367 | chosenPostal = locPostalCodeNum 368 | ExecuteCommand("postal") 369 | ExecuteCommand(string.format("%s %s",dest,numDest)) 370 | print("Postal command", dest, numDest) 371 | if DoesBlipExist(GetFirstBlipInfoId(8)) then 372 | print("DoesBlipExist(GetFirstBlipInfoId(8))", DoesBlipExist(GetFirstBlipInfoId(8))) 373 | local dx, dy, dz = table.unpack(GetBlipInfoIdCoord(GetFirstBlipInfoId(8))) 374 | SetDriverAbility(ped, 1.0) 375 | local dx, dy, dz = table.unpack(GetBlipInfoIdCoord(GetFirstBlipInfoId(8))) 376 | local roadCoords, spawnPos, spawnHeading = GetClosestVehicleNodeWithHeading(dx, dy, dz, 0, 3, 0) 377 | TaskVehicleDriveToCoord(ped, playerVeh, spawnPos, ChosenSpeed/SpeedUnits, 0, 378 | GetEntityModel(playerVeh), ChosenDrivingStyle, 50.0) 379 | SetDriverAbility(ped, 1.0) 380 | PrintSettings() 381 | GameDestination = chosenPostal 382 | DestinationEvents(string.format("~b~Postal~b~%s", GameDestination)) 383 | print("^2############################################################################### Blip Now exists") 384 | else 385 | Subtitle("Postal doesn't exist", 3000) 386 | end 387 | end 388 | else 389 | -- print("Something went wrong in the autodrive destination events") 390 | IsAutoDriveEnabled = false 391 | end 392 | end 393 | end) 394 | 395 | -- ##########################################-------------------------------------- Style Events -- Modular 396 | 397 | RegisterNetEvent(EventsTable.Style.name) 398 | AddEventHandler(EventsTable.Style.name, function(dsName) 399 | local playerPed = PlayerPedId() 400 | local playerVeh = GetVehiclePedIsIn(playerPed, false) 401 | local ped = nil 402 | ped = SetDriverPed() 403 | -- print(ped) 404 | if type(dsName) == 'table' then dsName = dsName.id end -- code to handle qb-radialmenu triggers 405 | if dsName == StylesTable.Args.Code3.id then 406 | ChosenSpeed = 60.0 407 | if IsAutoDriveEnabled then 408 | SetDriveTaskCruiseSpeed(ped, ChosenSpeed/SpeedUnits) 409 | end 410 | DrivingStyleEvents(StylesTable.Args.Code3.title) 411 | elseif dsName == 'Custom' then 412 | local dsCustomStyle = GetUserInput("Custom Driving Style", "") 413 | Citizen.Wait(1000) 414 | ChosenDrivingStyle = dsCustomStyle 415 | ChosenDrivingStyleName = StylesTable.Args.Code3.title 416 | SetDriveTaskDrivingStyle(ped, ChosenDrivingStyle) 417 | TimedOSD() 418 | Subtitle("Driving Style: ~y~Custom", 1000) 419 | PrintSettings() 420 | else 421 | DrivingStyleEvents(dsName) 422 | -- print(ChosenDrivingStyle) 423 | end 424 | end) 425 | 426 | -- ##########################################-------------------------------------- Speed Events -- Modular 427 | 428 | RegisterNetEvent(EventsTable.Speed.name) 429 | AddEventHandler(EventsTable.Speed.name, function(dsSpeed) 430 | print("Event Triggered: Speed: dsSpeed", dsSpeed) 431 | local playerPed = PlayerPedId() 432 | local playerVeh = GetVehiclePedIsIn(playerPed, false) 433 | local ped = nil 434 | ped = SetDriverPed() 435 | PostedLimits = false 436 | 437 | if type(dsSpeed) == 'table' then dsSpeed = dsSpeed.id end -- code to handle qb-radialmenu triggers 438 | if dsSpeed == 'postedspeed' then 439 | Citizen.CreateThread(function() 440 | if IsPedInAnyVehicle(ped, false) then 441 | PostedLimits = true 442 | TimedOSD() 443 | -- if PostedLimits then 444 | while PostedLimits do 445 | Citizen.Wait(1000) 446 | local coords = GetEntityCoords(ped) 447 | local street = GetStreetNameFromHashKey(GetStreetNameAtCoord(coords.x, coords.y, coords.z)) 448 | local speed = Street.Speed[street] or 25 449 | ChosenSpeed = tonumber(speed) 450 | SetDriveTaskCruiseSpeed(ped, ChosenSpeed / SpeedUnits) 451 | -- print("event: posted speed: Street: ^6" .. street .. " ^7Speed: ^6" .. speed, 452 | -- "ChosenSpeed", 453 | -- ChosenSpeed / SpeedUnits, GetEntitySpeed(playerVeh) * SpeedUnits) 454 | end 455 | -- end 456 | end 457 | end) 458 | elseif dsSpeed == 'setspeed' then 459 | local manualSpeed = GetUserInput("Speed Limit", "", 10) 460 | ChosenSpeed = tonumber(manualSpeed) 461 | if IsAutoDriveEnabled then 462 | SetDriveTaskCruiseSpeed(ped, ChosenSpeed / SpeedUnits) 463 | end 464 | Subtitle("Manual Speed: ~y~" .. manualSpeed:tonumber(), 1000) 465 | elseif dsSpeed == 'resetspeed' then 466 | ChosenSpeed = tonumber(ADDefaults.DefaultDriveSpeed) 467 | if IsAutoDriveEnabled then 468 | SetDriveTaskCruiseSpeed(ped, ChosenSpeed / SpeedUnits) 469 | end 470 | Subtitle("Reset Speed: ~y~" .. ChosenSpeed, 1000) 471 | elseif dsSpeed == 'speedup' then 472 | local setSpeed = tonumber(ChosenSpeed + 5) 473 | if SpeedUnits == ADDefaults.MPH then 474 | if ChosenSpeed < 5 then 475 | setSpeed = tonumber(ChosenSpeed + 1) 476 | else 477 | setSpeed = tonumber(ChosenSpeed + 5) 478 | end 479 | else 480 | if ChosenSpeed < 2 then 481 | setSpeed = tonumber(ChosenSpeed + 1) 482 | else 483 | setSpeed = tonumber(ChosenSpeed + 2) 484 | end 485 | end 486 | IsPlayerInVehicle = IsPedInAnyVehicle(ped) 487 | ChosenSpeed = setSpeed 488 | if IsAutoDriveEnabled then 489 | SetDriveTaskCruiseSpeed(ped, ChosenSpeed / SpeedUnits) 490 | end 491 | Subtitle("Speed: ~b~" .. tostring(ChosenSpeed), 3000) 492 | elseif dsSpeed == 'speeddown' then 493 | local setSpeed = tonumber(ChosenSpeed - 5) 494 | if SpeedUnits == ADDefaults.MPH then 495 | if ChosenSpeed <= 5 then 496 | setSpeed = tonumber(ChosenSpeed -1) 497 | else 498 | setSpeed = tonumber(ChosenSpeed - 5) 499 | end 500 | else 501 | if ChosenSpeed <= 2 then 502 | setSpeed = tonumber(ChosenSpeed -1) 503 | else 504 | setSpeed = tonumber(ChosenSpeed - 2) 505 | end 506 | end 507 | if setSpeed < 0.0 then 508 | setSpeed = 0.0 509 | end 510 | ChosenSpeed = setSpeed 511 | if IsAutoDriveEnabled and IsPlayerInVehicle then 512 | SetDriveTaskCruiseSpeed(ped, ChosenSpeed / SpeedUnits) 513 | end 514 | Subtitle("Speed: ~b~" .. tostring(ChosenSpeed), 3000) 515 | end 516 | TimedOSD() 517 | end) 518 | 519 | -- ##########################################-------------------------------------- Settings Events -- Modular 520 | 521 | RegisterNetEvent(EventsTable.Settings.name) 522 | AddEventHandler(EventsTable.Settings.name, function(settingsData) 523 | local playerPed = PlayerPedId() 524 | local ped = nil 525 | ped = SetDriverPed() 526 | local settings = settingsData 527 | if type(settings) == 'table' then settings = settingsData.id end 528 | if settings == 'osd' then 529 | if ADDefaults.OnScreenDisplay then 530 | if ADDefaults.OSDtimed then 531 | if vehicleOSDMode then ToggleOSDMode() end 532 | ToggleOSDMode() 533 | Citizen.Wait(3000) 534 | if vehicleOSDMode then ToggleOSDMode() end 535 | else 536 | ToggleOSDMode() 537 | end 538 | elseif 539 | not ADDefaults.OnScreenDisplay then 540 | ToggleOSDMode() 541 | end 542 | elseif settings == 'toggleosd' then 543 | ADDefaults.OnScreenDisplay = not ADDefaults.OnScreenDisplay 544 | if ADDefaults.OnScreenDisplay then 545 | if ADDefaults.OSDtimed then 546 | if vehicleOSDMode then ToggleOSDMode() end 547 | ToggleOSDMode() 548 | Citizen.Wait(3000) 549 | if vehicleOSDMode then ToggleOSDMode() end 550 | else 551 | ToggleOSDMode() 552 | end 553 | elseif 554 | not ADDefaults.OnScreenDisplay then 555 | ToggleOSDMode() 556 | end 557 | Subtitle("Toggle OSD ~y~" .. tostring(ADDefaults.OnScreenDisplay), 3000) 558 | elseif settings == 'timedosd' then 559 | ADDefaults.OSDtimed = not ADDefaults.OSDtimed 560 | if ADDefaults.OSDtimed then 561 | TimedOSD() 562 | else 563 | if not vehicleOSDMode and IsPedInAnyVehicle(ped) then 564 | TimedOSD() 565 | end 566 | 567 | end 568 | Subtitle("Toggle OSD Timed ~y~" .. tostring(ADDefaults.OSDtimed), 3000) 569 | elseif settings == 'setspeedunits' then 570 | toggleSpeedUnits = not toggleSpeedUnits 571 | if toggleSpeedUnits then 572 | SpeedUnits = ADDefaults.KMH 573 | ChosenSpeed = 40.0 574 | SetDriveTaskCruiseSpeed(ped, ChosenSpeed/SpeedUnits) 575 | Subtitle("Speed Units ~y~" .. tostring("KMH"), 3000) 576 | else 577 | SpeedUnits = ADDefaults.MPH 578 | ChosenSpeed = 25.0 579 | SetDriveTaskCruiseSpeed(ped, ChosenSpeed/SpeedUnits) 580 | Subtitle("Speed Units ~y~" .. tostring("MPH"), 3000) 581 | end 582 | ToggleOSDMode() 583 | Citizen.Wait(10) 584 | ToggleOSDMode() 585 | elseif settings == 'drivervisible' and ADDefaults.ToggleDriverCreation then 586 | toggleDriverVisible = not toggleDriverVisible 587 | if DriverPed ~= PlayerPedId() then 588 | Subtitle(string.format("Driver Visible ~y~%s", tostring(toggleDriverVisible):gsub("^%l", string.upper)), 3000) 589 | if toggleDriverVisible then 590 | SetEntityVisible(DriverPed, true) 591 | Citizen.CreateThread(function() 592 | while toggleDriverVisible do 593 | Citizen.Wait(1000) 594 | if DoesEntityExist(DriverPed) then 595 | if not IsPedInAnyVehicle(DriverPed, false) then 596 | DeleteEntity(DriverPed) 597 | else 598 | end 599 | end 600 | end 601 | end) 602 | else 603 | SetEntityVisible(DriverPed, false) 604 | end 605 | end 606 | elseif settings == 'drivercreate' and ADDefaults.ToggleDriverCreation then 607 | toggleDriverCreation = not toggleDriverCreation 608 | Subtitle(string.format("Driver Creation ~y~%s", tostring(toggleDriverCreation):gsub("^%l", string.upper)), 3000) 609 | -- if toggleDriverCreation then 610 | elseif settings == 'driverforced' and ADDefaults.ToggleDriverCreation then 611 | toggleDriverForced = not toggleDriverForced 612 | Subtitle(string.format("Driver Forced ~y~%s", tostring(toggleDriverForced):gsub("^%l", string.upper)), 3000) 613 | 614 | end 615 | end) 616 | -------------------------------------------------------------------------------- /qbcore/adclient-qb.lua: -------------------------------------------------------------------------------- 1 | ----------------------------------------------------------------------------------------------------------------------------------------- 2 | ----------------------------------------------------------------------------------------------------------------------------------------- 3 | ----------------------------------------------------------------------------------------------------------- QBCore Client --------------- 4 | ----------------------------------------------------------------------------------------------------------------------------------------- 5 | ----------------------------------------------------------------------------------------------------------------------------------------- 6 | 7 | if not ADDefaults.UseQBCore then return end 8 | 9 | local QBCore = exports['qb-core']:GetCoreObject() 10 | 11 | -- local TADev = exports['ta-dev']:GetTADevObject() 12 | RegisterNetEvent('QBCore:Client:UpdateObject', function() 13 | QBCore = exports['qb-core']:GetCoreObject() 14 | end) 15 | 16 | -- TADev.Debug(QBCore.Shared.Items['ad_fob']) 17 | -- -- ############################################################################################# Metatable 18 | 19 | -- Create metatable 20 | VehiclesWithAutodrive = {} 21 | AutodriveMeta = {} -- create a namespace 22 | -- create the protoype with default values 23 | AutodriveMeta.protoype = { ["Id"] = 0, ["Order"] = 0, ["ad_destinations"] = false, ["ad_kit"] = false, ["ad_osd"] = false, 24 | ["ad_speed"] = false, ["ad_styles"] = false, ["ad_tagger"] = false, } 25 | AutodriveMeta.mt = {} -- create a metatable 26 | function AutodriveMeta.new(o) -- declare the construcor function 27 | setmetatable(o, AutodriveMeta.mt) 28 | return o 29 | end 30 | 31 | AutodriveMeta.mt.__index = AutodriveMeta.protoype -- ### did work 32 | exports('vehicleswithautodrive', function() 33 | return VehiclesWithAutodrive 34 | end) 35 | 36 | RegisterNetEvent('QBCore:Server:UpdateObject', function() 37 | if source ~= '' then return false end 38 | QBCore = exports['qb-core']:GetCoreObject() 39 | 40 | end) 41 | 42 | -- -- ############################################################################################# FUNCTIONS 43 | -- -- ############################################################################################# -- Helper functions 44 | 45 | -- QB Notify, subtitles, console print 46 | ---@param text string message string 47 | ---@param type string error/success string 48 | function NotifyAutodrive(text, type) 49 | local sub = Config.Lang.Subtitle[text] 50 | local notify = Config.Lang.Notify[text] 51 | local debug = true 52 | Subtitle(sub, 3000) 53 | if ADDefaults.UseQBCore and Config.QBNotify then 54 | QBCore.Functions.Notify(notify, type, 3000) 55 | end 56 | if debug then print("Notify:", Config.Lang.Notify[text]) end 57 | end 58 | -- -- ############################################################################################# 59 | 60 | -- create new vehicle metatable for VehiclesWithAutodrive 61 | ---@param vehicle integer vehicle id 62 | ---@param tbl table vehicle table 63 | local function NewMeta(vehicle, tbl) 64 | local count = 0 65 | for k, v in pairs(tbl) do 66 | count = count + 1 67 | end 68 | local order = count + 1 69 | tbl[vehicle] = AutodriveMeta.new { 70 | ["Id"] = vehicle, 71 | ["Order"] = order, 72 | ["ad_kit"] = false, 73 | ["ad_destinations"] = false, 74 | ["ad_osd"] = false, 75 | ["ad_speed"] = false, 76 | ["ad_styles"] = false, 77 | ["ad_tagger"] = false, 78 | } 79 | end 80 | 81 | -- -- ############################################################################################# 82 | 83 | -- is ad_kit installed, used in InstallPartsByVehicle 84 | ---@param vehicle integer vehicle id 85 | ---@param ad_part string autodrive part 86 | ---@return boolean bool is part installed 87 | function IsADPartInstalled(vehicle, ad_part) 88 | print("adclient-qb: IsADPartInstalled", vehicle, ad_part) 89 | local ret = false 90 | if not Config.RequireParts then 91 | ret = true print(ret) 92 | return ret 93 | end 94 | if VehiclesWithAutodrive[vehicle] == nil then return ret end 95 | if VehiclesWithAutodrive[vehicle][ad_part] == true then 96 | ret = true 97 | return ret 98 | end 99 | return ret 100 | end 101 | 102 | -- -- ############################################################################################# 103 | 104 | -- make entity1 face entity2 105 | ---@param entity1 integer 106 | ---@param entity2 integer 107 | local function MakeEntityFaceEntity(entity1, entity2) 108 | local p1 = GetEntityCoords(entity1, true) 109 | local p2 = GetEntityCoords(entity2, true) 110 | 111 | local dx = p2.x - p1.x 112 | local dy = p2.y - p1.y 113 | 114 | local heading = GetHeadingFromVector_2d(dx, dy) 115 | SetEntityHeading(entity1, heading) 116 | end 117 | 118 | -- -- ############################################################################################# 119 | 120 | -- find bone coords and go to ped task 121 | ---@param ped integer ped id 122 | ---@param vehicle integer vehicle id 123 | local function GoToBone(ped, vehicle) 124 | local playerPed = ped 125 | local v0 = GetWorldPositionOfEntityBone(vehicle, GetEntityBoneIndexByName(vehicle, "overheat")) 126 | local v1 = GetObjectOffsetFromCoords(v0.x, v0.y, v0.z, GetEntityHeading(vehicle), 0.0, 0.6, 0.0) 127 | ClearPedTasks(playerPed) 128 | 129 | MakeEntityFaceEntity(playerPed, vehicle) 130 | SetVehicleDoorOpen(vehicle, 4, false, false) 131 | TaskGoStraightToCoord(playerPed, v1.x, v1.y, v1.z, 1.0, -1, 0.0, 1.0) 132 | 133 | Wait(3000) 134 | ClearPedTasks(playerPed) 135 | 136 | FreezeEntityPosition(playerPed, false) 137 | MakeEntityFaceEntity(playerPed, vehicle) 138 | end 139 | 140 | -- Install parts progress bar 141 | ---@param vehicle integer vehicle id 142 | ---@param ad_part string item 143 | local function InstallProgressBar(vehicle, ad_part) 144 | local notify = Config.Lang.Notify['ad_install_progbar'] 145 | local playerPed = PlayerPedId() 146 | local part = ad_part 147 | local installTime = nil 148 | if part == "ad_kit" then 149 | installTime = Config.KitInstallTime 150 | else 151 | installTime = Config.UpgradeInstallTime 152 | end 153 | 154 | Wait(500) 155 | 156 | QBCore.Functions.Progressbar("ad_install_parts", notify, installTime, false, false, 157 | { -- control disables 158 | disableMovement = true, 159 | disableCarMovement = false, 160 | disableMouse = false, 161 | disableCombat = true, 162 | }, 163 | { -- animations 164 | animDict = "mini@repair", 165 | anim = "fixing_a_ped", 166 | flags = 1, 167 | }, {}, {}, 168 | function() -- do when done 169 | FreezeEntityPosition(playerPed, false) 170 | SetVehicleDoorShut(vehicle, 4, false) 171 | ClearPedTasks(playerPed) 172 | end) 173 | -- Wait(1000) 174 | end 175 | 176 | -- --############################################################################################# Install Part Function 177 | -- --############################################################################################# 178 | 179 | ---@param ad_part string located in items.lua 180 | local function InstallPart(ad_part) 181 | local has_key = false 182 | local playerPed = PlayerPedId() 183 | local veh = nil 184 | local vehicle = nil 185 | local part = ad_part 186 | local CurrentVehicleData = nil 187 | local hasItem = QBCore.Functions.HasItem(part) 188 | local reqParts = Config.RequireParts 189 | TriggerServerEvent('ta-autodrive:server:giveitems', ad_part) 190 | 191 | vehicle = GetVehicle(playerPed) 192 | if DoesEntityExist(vehicle) then 193 | if VehiclesWithAutodrive[vehicle] == nil then 194 | NewMeta(vehicle, VehiclesWithAutodrive) 195 | has_key = true 196 | else 197 | has_key = true 198 | end 199 | else print("does not exist") return 200 | end 201 | 202 | if not IsAllowedToInstall(playerPed, vehicle) then return end 203 | if VehiclesWithAutodrive[vehicle] == nil then NotifyAutodrive('tryagain', 'error') return end 204 | if has_key then 205 | 206 | veh = VehiclesWithAutodrive[vehicle] 207 | if reqParts and not hasItem then 208 | NotifyAutodrive('missingparts', "error") 209 | return 210 | elseif part == 'ad_kit' then 211 | veh[part] = true 212 | GoToBone(playerPed, vehicle) 213 | InstallProgressBar(vehicle) 214 | Wait(Config.KitInstallTime) 215 | NotifyAutodrive('adkit', "success") 216 | elseif not veh['ad_kit'] then 217 | NotifyAutodrive('adupgradef', "error") 218 | elseif part ~= 'ad_kit' and veh['ad_kit'] then 219 | veh[part] = true 220 | GoToBone(playerPed, vehicle) 221 | InstallProgressBar(vehicle) 222 | Wait(Config.UpgradeInstallTime) 223 | NotifyAutodrive('adupgrade', "success") 224 | end 225 | 226 | if veh[part] then 227 | if reqParts then 228 | TriggerServerEvent('ta-autodrive:server:remove:part', ad_part) 229 | NotifyAutodrive("partremoved", "success") 230 | end 231 | 232 | CurrentVehicleData = QBCore.Functions.GetVehicleProperties(vehicle) 233 | CurrentVehicleData.autodrive[part] = veh[part] 234 | QBCore.Functions.SetVehicleProperties(vehicle, CurrentVehicleData) 235 | TriggerServerEvent('updateVehicle', CurrentVehicleData) 236 | end 237 | 238 | end 239 | end 240 | 241 | -- -- ######################################################################################################-- QB-Menu 242 | -- -- ###################################################################################################### 243 | 244 | -- Autodrive Main Menu 245 | local requiredParts = {} 246 | if Config.RequireParts then 247 | requiredParts = { 248 | adkit = 'ad_kit', 249 | adtagger = 'ad_tagger', 250 | adstyles = 'ad_styles', 251 | adosd = 'ad_osd', 252 | adspeed = 'ad_speed', 253 | addestinations = 'ad_destinations', 254 | adblips = 'ad_kit' 255 | } 256 | else 257 | requiredParts = { 258 | adkit = false, 259 | adtagger = false, 260 | adstyles = false, 261 | adosd = false, 262 | adspeed = false, 263 | addestinations = false, 264 | } 265 | end 266 | -- -- ######################################################################################################-- QB Main Menu Event 267 | -- -- ###################################################################################################### 268 | 269 | RegisterNetEvent(EventsTable.QBMenu.main) 270 | AddEventHandler(EventsTable.QBMenu.main, function() 271 | local veh = GetVehicle(PlayerPedId()) 272 | local hasItem = QBCore.Functions.HasItem('ad_fob') 273 | if not IsADPartInstalled(veh, "ad_kit") or not hasItem then 274 | NotifyAutodrive('adkitfail', "error") 275 | return 276 | end 277 | local submenu = EventsTable.QBMenu.Submenu.name 278 | if ADDefaults.UseQBMenu then 279 | exports['qb-menu']:openMenu({ 280 | { -- header = "Autodrive Menu" 281 | header = "Autodrive Menu", 282 | txt = "Sit back and close your eyes..", 283 | isMenuHeader = true 284 | }, 285 | { -- Toggle autodrive 286 | header = "Autodrive", 287 | txt = DestTable.Toggle.Start.title, 288 | icon = string.format('fa-solid fa-%s', DestTable.Toggle.Start.icon), 289 | params = { 290 | item = requiredParts.adkit, 291 | event = EventsTable.Start, 292 | -- args = false, 293 | } 294 | }, 295 | { -- Toggle driving style 296 | header = StylesTable.Info.title, 297 | txt = StylesTable.Info.txt, 298 | icon = string.format('fa-solid fa-%s', StylesTable.Info.icon), 299 | params = { 300 | event = submenu, 301 | args = 'styles' 302 | } 303 | }, 304 | { -- Toggle Destinations 305 | header = DestTable.Info.title, 306 | txt = DestTable.Info.txt, 307 | icon = string.format('fa-solid fa-%s', DestTable.Info.icon), 308 | params = { 309 | event = submenu, 310 | args = 'destinations' 311 | } 312 | }, 313 | { -- Toggle Speed Limits 314 | header = SpeedTable.Info.title, 315 | txt = SpeedTable.Info.txt, 316 | icon = string.format('fa-solid fa-%s', SpeedTable.Info.icon), 317 | params = { 318 | event = submenu, 319 | args = 'speeds' 320 | } 321 | }, 322 | { -- Toggle Settings 323 | header = SettingsTable.Info.title, 324 | txt = SettingsTable.Info.txt, 325 | icon = string.format('fa-solid fa-%s', SettingsTable.Info.icon), 326 | params = { 327 | event = submenu, 328 | args = 'settings' 329 | } 330 | }, 331 | { -- Toggle OSD 332 | header = SettingsTable.Args.OSD.title, 333 | txt = SettingsTable.Args.OSD.txt, 334 | icon = string.format('fa-solid fa-%s', SettingsTable.Info.icon), 335 | params = { 336 | event = EventsTable.Settings.name, 337 | args = SettingsTable.Args.OSD.id 338 | } 339 | }, 340 | { -- Follow 341 | header = DestTable.Args.Tag.title, 342 | icon = string.format('fa-solid fa-%s', DestTable.Args.Tag.icon), 343 | params = { 344 | event = EventsTable.Destination.name, 345 | args = DestTable.Args.Tag.id 346 | } 347 | }, 348 | { -- close 349 | header = "<< Close Menu", 350 | txt = "Bye!", 351 | params = { 352 | event = EventsTable.QBMenu.close, 353 | } 354 | 355 | }, 356 | }) 357 | end 358 | end) 359 | 360 | -- ######################################################################################################-- QB Sub Menu Events 361 | 362 | RegisterNetEvent(EventsTable.QBMenu.Submenu.name, function(submenu) 363 | -- ##############################################################################-- Destination QB Menu 364 | if submenu == "destinations" then 365 | local event = EventsTable.Destination.name 366 | exports['qb-menu']:openMenu({ 367 | { -- header = "Destinations" 368 | header = "Destinations", 369 | txt = "Where do you want to go?", 370 | isMenuHeader = true 371 | }, 372 | { -- Freeroam 373 | header = DestTable.Args.Freeroam.title, 374 | icon = string.format('fa-solid fa-%s', DestTable.Args.Freeroam.icon), 375 | params = { 376 | event = event, 377 | args = DestTable.Args.Freeroam.id 378 | } 379 | }, 380 | { -- Blip 381 | header = DestTable.Args.Blip.title, 382 | icon = string.format('fa-solid fa-%s', DestTable.Args.Blip.icon), 383 | params = { 384 | event = EventsTable.QBMenu.Submenu.name, 385 | args = 'blips' 386 | } 387 | }, 388 | { -- Waypoint 389 | header = DestTable.Args.Waypoint.title, 390 | icon = string.format('fa-solid fa-%s', DestTable.Args.Waypoint.icon), 391 | params = { 392 | event = event, 393 | args = DestTable.Args.Waypoint.id 394 | } 395 | }, 396 | { -- Fuel 397 | header = DestTable.Args.Fuel.title, 398 | icon = string.format('fa-solid fa-%s', DestTable.Args.Fuel.icon), 399 | params = { 400 | event = event, 401 | args = DestTable.Args.Fuel.id 402 | } 403 | }, 404 | { -- Postal 405 | header = DestTable.Args.Postal.title, 406 | icon = string.format('fa-solid fa-%s', DestTable.Args.Postal.icon), 407 | params = { 408 | event = EventsTable.QBMenu.Submenu.name, 409 | args = 'postals' 410 | } 411 | }, 412 | { -- Follow 413 | header = DestTable.Args.Follow.title, 414 | icon = string.format('fa-solid fa-%s', DestTable.Args.Follow.icon), 415 | params = { 416 | event = event, 417 | args = DestTable.Args.Follow.id 418 | } 419 | }, 420 | { -- Tag 421 | header = DestTable.Args.Tag.title, 422 | icon = string.format('fa-solid fa-%s', DestTable.Args.Tag.icon), 423 | params = { 424 | event = event, 425 | args = DestTable.Args.Tag.id 426 | } 427 | }, 428 | { -- back 429 | header = "<< Back", 430 | params = { 431 | event = EventsTable.QBMenu.main, 432 | } 433 | }, 434 | 435 | }) 436 | end 437 | 438 | -- ##############################################################################-- Styles QB Menu 439 | 440 | if submenu == "styles" then 441 | local event = EventsTable.Style.name 442 | local staffList = {} 443 | 444 | staffList[#staffList + 1] = { -- create non-clickable header button 445 | isMenuHeader = true, 446 | header = StylesTable.Info.title, 447 | txt = StylesTable.Info.title, 448 | icon = string.format('fa-solid fa-%s', StylesTable.Info.icon), 449 | } 450 | for k, v in pairs(StylesTable.Args) do -- loop through our table 451 | if v ~= StylesTable.info then 452 | staffList[#staffList + 1] = { -- insert data from our loop into the menu 453 | header = v.title, 454 | icon = string.format('fa-solid fa-%s', v.icon), --fa-face-grin-tears 455 | params = { 456 | event = event, -- event name 457 | args = v 458 | -- { 459 | -- -- name = k, -- value we want to pass 460 | -- -- label = tonumber(v.sprite) 461 | -- } 462 | } 463 | } 464 | end 465 | end 466 | 467 | staffList[#staffList + 1] = { -- create clickable header button 468 | header = '<< Back', 469 | -- icon = 'fa-solid fa-infinity', 470 | params = { 471 | event = EventsTable.QBMenu.main, 472 | -- args = 'destinations' 473 | } 474 | } 475 | table.sort(StylesTable.Args, function (a, b) 476 | return string.upper(a.id) < string.upper(b.id) 477 | end) 478 | exports['qb-menu']:openMenu(staffList) -- open our menu 479 | 480 | end 481 | 482 | -- ##############################################################################-- Speeds QB Menu 483 | 484 | if submenu == "speeds" then 485 | local event = 'ta-autodrive:client:speed' 486 | exports['qb-menu']:openMenu({ 487 | { -- Driving Styles 488 | isMenuHeader = true, 489 | header = SpeedTable.Info.title, 490 | txt = SpeedTable.Info.txt, 491 | icon = string.format('fa-solid fa-%s', SpeedTable.Info.icon), 492 | }, 493 | { -- Posted Limits 494 | header = SpeedTable.Args.PostedLimits.title, 495 | icon = string.format('fa-solid fa-%s', SpeedTable.Args.PostedLimits.icon), 496 | params = { 497 | event = event, 498 | args = SpeedTable.Args.PostedLimits.id 499 | } 500 | }, 501 | { -- Manual Input 502 | header = SpeedTable.Args.SetSpeed.title, 503 | icon = string.format('fa-solid fa-%s', SpeedTable.Args.SetSpeed.icon), 504 | params = { 505 | event = event, 506 | args = SpeedTable.Args.SetSpeed.id 507 | } 508 | }, 509 | { -- Reset Speed 510 | header = SpeedTable.Args.ResetSpeed.title, 511 | icon = string.format('fa-solid fa-%s', SpeedTable.Args.ResetSpeed.icon), 512 | params = { 513 | event = event, 514 | args = SpeedTable.Args.ResetSpeed.id 515 | } 516 | }, 517 | { -- back 518 | header = "<< Back", 519 | params = { 520 | event = EventsTable.QBMenu.main, 521 | } 522 | }, 523 | }) 524 | 525 | end 526 | 527 | -- ##############################################################################-- Blips QB Menu 528 | 529 | if submenu == 'blips' then 530 | local veh = GetVehicle(PlayerPedId()) 531 | if not IsADPartInstalled(veh, "ad_kit") then 532 | NotifyAutodrive('adkitfail', "error") 533 | --return 534 | end 535 | 536 | local event = EventsTable.Destination.name 537 | local staffList = {} 538 | 539 | staffList[#staffList + 1] = { -- create non-clickable header button 540 | isMenuHeader = true, 541 | header = "Blips Menu", 542 | txt = DestTable.Args.Blip.txt, 543 | icon = 'fa-solid fa-infinity' 544 | } 545 | 546 | for k,v in pairs(BlipDestination.BlipNames) do -- loop through our table 547 | print("k", k, "v", v.sprite, v.id, v.title) 548 | staffList[#staffList + 1] = { -- insert data from our loop into the menu 549 | header = v.title, --k, 550 | txt = v.title, 551 | icon = string.format('fa-solid fa-%s', v.icon), --fa-face-grin-tears 552 | params = { 553 | event = event, -- event name 554 | args = tonumber(v.sprite) 555 | -- { 556 | -- -- name = k, -- value we want to pass 557 | -- -- label = tonumber(v.sprite) 558 | -- } 559 | } 560 | } 561 | end 562 | 563 | staffList[#staffList + 1] = { -- create clickable header button 564 | header = 'Close Menu', 565 | icon = 'fa-solid fa-infinity', 566 | params = { 567 | event = EventsTable.QBMenu.Submenu.name, 568 | args = 'destinations' 569 | } 570 | } 571 | 572 | exports['qb-menu']:openMenu(staffList) -- open our menu 573 | end 574 | 575 | -- ##############################################################################-- Blips QB Menu 576 | 577 | if submenu == 'postals' then 578 | local event = EventsTable.Destination.name 579 | exports['qb-menu']:openMenu({ 580 | { -- Settings 581 | isMenuHeader = true, 582 | header = 'Postals Menu', 583 | txt = 'Special Delivery', 584 | icon = string.format('fa-solid fa-%s', DestTable.Args.Postal.icon), 585 | }, 586 | { -- Postal 587 | header = DestTable.Args.Postal.title, 588 | icon = string.format('fa-solid fa-%s', DestTable.Args.Postal.icon), 589 | params = { 590 | event = event, 591 | args = DestTable.Args.Postal.id 592 | } 593 | }, 594 | { -- Clear Postal 595 | header = 'Clear Postal', 596 | -- txt = tostring(ADDefaults.OSDtimed):gsub("^%l", string.upper), 597 | icon = string.format('fa-solid fa-%s', SettingsTable.Args.TimedOsd.icon), 598 | params = { 599 | event = ExecuteCommand('postal'), 600 | -- args = SettingsTable.Args.TimedOsd.id 601 | } 602 | }, 603 | }) 604 | end 605 | 606 | -- ##############################################################################-- Settings QB Menu 607 | 608 | if submenu == 'settings' then 609 | local event = EventsTable.Settings.name 610 | exports['qb-menu']:openMenu({ 611 | { -- Settings 612 | isMenuHeader = true, 613 | header = SettingsTable.Info.title, 614 | txt = SettingsTable.Info.txt, 615 | icon = string.format('fa-solid fa-%s', SettingsTable.Info.icon), 616 | }, 617 | { -- OSD Always on/off 618 | header = SettingsTable.Args.ToggleOsd.title, 619 | txt = tostring(ADDefaults.OnScreenDisplay):gsub("^%l", string.upper), 620 | icon = string.format('fa-solid fa-%s', SettingsTable.Args.ToggleOsd.icon), 621 | params = { 622 | event = event, 623 | args = SettingsTable.Args.ToggleOsd.id 624 | } 625 | }, 626 | { -- Timed OSD 627 | header = SettingsTable.Args.TimedOsd.title, 628 | txt = tostring(ADDefaults.OSDtimed):gsub("^%l", string.upper), 629 | icon = string.format('fa-solid fa-%s', SettingsTable.Args.TimedOsd.icon), 630 | params = { 631 | event = event, 632 | args = SettingsTable.Args.TimedOsd.id 633 | } 634 | }, 635 | { -- Toggle Speed Units 636 | header = SettingsTable.Args.SetSpeedUnits.title, 637 | txt = tostring(toggleSpeedUnits):gsub("^%l", string.upper), 638 | icon = string.format('fa-solid fa-%s', SettingsTable.Args.SetSpeedUnits.icon), 639 | params = { 640 | event = event, 641 | args = SettingsTable.Args.SetSpeedUnits.id 642 | } 643 | }, 644 | { -- Toggle Driver Visible 645 | header = SettingsTable.Args.DriverVisible.title, 646 | txt = tostring(toggleDriverVisible):gsub("^%l", string.upper), 647 | icon = string.format('fa-solid fa-%s', SettingsTable.Args.DriverVisible.icon), 648 | params = { 649 | event = event, 650 | args = SettingsTable.Args.DriverVisible.id 651 | } 652 | }, 653 | { -- Toggle Driver Create 654 | header = SettingsTable.Args.DriverCreate.title, 655 | txt = tostring(toggleDriverCreation):gsub("^%l", string.upper), 656 | icon = string.format('fa-solid fa-%s', SettingsTable.Args.DriverCreate.icon), 657 | params = { 658 | event = event, 659 | args = SettingsTable.Args.DriverCreate.id, 660 | } 661 | }, 662 | { -- Toggle Driver Forced 663 | header = SettingsTable.Args.DriverForced.title, 664 | txt = tostring(toggleDriverForced):gsub("^%l", string.upper), 665 | icon = string.format('fa-solid fa-%s', SettingsTable.Args.DriverForced.icon), 666 | params = { 667 | event = event, 668 | args = SettingsTable.Args.DriverForced.id, 669 | } 670 | }, 671 | { -- back 672 | header = "<< Back", 673 | params = { 674 | event = EventsTable.QBMenu.main, 675 | } 676 | }, 677 | }) 678 | end 679 | end) 680 | 681 | -- ######################################################################################################-- QB Close Menu Event 682 | 683 | RegisterNetEvent(EventsTable.QBMenu.close, function() exports['qb-menu']:closeMenu() 684 | end) 685 | 686 | -- -- ######################################################################################################-- QB-Target 687 | -- -- ###################################################################################################### 688 | 689 | -- QB-Target Bones 690 | 691 | local vehBones = { 692 | 'boot', 693 | 'bonnet' 694 | } 695 | 696 | -- QB-Target menu 697 | exports['qb-target']:AddTargetBone(vehBones, { 698 | options = { 699 | { -- Install ad_kit 700 | num = 1, 701 | type = "client", 702 | icon = "fas fa-bolt", 703 | label = "Install Autodrive Kit", 704 | item = requiredParts.adkit, 705 | action = function() 706 | TriggerEvent("ta-autodrive:client:qb:install:part", 'ad_kit') 707 | end 708 | }, 709 | { -- Install ad_tagger 710 | num = 2, 711 | type = "client", 712 | icon = "fas fa-bolt", 713 | label = "Install Autodrive Tagger", 714 | item = requiredParts.adtagger, 715 | action = function() 716 | TriggerEvent("ta-autodrive:client:qb:install:part", 'ad_tagger') 717 | end 718 | }, 719 | { -- install ad_speed 720 | num = 5, 721 | type = "client", 722 | icon = "fas fa-bolt", 723 | label = "Upgrade Speed", 724 | item = requiredParts.adspeed, 725 | action = function() 726 | TriggerEvent("ta-autodrive:client:qb:install:part", 'ad_speed') 727 | end 728 | }, 729 | { -- install ad_styles 730 | num = 4, 731 | type = "client", 732 | -- event = TriggerEvent("ta-autodrive:client:qb:install:part", 'ad_tagger'), 733 | icon = "fas fa-bolt", 734 | label = "Upgrade Styles", 735 | item = requiredParts.adstyles, 736 | action = function() 737 | TriggerEvent("ta-autodrive:client:install:part", 'ad_styles') 738 | end 739 | }, 740 | { -- install ad_destinations 741 | num = 3, 742 | type = "client", 743 | -- event = TriggerEvent("ta-autodrive:client:qb:install:part", 'ad_tagger'), 744 | icon = "fas fa-bolt", 745 | label = "Upgrade Destinations", 746 | item = requiredParts.addestinations, 747 | action = function() 748 | TriggerEvent("ta-autodrive:client:qb:install:part", 'ad_destinations') 749 | end 750 | }, 751 | { -- install ad_osd 752 | num = 6, 753 | type = "client", 754 | -- event = TriggerEvent("ta-autodrive:client:qb:install:part", 'ad_tagger'), 755 | icon = "fas fa-bolt", 756 | label = "Install Autodrive OSD", 757 | item = requiredParts.adosd, 758 | action = function() 759 | TriggerEvent("ta-autodrive:client:qb:install:part", 'ad_osd') 760 | end 761 | }, 762 | --[[ { -- install ad_blips 763 | -- num = 7, 764 | -- type = "client", 765 | -- icon = "fas fa-bolt", 766 | -- label = "Install Autodrive Blips", 767 | -- item = requiredParts.addestinations, 768 | -- action = function() 769 | -- TriggerEvent("ta-autodrive:client:qb:install:part", 'ad_kit') 770 | -- end 771 | -- },]] 772 | }, 773 | distance = 2.0, 774 | }) 775 | 776 | -- -- #######################################################################################################-- Install Part Event 777 | -- -- ###################################################################################################### 778 | 779 | RegisterNetEvent('ta-autodrive:client:qb:install:part') 780 | AddEventHandler('ta-autodrive:client:qb:install:part', function(ad_part) 781 | InstallPart(tostring(ad_part)) 782 | end) 783 | 784 | RegisterCommand('adpart', function(source, args, rawcommand) 785 | TriggerEvent('ta-autodrive:client:qb:install:part', args[1]) 786 | TaskEnterVehicle(PlayerPedId(), GetVehicle(PlayerPedId()), -1, -1, 2.0, 8, 0) 787 | end) 788 | 789 | 790 | 791 | 792 | --------------------------------------------------------------------------------