Merge pull request #57 from ND-Framework/fix/driving-locked-vehicle

fix(client/vehicle): vehicle keys issues
This commit is contained in:
Andy
2024-01-16 23:31:40 +01:00
committed by GitHub
2 changed files with 29 additions and 15 deletions

View File

@@ -10,8 +10,9 @@ Config = {
discordActionLink = GetConvar("discordActionLink", "https://discord.gg/Z9Mxu72zZ6"), discordActionLink = GetConvar("discordActionLink", "https://discord.gg/Z9Mxu72zZ6"),
discordActionText2 = GetConvar("core:discordActionText2", "STORE"), discordActionText2 = GetConvar("core:discordActionText2", "STORE"),
discordActionLink2 = GetConvar("core:discordActionLink2", "https://andyyy.tebex.io/category/fivem-scripts"), discordActionLink2 = GetConvar("core:discordActionLink2", "https://andyyy.tebex.io/category/fivem-scripts"),
randomUnlockedVehicleChance = GetConvarInt("core:randomUnlockedVehicleChance", 30),
disableVehicleAirControl = GetConvarInt("core:disableVehicleAirControl", 1) == 1, disableVehicleAirControl = GetConvarInt("core:disableVehicleAirControl", 1) == 1,
randomUnlockedVehicleChance = GetConvarInt("core:randomUnlockedVehicleChance", 30),
requireKeys = GetConvarInt("core:requireKeys", 1) == 1,
useInventoryForKeys = GetConvarInt("core:useInventoryForKeys", 1) == 1, useInventoryForKeys = GetConvarInt("core:useInventoryForKeys", 1) == 1,
groups = json.decode(GetConvar("core:groups", "[]")), groups = json.decode(GetConvar("core:groups", "[]")),
compatibility = json.decode(GetConvar("core:compatibility", "[]")) compatibility = json.decode(GetConvar("core:compatibility", "[]"))

View File

@@ -480,22 +480,35 @@ CreateThread(function()
local wait = 500 local wait = 500
while true do while true do
Wait(wait) Wait(wait)
local reset = true
playerVehicle = cache.seat == -1 and cache.vehicle playerVehicle = cache.seat == -1 and cache.vehicle
if playerVehicle then
local entering = GetVehiclePedIsEntering(cache.ped)
if entering and DoesEntityExist(entering) and IsVehicleNeedsToBeHotwired(entering) then
SetVehicleNeedsToBeHotwired(entering, false)
end
if not playerVehicle then goto skip end
if Config.disableVehicleAirControl and not vehicleClassNotDisableAirControl[GetVehicleClass(playerVehicle)] and (IsEntityInAir(playerVehicle) or IsEntityUpsidedown(playerVehicle)) then if Config.disableVehicleAirControl and not vehicleClassNotDisableAirControl[GetVehicleClass(playerVehicle)] and (IsEntityInAir(playerVehicle) or IsEntityUpsidedown(playerVehicle)) then
wait = 0 wait = 0
reset = false
DisableControlAction(0, 59) -- disable vehicle air control. DisableControlAction(0, 59) -- disable vehicle air control.
DisableControlAction(0, 60) DisableControlAction(0, 60)
elseif not GetIsVehicleEngineRunning(playerVehicle) and not hasVehicleKeysCheck(playerVehicle) then end
if Config.requireKeys and not GetIsVehicleEngineRunning(playerVehicle) and not hasVehicleKeysCheck(playerVehicle) then
wait = 0 wait = 0
reset = false
DisableControlAction(0, 59) DisableControlAction(0, 59)
DisableControlAction(0, 71)
if DoesEntityExist(playerVehicle) and IsVehicleEngineStarting(playerVehicle) then if DoesEntityExist(playerVehicle) and IsVehicleEngineStarting(playerVehicle) then
SetVehicleEngineOn(playerVehicle, false, true, true) -- don't turn on engine if no keys. SetVehicleEngineOn(playerVehicle, false, true, true) -- don't turn on engine if no keys.
end end
else
wait = 500
end end
elseif wait ~= 500 then
::skip::
if (reset or not playerVehicle) and wait ~= 500 then
wait = 500 wait = 500
end end
end end