Skip to content

Commit

Permalink
Fix issue #112, #113
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangducvn committed Apr 12, 2022
1 parent a8ef759 commit 5653f8d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ end)
local garaIndex = nil
local function SetupGaragesMenu()
local isingarage, canStoreVehicle = exports["MojiaGarages"]:IsInGarage()
local isInJobGarage, lastJobVehicle = exports["MojiaGarages"]:isInJobStation(PlayerData.job.name)
local GaragesMenu = {
id = 'garages',
title = 'Garages',
Expand All @@ -419,7 +420,7 @@ local function SetupGaragesMenu()
icon = 'warehouse',
type = 'client',
event = 'MojiaGarages:client:openGarage',
shouldClose = false,
shouldClose = true,
}
local veh = nil
local ped = PlayerPedId()
Expand All @@ -443,7 +444,46 @@ local function SetupGaragesMenu()
icon = 'parking',
type = 'client',
event = 'MojiaGarages:client:storeVehicle',
shouldClose = false,
shouldClose = true,
}
end
end
end
end
if isInJobGarage then
if lastJobVehicle == nil then
GaragesMenu.items[#GaragesMenu.items+1] = {
id = 'openjobgarage',
title = 'Open Job Garage',
icon = 'warehouse',
type = 'client',
event = 'MojiaGarages:client:openJobVehList',
shouldClose = true,
}
else
local veh = nil
local ped = PlayerPedId()
local pos = GetEntityCoords(ped)
local vehout, distance = QBCore.Functions.GetClosestVehicle(pos)
local vehin = IsPedInAnyVehicle(ped, true)
if vehin then
veh = GetVehiclePedIsIn(ped)
else
if NetworkGetEntityIsLocal(vehout) and distance <= 5 then
veh = vehout
end
end
if veh ~= nil and veh == lastJobVehicle then
local plate = QBCore.Functions.GetPlate(veh)
if exports["qb-vehiclekeys"]:HasVehicleKey(plate) then --disable if use MojiaVehicleKeys
--if exports['MojiaVehicleKeys']:CheckHasKey(plate) then --enable if use MojiaVehicleKeys
GaragesMenu.items[#GaragesMenu.items+1] = {
id = 'hidejobvehicle',
title = 'Hide Job Vehicle',
icon = 'parking',
type = 'client',
event = 'MojiaGarages:client:HideJobVeh',
shouldClose = true,
}
end
end
Expand Down
7 changes: 5 additions & 2 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,10 @@ function SpawnVehicles(vehdata)
QBCore.Functions.SpawnVehicle(vehdata.model, function(veh)
SetVehicleModifications(veh, vehdata.mods)
SetEntityRotation(veh, vehdata.rotation)
exports['LegacyFuel']:SetFuel(veh, vehdata.mods.fuelLevel)
exports['LegacyFuel']:SetFuel(veh, vehdata.mods.fuelLevel)
if not UsingMojiaVehiclekeys then
TriggerServerEvent('MojiaGarages:server:updateVehicleKey')
end
end, vehdata.position, true)
end
end)
Expand Down Expand Up @@ -1705,4 +1708,4 @@ end)
-- export

exports('IsInGarage', IsInGarage)
exports('isInJobStation', isInJobStation)
exports('isInJobStation', isInJobStation)
4 changes: 3 additions & 1 deletion server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -698,4 +698,6 @@ RegisterNetEvent('MojiaGarages:server:refreshVehicles', function()
RefreshVehicles()
end)


RegisterNetEvent('MojiaGarages:server:updateVehicleKey', function()
TriggerClientEvent('MojiaGarages:client:updateVehicleKey', -1, plate) -- Update vehicle key for qb-vehiclekey
end)

0 comments on commit 5653f8d

Please sign in to comment.