diff --git a/client/main.lua b/client/main.lua index 6c1151d..f7acbd1 100644 --- a/client/main.lua +++ b/client/main.lua @@ -26,7 +26,7 @@ CreateThread(function() local plate = GetPlate(entering) local driver = GetPedInVehicleSeat(entering, -1) - for _, veh in ipairs(Config.ImmuneVehicles) do + for _, veh in ipairs(Config.immuneVehicles) do if GetEntityModel(entering) == joaat(veh) then carIsImmune = true end @@ -54,7 +54,7 @@ CreateThread(function() isTakingKeys = false end end - elseif Config.LockNPCDrivingCars then + elseif Config.lockNPCDrivingCars then TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 2) else TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1) @@ -70,7 +70,7 @@ CreateThread(function() end -- Parked car logic elseif driver == 0 and entering ~= lastPickedVehicle and not HasKeys(plate) and not isTakingKeys then - if Config.LockNPCParkedCars then + if Config.lockNPCParkedCars then TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 2) else TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1) @@ -96,12 +96,12 @@ CreateThread(function() end end - if Config.CarJackEnable and canCarjack then + if Config.carJackEnable and canCarjack then local aiming, target = GetEntityPlayerIsFreeAimingAt(cache.playerId) if aiming and (target ~= nil and target ~= 0) then if DoesEntityExist(target) and IsPedInAnyVehicle(target, false) and not IsEntityDead(target) and not IsPedAPlayer(target) then local targetveh = GetVehiclePedIsIn(target) - for _, veh in ipairs(Config.ImmuneVehicles) do + for _, veh in ipairs(Config.immuneVehicles) do if GetEntityModel(targetveh) == joaat(veh) then carIsImmune = true end @@ -123,7 +123,7 @@ end) function isBlacklistedVehicle(vehicle) local isBlacklisted = false - for _,v in ipairs(Config.NoLockVehicles) do + for _,v in ipairs(Config.noLockVehicles) do if joaat(v) == GetEntityModel(vehicle) then isBlacklisted = true break; @@ -281,9 +281,9 @@ end function AreKeysJobShared(veh) local vehName = GetDisplayNameFromVehicleModel(GetEntityModel(veh)) local vehPlate = GetVehicleNumberPlateText(veh) - for job, v in pairs(Config.SharedKeys) do + for job, v in pairs(Config.sharedKeys) do if job == QBX.PlayerData.job.name then - if Config.SharedKeys[job].requireOnduty and not QBX.PlayerData.job.onduty then return false end + if Config.sharedKeys[job].requireOnduty and not QBX.PlayerData.job.onduty then return false end for _, vehicle in pairs(v.vehicles) do if string.upper(vehicle) == string.upper(vehName) then if not HasKeys(vehPlate) then @@ -357,7 +357,7 @@ end function IsBlacklistedWeapon() local weapon = GetSelectedPedWeapon(cache.ped) if weapon ~= nil then - for _, v in pairs(Config.NoCarjackWeapons) do + for _, v in pairs(Config.noCarjackWeapons) do if weapon == joaat(v) then return true end @@ -409,11 +409,11 @@ function LockpickFinishCallback(success) end if usingAdvanced then - if chance <= Config.RemoveLockpickAdvanced then + if chance <= Config.removeLockpickAdvanced[GetVehicleClass(vehicle)] then TriggerServerEvent("qb-vehiclekeys:server:breakLockpick", "advancedlockpick") end else - if chance <= Config.RemoveLockpickNormal then + if chance <= Config.removeLockpickNormal[GetVehicleClass(vehicle)] then TriggerServerEvent("qb-vehiclekeys:server:breakLockpick", "lockpick") end end @@ -442,13 +442,13 @@ function Hotwire(vehicle, plate) } }) then StopAnimTask(cache.ped, "anim@amb@clubhouse@tutorial@bkr_tut_ig3@", "machinic_loop_mechandplayer", 1.0) - if (math.random() <= Config.HotwireChance) then + if (math.random() <= Config.hotwireChance[GetVehicleClass(vehicle)]) then TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate) else TriggerServerEvent('hud:server:GainStress', math.random(1, 4)) exports.qbx_core:Notify(Lang:t("notify.failed_lockedpick"), 'error') end - Wait(Config.TimeBetweenHotwires) + Wait(Config.timeBetweenHotwires) isHotwiring = false else StopAnimTask(cache.ped, "anim@amb@clubhouse@tutorial@bkr_tut_ig3@", "machinic_loop_mechandplayer", 1.0) @@ -461,7 +461,7 @@ function Hotwire(vehicle, plate) end function CarjackVehicle(target) - if not Config.CarJackEnable then return end + if not Config.carJackEnable then return end isCarjacking = true canCarjack = false lib.requestAnimDict('mp_am_hold_up') @@ -487,7 +487,7 @@ function CarjackVehicle(target) end) if lib.progressCircle({ - duration = Config.CarjackingTime, + duration = Config.carjackingTime, label = Lang:t("progress.attempting_carjack"), position = 'bottom', useWhileDead = false, @@ -499,8 +499,8 @@ function CarjackVehicle(target) local hasWeapon, weaponHash = GetCurrentPedWeapon(cache.ped, true) if hasWeapon and isCarjacking then local carjackChance - if Config.CarjackChance[tostring(GetWeapontypeGroup(weaponHash))] then - carjackChance = Config.CarjackChance[tostring(GetWeapontypeGroup(weaponHash))] + if Config.carjackChance[tostring(GetWeapontypeGroup(weaponHash))] then + carjackChance = Config.carjackChance[tostring(GetWeapontypeGroup(weaponHash))] else carjackChance = 0.5 end @@ -527,28 +527,28 @@ function CarjackVehicle(target) isCarjacking = false Wait(2000) AttemptPoliceAlert("carjack") - Wait(Config.DelayBetweenCarjackings) + Wait(Config.delayBetweenCarjackings) canCarjack = true end else MakePedFlee(target) isCarjacking = false - Wait(Config.DelayBetweenCarjackings) + Wait(Config.delayBetweenCarjackings) canCarjack = true end end function AttemptPoliceAlert(type) if not alertSend then - local chance = Config.PoliceAlertChance + local chance = Config.policeAlertChance if GetClockHours() >= 1 and GetClockHours() <= 6 then - chance = Config.PoliceNightAlertChance + chance = Config.policeNightAlertChance end if math.random() <= chance then TriggerServerEvent('police:server:policeAlert', Lang:t("info.vehicle_theft") .. type) end alertSend = true - SetTimeout(Config.AlertCooldown, function() + SetTimeout(Config.alertCooldown, function() alertSend = false end) end diff --git a/config.lua b/config.lua index 2696d0d..0f99720 100644 --- a/config.lua +++ b/config.lua @@ -1,95 +1,174 @@ -Config = {} +Config = { + debug = true, -- Set to true for development purposes only. Used for zones, and essential prints. Will be removed upon release --- NPC Vehicle Lock States -Config.LockNPCDrivingCars = true -- Lock state for NPC cars being driven by NPCs [true = locked, false = unlocked] -Config.LockNPCParkedCars = true -- Lock state for NPC parked cars [true = locked, false = unlocked] + vehicleMaximumLockingDistance = 5.0, -- Minimum distance for vehicle locking --- Lockpick Settings -Config.RemoveLockpickNormal = 0.5 -- Chance to remove lockpick on fail -Config.RemoveLockpickAdvanced = 0.2 -- Chance to remove advanced lockpick on fail + -- NPC Vehicle Lock States + lockNPCDrivenCars = true, -- Lock state for NPC cars being driven by NPCs [true = locked, false = unlocked] + lockNPCParkedCars = true, -- Lock state for NPC parked cars [true = locked, false = unlocked] --- Carjack Settings -Config.CarJackEnable = true -- True allows for the ability to car jack peds. -Config.CarjackingTime = 7500 -- How long it takes to carjack -Config.DelayBetweenCarjackings = 10000 -- Time before you can carjack again -Config.CarjackChance = { - ['2685387236'] = 0.0, -- melee - ['416676503'] = 0.5, -- handguns - ['-957766203'] = 0.75, -- SMG - ['860033945'] = 0.90, -- shotgun - ['970310034'] = 0.90, -- assault - ['1159398588'] = 0.99, -- LMG - ['3082541095'] = 0.99, -- sniper - ['2725924767'] = 0.99, -- heavy - ['1548507267'] = 0.0, -- throwable - ['4257178988'] = 0.0, -- misc -} + -- Lockpick Settings + removeNormalLockpickChance = { -- Chance to remove lockpick on fail by vehicle class + [0] = 0.5, -- Compacts + [1] = 0.5, -- Sedans + [2] = 0.5, -- SUVs + [3] = 0.5, -- Coupes + [4] = 0.5, -- Muscle + [5] = 0.5, -- Sports Classics + [6] = 0.5, -- Sports + [7] = 0.5, -- Super + [8] = 0.5, -- Motorcycles + [9] = 0.5, -- Off-road + [10] = 0.5, -- Industrial + [11] = 0.5, -- Utility + [12] = 0.5, -- Vans + [13] = 0.5, -- Cycles + [14] = 0.5, -- Boats + [15] = 0.5, -- Helicopters + [16] = 0.5, -- Planes + [17] = 0.5, -- Service + [18] = 0.5, -- Emergency + [19] = 0.5, -- Military + [20] = 0.5, -- Commercial + [21] = 0.5, -- Trains + [22] = 0.5, -- Open Wheel + }, + removeLockpickAdvanced = { -- Chance to remove advanced lockpick on fail by vehicle class + [0] = 0.5, -- Compacts + [1] = 0.5, -- Sedans + [2] = 0.5, -- SUVs + [3] = 0.5, -- Coupes + [4] = 0.5, -- Muscle + [5] = 0.5, -- Sports Classics + [6] = 0.5, -- Sports + [7] = 0.5, -- Super + [8] = 0.5, -- Motorcycles + [9] = 0.5, -- Off-road + [10] = 0.5, -- Industrial + [11] = 0.5, -- Utility + [12] = 0.5, -- Vans + [13] = 0.5, -- Cycles + [14] = 0.5, -- Boats + [15] = 0.5, -- Helicopters + [16] = 0.5, -- Planes + [17] = 0.5, -- Service + [18] = 0.5, -- Emergency + [19] = 0.5, -- Military + [20] = 0.5, -- Commercial + [21] = 0.5, -- Trains + [22] = 0.5, -- Open Wheel + }, --- Hotwire Settings -Config.HotwireChance = 0.5 -- Chance for successful hotwire or not -Config.TimeBetweenHotwires = 5000 -- Time in ms between hotwire attempts -Config.minHotwireTime = 20000 -- Minimum hotwire time in ms -Config.maxHotwireTime = 40000 -- Maximum hotwire time in ms + -- Carjack Settings + carjackEnable = true, -- Enables the ability to carjack pedestrian vehicles, stealing them by pointing a weapon at them + carjackingTimeInMs = 7500, -- Time it takes to successfully carjack in miliseconds + delayBetweenCarjackingsInMs = 10000, -- Time before you can attempt another carjack in miliseconds + carjackChance = { -- Probability of successful carjacking based on weapon used + [2685387236] = 0.0, -- melee + [416676503] = 0.5, -- handguns + [-957766203] = 0.75, -- SMG + [860033945] = 0.90, -- shotgun + [970310034] = 0.90, -- assault + [1159398588] = 0.99, -- LMG + [3082541095] = 0.99, -- sniper + [2725924767] = 0.99, -- heavy + [1548507267] = 0.0, -- throwable + [4257178988] = 0.0, -- misc + -- Add more weapon IDs and probabilities as needed + }, + + -- Hotwire Settings + hotwireChance = { + [0] = 0.5, -- Compacts + [1] = 0.5, -- Sedans + [2] = 0.5, -- SUVs + [3] = 0.5, -- Coupes + [4] = 0.5, -- Muscle + [5] = 0.5, -- Sports Classics + [6] = 0.5, -- Sports + [7] = 0.5, -- Super + [8] = 0.5, -- Motorcycles + [9] = 0.5, -- Off-road + [10] = 0.5, -- Industrial + [11] = 0.5, -- Utility + [12] = 0.5, -- Vans + [13] = 0.5, -- Cycles + [14] = 0.5, -- Boats + [15] = 0.5, -- Helicopters + [16] = 0.5, -- Planes + [17] = 0.5, -- Service + [18] = 0.5, -- Emergency + [19] = 0.5, -- Military + [20] = 0.5, -- Commercial + [21] = 0.5, -- Trains + [22] = 0.5, -- Open Wheel + }, -- Chance for a successful hotwire by vehicle Class + timeBetweenHotwires = 5000, -- Time in milliseconds between hotwire attempts + minHotwireTime = 20000, -- Minimum hotwire time in milliseconds + maxHotwireTime = 40000, -- Maximum hotwire time in milliseconds --- Police Alert Settings -Config.AlertCooldown = 10000 -- 10 seconds -Config.PoliceAlertChance = 0.75 -- Chance of alerting police during the day -Config.PoliceNightAlertChance = 0.50 -- Chance of alerting police at night (times:01-06) + -- Police Alert Settings + alertCooldown = 10000, -- Cooldown period in milliseconds (10 seconds) + policeAlertChance = 0.75, -- Chance of alerting the police during the day + policeNightAlertChance = 0.50, -- Chance of alerting the police at night (times: 01-06) --- Job Settings -Config.SharedKeys = { -- Share keys amongst employees. Employees can lock/unlock any job-listed vehicle - ['police'] = { -- Job name - requireOnduty = false, - vehicles = { - 'police', -- Vehicle model - 'police2', -- Vehicle model + -- Job Settings + sharedKeys = { -- Share keys amongst employees. Employees can lock/unlock any job-listed vehicle + ['police'] = { -- Job name + requireOnduty = false, + vehicles = { + 'police', -- Vehicle model + 'police2', -- Vehicle model + } + }, + ['mechanic'] = { + requireOnduty = false, + vehicles = { + 'towtruck', + } } }, - ['mechanic'] = { - requireOnduty = false, - vehicles = { - 'towtruck', - } - } -} + -- Vehicles that cannot be jacked + immuneVehicles = { + 'stockade' + }, --- These vehicles cannot be jacked -Config.ImmuneVehicles = { - 'stockade' -} + -- Vehicles that will never lock + noLockVehicles = { --- These vehicles will never lock -Config.NoLockVehicles = {} + }, --- These weapons cannot be used for carjacking -Config.NoCarjackWeapons = { - "WEAPON_UNARMED", - "WEAPON_Knife", - "WEAPON_Nightstick", - "WEAPON_HAMMER", - "WEAPON_Bat", - "WEAPON_Crowbar", - "WEAPON_Golfclub", - "WEAPON_Bottle", - "WEAPON_Dagger", - "WEAPON_Hatchet", - "WEAPON_KnuckleDuster", - "WEAPON_Machete", - "WEAPON_Flashlight", - "WEAPON_SwitchBlade", - "WEAPON_Poolcue", - "WEAPON_Wrench", - "WEAPON_Battleaxe", - "WEAPON_Grenade", - "WEAPON_StickyBomb", - "WEAPON_ProximityMine", - "WEAPON_BZGas", - "WEAPON_Molotov", - "WEAPON_FireExtinguisher", - "WEAPON_PetrolCan", - "WEAPON_Flare", - "WEAPON_Ball", - "WEAPON_Snowball", - "WEAPON_SmokeGrenade", + -- Weapons that cannot be used for carjacking + noCarjackWeapons = { + "WEAPON_UNARMED", + "WEAPON_KNIFE", + "WEAPON_NIGHTSTICK", + "WEAPON_HAMMER", + "WEAPON_BAT", + "WEAPON_CROWBAR", + "WEAPON_GOLFCLUB", + "WEAPON_BOTTLE", + "WEAPON_DAGGER", + "WEAPON_HATCHET", + "WEAPON_KNUCKLE", + "WEAPON_MACHETE", + "WEAPON_FLASHLIGHT", + "WEAPON_SWITCHBLADE", + "WEAPON_POOLCUE", + "WEAPON_WRENCH", + "WEAPON_BATTLEAXE", + "WEAPON_GRENADE", + "WEAPON_STOCKYBOMB", + "WEAPON_PROXIMITYMINE", + "WEAPON_BZGAS", + "WEAPON_MOLOTOV", + "WEAPON_FIREEXTINGUISHER", + "WEAPON_PETROLCAN", + "WEAPON_FLARE", + "WEAPON_BALL", + "WEAPON_SNOWBALL", + "WEAPON_SMOKEGRENADE", + -- Add more weapon names as needed + } } diff --git a/fxmanifest.lua b/fxmanifest.lua index de60532..8ad7f55 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -22,4 +22,4 @@ client_scripts { server_script 'server/main.lua' lua54 'yes' -use_experimental_fxv2_oal 'yes' \ No newline at end of file +use_experimental_fxv2_oal 'yes'