Retro Boosting
-
Make the necessary adjustments.
client/main.lua --------------------------- Variables ---------------------------local QBCore = exports['qb-core']:GetCoreObject()local KeysList = {}local isTakingKeys = falselocal isCarjacking = falselocal canCarjack = truelocal AlertSend = falselocal lastPickedVehicle = nillocal IsHotwiring = falselocal trunkclose = truelocal looped = falselocal function robKeyLoop()if looped then return endlooped = truewhile true dolocal sleep = 1000if LocalPlayer.state.isLoggedIn thensleep = 100local ped = PlayerPedId()local entering = GetVehiclePedIsTryingToEnter(ped)local carIsImmune = falseif entering ~= 0 and not isBlacklistedVehicle(entering) thensleep = 2000local plate = QBCore.Functions.GetPlate(entering)local driver = GetPedInVehicleSeat(entering, -1)for _, veh in ipairs(Config.ImmuneVehicles) doif GetEntityModel(entering) == joaat(veh) thencarIsImmune = trueendend-- Driven vehicle logicif driver ~= 0 and not IsPedAPlayer(driver) and not HasKeys(plate) and not carIsImmune thenif IsEntityDead(driver) thenif not isTakingKeys thenisTakingKeys = trueTriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1)QBCore.Functions.Progressbar('steal_keys', Lang:t('progress.takekeys'), 2500, false, false, {disableMovement = false,disableCarMovement = true,disableMouse = false,disableCombat = true}, {}, {}, {}, function() -- DoneTriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)isTakingKeys = falseend, function()isTakingKeys = falseend)endelseif Config.LockNPCDrivingCars thenTriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 2)elseTriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1)TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)--Make passengers fleelocal pedsInVehicle = GetPedsInVehicle(entering)for _, pedInVehicle in pairs(pedsInVehicle) doif pedInVehicle ~= GetPedInVehicleSeat(entering, -1) thenMakePedFlee(pedInVehicle)endendend-- Parked car logicelseif driver == 0 and entering ~= lastPickedVehicle and not HasKeys(plate) and not isTakingKeys thenQBCore.Functions.TriggerCallback('qb-vehiclekeys:server:checkPlayerOwned', function(playerOwned)local coords = exports['rs_boosting']:getBoostingCoords()if not playerOwned and (not coords or #(GetEntityCoords(ped) - coords.xyz) > 10.0) thenif Config.LockNPCParkedCars thenTriggerServerEvent('qb-vehiclekeys:server:setVehLockState',NetworkGetNetworkIdFromEntity(entering), 2)elseTriggerServerEvent('qb-vehiclekeys:server:setVehLockState',NetworkGetNetworkIdFromEntity(entering), 1)endendend, plate)endend-- Hotwiring while in vehicle, also keeps engine off for vehicles you don't own keys toif IsPedInAnyVehicle(ped, false) and not IsHotwiring thensleep = 1000local vehicle = GetVehiclePedIsIn(ped)local plate = QBCore.Functions.GetPlate(vehicle)if GetPedInVehicleSeat(vehicle, -1) == PlayerPedId() and not HasKeys(plate) and not isBlacklistedVehicle(vehicle) and not AreKeysJobShared(vehicle) thensleep = 0local vehiclePos = GetOffsetFromEntityInWorldCoords(vehicle, 0.0, 1.0, 0.5)DrawText3D(vehiclePos.x, vehiclePos.y, vehiclePos.z, Lang:t('info.skeys'))SetVehicleEngineOn(vehicle, false, false, true)if IsControlJustPressed(0, 74) thenHotwire(vehicle, plate)endendendif Config.CarJackEnable and canCarjack thenlocal playerid = PlayerId()local aiming, target = GetEntityPlayerIsFreeAimingAt(playerid)if aiming and (target ~= nil and target ~= 0) thenif DoesEntityExist(target) and IsPedInAnyVehicle(target, false) and not IsEntityDead(target) and not IsPedAPlayer(target) thenlocal targetveh = GetVehiclePedIsIn(target)for _, veh in ipairs(Config.ImmuneVehicles) doif GetEntityModel(targetveh) == joaat(veh) thencarIsImmune = trueendendif GetPedInVehicleSeat(targetveh, -1) == target and not IsBlacklistedWeapon() thenlocal pos = GetEntityCoords(ped, true)local targetpos = GetEntityCoords(target, true)if #(pos - targetpos) < 5.0 and not carIsImmune thenCarjackVehicle(target)endendendendendif entering == 0 and not IsPedInAnyVehicle(ped, false) and GetSelectedPedWeapon(ped) == 'WEAPON_UNARMED' thenlooped = falsebreakendendWait(sleep)endendfunction isBlacklistedVehicle(vehicle)local isBlacklisted = falsefor _, v in ipairs(Config.NoLockVehicles) doif joaat(v) == GetEntityModel(vehicle) thenisBlacklisted = truebreak;endendif Entity(vehicle).state.ignoreLocks or GetVehicleClass(vehicle) == 13 then isBlacklisted = true endreturn isBlacklistedendfunction addNoLockVehicles(model)Config.NoLockVehicles[#Config.NoLockVehicles + 1] = modelendexports('addNoLockVehicles', addNoLockVehicles)function removeNoLockVehicles(model)for k, v in pairs(Config.NoLockVehicles) doif v == model thenConfig.NoLockVehicles[k] = nilendendendexports('removeNoLockVehicles', removeNoLockVehicles)--------------------------- Client Events ---------------------------RegisterKeyMapping('togglelocks', Lang:t('info.tlock'), 'keyboard', 'L')RegisterCommand('togglelocks', function()local ped = PlayerPedId()if IsPedInAnyVehicle(ped, false) thenToggleVehicleLocksWithoutNui(GetVehicle())elseif Config.UseKeyfob thenOpenMenu()elseToggleVehicleLocksWithoutNui(GetVehicle())endend)RegisterKeyMapping('engine', Lang:t('info.engine'), 'keyboard', 'G')RegisterCommand('engine', function()local vehicle = GetVehicle()if not vehicle then return endif not IsPedInVehicle(PlayerPedId(), vehicle) then return endToggleEngine(vehicle)end)AddEventHandler('onResourceStart', function(resourceName)if resourceName == GetCurrentResourceName() and QBCore.Functions.GetPlayerData() ~= {} thenGetKeys()endend)-- Handles state right when the player selects their character and location.RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()GetKeys()end)-- Resets state on logout, in case of character change.RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()KeysList = {}end)RegisterNetEvent('qb-vehiclekeys:client:AddKeys', function(plate)KeysList[plate] = truelocal ped = PlayerPedId()if not IsPedInAnyVehicle(ped, false) then return endlocal vehicle = GetVehiclePedIsIn(ped)local vehicleplate = QBCore.Functions.GetPlate(vehicle)if plate ~= vehicleplate then return endSetVehicleEngineOn(vehicle, false, false, false)end)RegisterNetEvent('qb-vehiclekeys:client:RemoveKeys', function(plate)KeysList[plate] = nilend)RegisterNetEvent('qb-vehiclekeys:client:ToggleEngine', function()local EngineOn = GetIsVehicleEngineRunning(GetVehiclePedIsIn(PlayerPedId()))local vehicle = GetVehiclePedIsIn(PlayerPedId(), true)if HasKeys(QBCore.Functions.GetPlate(vehicle)) thenSetVehicleEngineOn(vehicle, not EngineOn, false, true)endend)RegisterNetEvent('qb-vehiclekeys:client:GiveKeys', function(id)local targetVehicle = GetVehicle()if not targetVehicle then return endlocal targetPlate = QBCore.Functions.GetPlate(targetVehicle)if not HasKeys(targetPlate) thenQBCore.Functions.Notify(Lang:t('notify.ydhk'), 'error')returnendif id and type(id) == 'number' then -- Give keys to specific IDGiveKeys(id, targetPlate)elseif IsPedSittingInVehicle(PlayerPedId(), targetVehicle) then -- Give keys to everyone in vehiclelocal otherOccupants = GetOtherPlayersInVehicle(targetVehicle)for p = 1, #otherOccupants doTriggerServerEvent('qb-vehiclekeys:server:GiveVehicleKeys', GetPlayerServerId(NetworkGetPlayerIndexFromPed(otherOccupants[p])), targetPlate)endelse -- Give keys to closest playerGiveKeys(GetPlayerServerId(QBCore.Functions.GetClosestPlayer()), targetPlate)endend)RegisterNetEvent('QBCore:Client:VehicleInfo', function(data)if data.event == 'Entering' thenrobKeyLoop()endend)RegisterNetEvent('qb-weapons:client:DrawWeapon', function()Wait(2000)robKeyLoop()end)RegisterNetEvent('lockpicks:UseLockpick', function(isAdvanced)local ped = PlayerPedId()local pos = GetEntityCoords(ped)local vehicle = QBCore.Functions.GetClosestVehicle()if vehicle == nil or vehicle == 0 or exports['rs_boosting']:isBoostingVehicle() then return endif HasKeys(QBCore.Functions.GetPlate(vehicle)) then return endif #(pos - GetEntityCoords(vehicle)) > 2.5 then return endif GetVehicleDoorLockStatus(vehicle) <= 0 then return endlocal difficulty = isAdvanced and 'easy' or 'medium' -- Easy for advanced lockpick, medium by defaultlocal success = exports['qb-minigames']:Skillbar(difficulty)local chance = math.random()TriggerServerEvent('hud:server:GainStress', math.random(1, 4))if success thenlastPickedVehicle = vehicleif GetPedInVehicleSeat(vehicle, -1) == ped thenTriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', QBCore.Functions.GetPlate(vehicle))elseQBCore.Functions.Notify(Lang:t('notify.vlockpick'), 'success')TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(vehicle), 1)endelseAttemptPoliceAlert('steal')endlocal threshold = isAdvanced and Config.RemoveLockpickAdvanced or Config.RemoveLockpickNormallocal pickType = isAdvanced and 'advancedlockpick' or 'lockpick'if chance <= threshold thenTriggerServerEvent('qb-vehiclekeys:server:breakLockpick', pickType)endend)-- Backwards Compatibility ONLY -- Remove at some point --RegisterNetEvent('vehiclekeys:client:SetOwner', function(plate)TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)end)-- Backwards Compatibility ONLY -- Remove at some point ----------------------------- Functions ---------------------------function OpenMenu()TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 0.5, 'key', 0.3)SendNUIMessage({ casemenue = 'open' })SetNuiFocus(true, true)endfunction ToggleEngine(veh)if not veh then return endif isBlacklistedVehicle(veh) then return endif not HasKeys(QBCore.Functions.GetPlate(veh)) and not AreKeysJobShared(veh) then return endlocal EngineOn = GetIsVehicleEngineRunning(veh)if EngineOn thenSetVehicleEngineOn(veh, false, false, true)elseSetVehicleEngineOn(veh, true, true, true)endendfunction ToggleVehicleLocksWithoutNui(veh)if not veh then return endif isBlacklistedVehicle(veh) thenTriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1)returnendif not HasKeys(QBCore.Functions.GetPlate(veh)) and not AreKeysJobShared(veh) thenQBCore.Functions.Notify(Lang:t('notify.ydhk'), 'error')returnendlocal ped = PlayerPedId()local vehLockStatus, curVeh = GetVehicleDoorLockStatus(veh), GetVehiclePedIsIn(ped, false)local object = 0if curVeh == 0 thenif Config.LockToggleAnimation.Prop thenobject = CreateObject(joaat(Config.LockToggleAnimation.Prop), 0, 0, 0, true, true, true)while not DoesEntityExist(object) do Wait(1) endAttachEntityToEntity(object, ped, GetPedBoneIndex(ped, Config.LockToggleAnimation.PropBone),0.1, 0.0, 0.0, 0.0, 0.0, 0.0, true, true, false, true, 1, true)endloadAnimDict(Config.LockToggleAnimation.AnimDict)TaskPlayAnim(ped, Config.LockToggleAnimation.AnimDict, Config.LockToggleAnimation.Anim, 8.0, -8.0, -1, 52, 0, false, false, false)TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 5.0, Config.LockAnimSound, 0.5)endCitizen.CreateThread(function()if curVeh == 0 then Wait(Config.LockToggleAnimation.WaitTime) endif IsEntityPlayingAnim(ped, Config.LockToggleAnimation.AnimDict, Config.LockToggleAnimation.Anim, 3) thenStopAnimTask(ped, Config.LockToggleAnimation.AnimDict, Config.LockToggleAnimation.Anim, 8.0)endTriggerServerEvent('InteractSound_SV:PlayWithinDistance', 5, Config.LockToggleSound, 0.3)if object ~= 0 and DoesEntityExist(object) thenDeleteObject(object)object = 0endend)NetworkRequestControlOfEntity(veh)if vehLockStatus == 1 thenTriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 2)QBCore.Functions.Notify(Lang:t('notify.vlock'), 'primary')elseTriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1)QBCore.Functions.Notify(Lang:t('notify.vunlock'), 'success')endSetVehicleLights(veh, 2)Wait(250)SetVehicleLights(veh, 1)Wait(200)SetVehicleLights(veh, 0)Wait(300)ClearPedTasks(ped)endfunction GiveKeys(id, plate)local distance = #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(id))))if distance <= 0.0 or distance >= 1.5 thenQBCore.Functions.Notify(Lang:t('notify.nonear'), 'error')returnendTriggerServerEvent('qb-vehiclekeys:server:GiveVehicleKeys', id, plate)endfunction GetKeys()QBCore.Functions.TriggerCallback('qb-vehiclekeys:server:GetVehicleKeys', function(keysList)KeysList = keysListend)endfunction HasKeys(plate)return KeysList[plate]endexports('HasKeys', HasKeys)function loadAnimDict(dict)while not HasAnimDictLoaded(dict) doRequestAnimDict(dict)Wait(0)endend-- If in vehicle returns that, otherwise tries 3 different raycasts to get the vehicle they are facing.-- Raycasts picture: https://i.imgur.com/FRED0kV.pngfunction GetVehicle()local ped = PlayerPedId()local pos = GetEntityCoords(ped)local vehicle = GetVehiclePedIsIn(PlayerPedId())while vehicle == 0 dovehicle = QBCore.Functions.GetClosestVehicle()if #(pos - GetEntityCoords(vehicle)) > Config.LockToggleDist then-- TODO: Assess adding vehicle or nil here.returnendendif not IsEntityAVehicle(vehicle) then vehicle = nil endreturn vehicleendfunction AreKeysJobShared(veh)local vehName = GetDisplayNameFromVehicleModel(GetEntityModel(veh))local vehPlate = QBCore.Functions.GetPlate(veh)local jobName = QBCore.Functions.GetPlayerData().job.namelocal onDuty = QBCore.Functions.GetPlayerData().job.ondutyfor job, v in pairs(Config.SharedKeys) doif job == jobName thenif Config.SharedKeys[job].requireOnduty and not onDuty then return false endfor _, vehicle in pairs(v.vehicles) doif string.upper(vehicle) == string.upper(vehName) thenif not HasKeys(vehPlate) thenTriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', vehPlate)endreturn trueendendendendreturn falseendfunction ToggleVehicleLocks(veh)if not veh then return endif isBlacklistedVehicle(veh) thenTriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1)returnendif not HasKeys(QBCore.Functions.GetPlate(veh)) and not AreKeysJobShared(veh) thenQBCore.Functions.Notify(Lang:t('notify.ydhk'), 'error')returnendlocal ped = PlayerPedId()local vehLockStatus = GetVehicleDoorLockStatus(veh)loadAnimDict('anim@mp_player_intmenu@key_fob@')TaskPlayAnim(ped, 'anim@mp_player_intmenu@key_fob@', 'fob_click', 3.0, 3.0, -1, 49, 0, false, false, false)TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 5, 'lock', 0.3)NetworkRequestControlOfEntity(veh)while NetworkGetEntityOwner(veh) ~= 128 doNetworkRequestControlOfEntity(veh)Wait(0)endif vehLockStatus == 1 thenTriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 2)QBCore.Functions.Notify(Lang:t('notify.vlock'), 'primary')endSetVehicleLights(veh, 2)Wait(250)SetVehicleLights(veh, 1)Wait(200)SetVehicleLights(veh, 0)Wait(300)ClearPedTasks(ped)endfunction ToggleVehicleunLocks(veh)if not veh then return endif isBlacklistedVehicle(veh) thenTriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1)returnendif not HasKeys(QBCore.Functions.GetPlate(veh)) and not AreKeysJobShared(veh) thenQBCore.Functions.Notify(Lang:t('notify.ydhk'), 'error')returnendlocal ped = PlayerPedId()local vehLockStatus = GetVehicleDoorLockStatus(veh)loadAnimDict('anim@mp_player_intmenu@key_fob@')TaskPlayAnim(ped, 'anim@mp_player_intmenu@key_fob@', 'fob_click', 3.0, 3.0, -1, 49, 0, false, false, false)TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 5, 'lock', 0.3)NetworkRequestControlOfEntity(veh)if vehLockStatus == 2 thenTriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1)QBCore.Functions.Notify(Lang:t('notify.vunlock'), 'success')endSetVehicleLights(veh, 2)Wait(250)SetVehicleLights(veh, 1)Wait(200)SetVehicleLights(veh, 0)Wait(300)ClearPedTasks(ped)endfunction ToggleVehicleTrunk(veh)if not veh then return endif isBlacklistedVehicle(veh) thenTriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1)returnendif not HasKeys(QBCore.Functions.GetPlate(veh)) and not AreKeysJobShared(veh) thenQBCore.Functions.Notify(Lang:t('notify.ydhk'), 'error')returnendlocal ped = PlayerPedId()local boot = GetEntityBoneIndexByName(GetVehiclePedIsIn(PlayerPedId(), false), 'boot')loadAnimDict('anim@mp_player_intmenu@key_fob@')TaskPlayAnim(ped, 'anim@mp_player_intmenu@key_fob@', 'fob_click', 3.0, 3.0, -1, 49, 0, false, false, false)TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 5, 'lock', 0.3)NetworkRequestControlOfEntity(veh)if boot == -1 and not DoesEntityExist(veh) then return endSetVehicleLights(veh, 2)Wait(150)SetVehicleLights(veh, 0)Wait(150)SetVehicleLights(veh, 2)Wait(150)SetVehicleLights(veh, 0)Wait(150)if trunkclose thenSetVehicleDoorOpen(veh, 5)elseSetVehicleDoorShut(veh, 5)endtrunkclose = not trunkcloseClearPedTasks(ped)endfunction GetOtherPlayersInVehicle(vehicle)local otherPeds = {}for seat = -1, GetVehicleModelNumberOfSeats(GetEntityModel(vehicle)) - 2 dolocal pedInSeat = GetPedInVehicleSeat(vehicle, seat)if IsPedAPlayer(pedInSeat) and pedInSeat ~= PlayerPedId() thenotherPeds[#otherPeds + 1] = pedInSeatendendreturn otherPedsendfunction GetPedsInVehicle(vehicle)local otherPeds = {}for seat = -1, GetVehicleModelNumberOfSeats(GetEntityModel(vehicle)) - 2 dolocal pedInSeat = GetPedInVehicleSeat(vehicle, seat)if not IsPedAPlayer(pedInSeat) and pedInSeat ~= 0 thenotherPeds[#otherPeds + 1] = pedInSeatendendreturn otherPedsendfunction IsBlacklistedWeapon()local weapon = GetSelectedPedWeapon(PlayerPedId())if weapon == nil then return false endfor _, v in pairs(Config.NoCarjackWeapons) doif weapon == joaat(v) thenreturn trueendendreturn falseendfunction Hotwire(vehicle, plate)local hotwireTime = math.random(Config.minHotwireTime, Config.maxHotwireTime)local ped = PlayerPedId()IsHotwiring = trueSetVehicleAlarm(vehicle, true)SetVehicleAlarmTimeLeft(vehicle, hotwireTime)QBCore.Functions.Progressbar('hotwire_vehicle', Lang:t('progress.hskeys'), hotwireTime, false, true, {disableMovement = true,disableCarMovement = true,disableMouse = false,disableCombat = true}, {animDict = 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@',anim = 'machinic_loop_mechandplayer',flags = 16}, {}, {}, function() -- DoneStopAnimTask(ped, 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@', 'machinic_loop_mechandplayer', 1.0)TriggerServerEvent('hud:server:GainStress', math.random(1, 4))if (math.random() <= Config.HotwireChance) thenTriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)elseQBCore.Functions.Notify(Lang:t('notify.fvlockpick'), 'error')endWait(Config.TimeBetweenHotwires)IsHotwiring = falseend, function() -- CancelStopAnimTask(ped, 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@', 'machinic_loop_mechandplayer', 1.0)IsHotwiring = falseend)SetTimeout(10000, function()AttemptPoliceAlert('steal')end)IsHotwiring = falseendfunction CarjackVehicle(target)if not Config.CarJackEnable then return endisCarjacking = truecanCarjack = falseloadAnimDict('mp_am_hold_up')local vehicle = GetVehiclePedIsUsing(target)local occupants = GetPedsInVehicle(vehicle)for p = 1, #occupants dolocal ped = occupants[p]CreateThread(function()TaskPlayAnim(ped, 'mp_am_hold_up', 'holdup_victim_20s', 8.0, -8.0, -1, 49, 0, false, false, false)PlayPain(ped, 6, 0)FreezeEntityPosition(vehicle, true)SetVehicleUndriveable(vehicle, true)end)Wait(math.random(200, 500))end-- Cancel progress bar if: Ped dies during robbery, car gets too far awayCreateThread(function()while isCarjacking dolocal distance = #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(target))if IsPedDeadOrDying(target) or distance > 7.5 thenTriggerEvent('progressbar:client:cancel')FreezeEntityPosition(vehicle, false)SetVehicleUndriveable(vehicle, false)endWait(100)endend)QBCore.Functions.Progressbar('rob_keys', Lang:t('progress.acjack'), Config.CarjackingTime, false, true, {}, {}, {}, {}, function()local hasWeapon, weaponHash = GetCurrentPedWeapon(PlayerPedId(), true)if not hasWeapon or not isCarjacking then return endlocal carjackChanceif Config.CarjackChance[tostring(GetWeapontypeGroup(weaponHash))] thencarjackChance = Config.CarjackChance[tostring(GetWeapontypeGroup(weaponHash))]elsecarjackChance = 0.5endif math.random() <= carjackChance thenlocal plate = QBCore.Functions.GetPlate(vehicle)for p = 1, #occupants dolocal ped = occupants[p]CreateThread(function()FreezeEntityPosition(vehicle, false)SetVehicleUndriveable(vehicle, false)TaskLeaveVehicle(ped, vehicle, 0)PlayPain(ped, 6, 0)Wait(1250)ClearPedTasksImmediately(ped)PlayPain(ped, math.random(7, 8), 0)MakePedFlee(ped)end)endTriggerServerEvent('hud:server:GainStress', math.random(1, 4))TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)elseQBCore.Functions.Notify(Lang:t('notify.cjackfail'), 'error')FreezeEntityPosition(vehicle, false)SetVehicleUndriveable(vehicle, false)MakePedFlee(target)TriggerServerEvent('hud:server:GainStress', math.random(1, 4))endisCarjacking = falseWait(2000)AttemptPoliceAlert('carjack')Wait(Config.DelayBetweenCarjackings)canCarjack = trueend, function()MakePedFlee(target)isCarjacking = falseWait(Config.DelayBetweenCarjackings)canCarjack = trueend)endfunction AttemptPoliceAlert(type)if AlertSend then return endlocal chance = Config.PoliceAlertChanceif GetClockHours() >= 1 and GetClockHours() <= 6 thenchance = Config.PoliceNightAlertChanceendif math.random() <= chance thenTriggerServerEvent('police:server:policeAlert', Lang:t('info.palert') .. type)endAlertSend = trueSetTimeout(Config.AlertCooldown, function()AlertSend = falseend)endfunction MakePedFlee(ped)SetPedFleeAttributes(ped, 0, 0)TaskReactAndFleePed(ped, PlayerPedId())endfunction DrawText3D(x, y, z, text)SetTextScale(0.35, 0.35)if GetConvar('qb_locale', 'en') == 'en' thenSetTextFont(4)elseSetTextFont(1)endSetTextProportional(1)SetTextColour(255, 255, 255, 215)SetTextEntry('STRING')SetTextCentre(true)AddTextComponentString(text)SetDrawOrigin(x, y, z, 0)DrawText(0.0, 0.0)local factor = (string.len(text)) / 370DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)ClearDrawOrigin()end--------------------------- NUICallback ---------------------------RegisterNUICallback('closui', function()SetNuiFocus(false, false)end)RegisterNUICallback('unlock', function()ToggleVehicleunLocks(GetVehicle())SetNuiFocus(false, false)end)RegisterNUICallback('lock', function()ToggleVehicleLocks(GetVehicle())SetNuiFocus(false, false)end)RegisterNUICallback('trunk', function()ToggleVehicleTrunk(GetVehicle())SetNuiFocus(false, false)end)RegisterNUICallback('engine', function()ToggleEngine(GetVehicle())SetNuiFocus(false, false)end) -
Create the Items.
shared/items.lua lockpick = { name = 'lockpick', label = 'Lockpick', weight = 300, type = 'item', image = 'lockpick.webp', unique = false, useable = true, shouldClose = true, description = 'Very useful if you lose your keys a lot.. or if you want to use it for something else...' },drill = { name = 'drill', label = 'Drill', weight = 20000, type = 'item', image = 'drill.webp', unique = false, useable = false, shouldClose = false, description = 'The real deal...' },rs_trackerblocker = { name = "rs_trackerblocker", label = "Tracker Blocker", weight = 0, type = "item", image = "rs_trackerblocker.webp", unique = true, useable = true, shouldClose = false, combinable = nil, description = "" },rs_doorhacker = { name = "rs_doorhacker", label = "Door Hacker", weight = 0, type = "item", image = "rs_doorhacker.webp", unique = true, useable = true, shouldClose = false, combinable = nil, description = "" },rs_tablet = { name = "rs_tablet", label = "Tablet", weight = 0, type = "item", image = "rs_tablet.webp", unique = true, useable = true, shouldClose = false, combinable = nil, description = "" }, -
Insert the db.sql file.
-
Place all the assets we provide as extras into the resources file and start.
-
Configure it to suit yourself.
-
Everythingโs ready, youโre all set.