Skip to content

Commit

Permalink
Preventing vehicles being started when player not inside (#201)
Browse files Browse the repository at this point in the history
* added a check

added check if you are in the car to turn it on and off|

so if you are now outside the car, you cannot switch the car on and off with g, only with the keyfob

* Reinstate error message

* Whoopsie

* Update main.lua

* Bump

---------

Co-authored-by: zwkf <[email protected]>
  • Loading branch information
djraymond and S33G authored Feb 24, 2023
1 parent 9c85663 commit 8d163ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,12 @@ RegisterCommand('togglelocks', function()
end)
RegisterKeyMapping('engine', Lang:t("info.engine"), 'keyboard', 'G')
RegisterCommand('engine', function()
ToggleEngine(GetVehicle())
local vehicle = GetVehicle()
if vehicle and IsPedInVehicle(PlayerPedId(), vehicle) then
ToggleEngine(vehicle)
end
end)

AddEventHandler('onResourceStart', function(resourceName)
if resourceName == GetCurrentResourceName() and QBCore.Functions.GetPlayerData() ~= {} then
GetKeys()
Expand Down Expand Up @@ -386,7 +390,8 @@ function GetVehicle()
vehicle = QBCore.Functions.GetClosestVehicle()
if #(pos - GetEntityCoords(vehicle)) > 8 then
QBCore.Functions.Notify(Lang:t("notify.vehclose"), "error")
return end
return
end
end

if not IsEntityAVehicle(vehicle) then vehicle = nil end
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fx_version 'cerulean'
game 'gta5'
description 'QB-VehicleKeys'
version '1.2.4'
version '1.2.5'
ui_page 'NUI/index.html'

files {
Expand Down

0 comments on commit 8d163ce

Please sign in to comment.