112 lines
4.2 KiB
Lua
112 lines
4.2 KiB
Lua
RegisterNetEvent("advancedgarages:client:radialOpenMenu")
|
|
AddEventHandler("advancedgarages:client:radialOpenMenu", function()
|
|
local garageData = Config.Garages[ClosestGarage]
|
|
OpenGarageMenu(ClosestGarage, garageData.isImpound, nil, garageData.type == "boat")
|
|
end)
|
|
|
|
RegisterNetEvent("advancedgarages:client:radialEnterShell")
|
|
AddEventHandler("advancedgarages:client:radialEnterShell", function()
|
|
local garageData = Config.Garages[ClosestGarage]
|
|
GotoShellGarage(ClosestGarage, garageData.coords.spawnCoords, garageData.shell)
|
|
end)
|
|
|
|
RegisterNetEvent("advancedgarages:client:radialExitShell")
|
|
AddEventHandler("advancedgarages:client:radialExitShell", function()
|
|
ExitGarage()
|
|
end)
|
|
|
|
RegisterNetEvent("advancedgarages:client:radialSaveVehicle")
|
|
AddEventHandler("advancedgarages:client:radialSaveVehicle", function(data)
|
|
local isJob = data.isJob
|
|
local targetGarage = data.garage
|
|
local currentVehicle = cache.vehicle
|
|
local plate = GetPlate(currentVehicle)
|
|
local isOwned = isJob
|
|
|
|
if not isJob then
|
|
isOwned = lib.callback.await("advancedgarages:isVehicleOwned", false, plate)
|
|
end
|
|
|
|
if isJob then
|
|
return saveJobVehicle(IsNearbyJobGarage(), currentVehicle)
|
|
end
|
|
|
|
if not isOwned then
|
|
return Notification(i18n.t("no_vehicle_owner"), "error")
|
|
end
|
|
|
|
SaveVehicle(targetGarage, nil, currentVehicle)
|
|
end)
|
|
|
|
local function GetCurrentShellGarageData()
|
|
if not CurrentShellGarage or not existKey then return nil, nil end
|
|
local shellData = ShellGarages[CurrentShellGarage]
|
|
if not shellData then return nil, nil end
|
|
return shellData.takeVehicle, shellData.shell
|
|
end
|
|
|
|
RegisterNetEvent("advancedgarages:client:radialEnterHousingGarage")
|
|
AddEventHandler("advancedgarages:client:radialEnterHousingGarage", function()
|
|
local takeVehicleCoords, shellId = GetCurrentShellGarageData()
|
|
if not takeVehicleCoords then return end
|
|
|
|
nearbyGarageType = "vehicle"
|
|
local heading = takeVehicleCoords.h or takeVehicleCoords.w
|
|
GotoGarage(CurrentShellGarage, vec4(takeVehicleCoords.x, takeVehicleCoords.y, takeVehicleCoords.z, heading), shellId)
|
|
end)
|
|
|
|
RegisterNetEvent("advancedgarages:client:radialSaveHousingGarage")
|
|
AddEventHandler("advancedgarages:client:radialSaveHousingGarage", function()
|
|
local takeVehicleCoords, shellId = GetCurrentShellGarageData()
|
|
if not takeVehicleCoords then return end
|
|
|
|
nearbyGarageType = "vehicle"
|
|
local saved = SaveVehicle(CurrentShellGarage, true)
|
|
if saved then
|
|
local heading = takeVehicleCoords.h or takeVehicleCoords.w
|
|
GotoGarage(CurrentShellGarage, vec4(takeVehicleCoords.x, takeVehicleCoords.y, takeVehicleCoords.z, heading), shellId)
|
|
end
|
|
end)
|
|
|
|
RegisterNetEvent("advancedgarages:client:radialGarageManagement")
|
|
AddEventHandler("advancedgarages:client:radialGarageManagement", function()
|
|
OpenManagementMenu()
|
|
end)
|
|
|
|
RegisterNetEvent("advancedgarages:client:radialRecoverVehicle")
|
|
AddEventHandler("advancedgarages:client:radialRecoverVehicle", function()
|
|
local recoveryVehicles = lib.callback.await("advancedgarages:getRecoveryVehicles", false)
|
|
if #recoveryVehicles == 0 then
|
|
return Notification(i18n.t("keyholders.empty_out"), "info")
|
|
end
|
|
OpenRecoveryMenu(recoveryVehicles)
|
|
end)
|
|
|
|
RegisterNetEvent("advancedgarages:client:radialImpoundVehicle")
|
|
AddEventHandler("advancedgarages:client:radialImpoundVehicle", function()
|
|
ImpoundVehicle()
|
|
end)
|
|
|
|
RegisterNetEvent("advancedgarages:client:radialOpenJobGarage")
|
|
AddEventHandler("advancedgarages:client:radialOpenJobGarage", function(data)
|
|
local jobGarageData = Config.JobGarages[data.garage]
|
|
local jobOrGang = jobGarageData.job or jobGarageData.gang
|
|
|
|
local vehicleList = lib.callback.await("advancedgarages:getJobVehicles", false, jobGarageData.name, jobOrGang)
|
|
|
|
for _, vehicleEntry in pairs(vehicleList) do
|
|
vehicleEntry.vehicle = json.encode(vehicleEntry.vehicle)
|
|
end
|
|
|
|
for _, vehicleModel in ipairs(jobGarageData.vehicles) do
|
|
local plate = tostring(jobOrGang .. math.random(111, 999))
|
|
table.insert(vehicleList, {
|
|
id = #vehicleList + 1,
|
|
vehicle = json.encode({ model = vehicleModel, plate = plate }),
|
|
plate = plate
|
|
})
|
|
end
|
|
|
|
OpenGarageMenu(data.garage, false, vehicleList)
|
|
end)
|