diff --git a/client/job.lua b/client/job.lua
index c2d8b9f1..2dbeaf01 100644
--- a/client/job.lua
+++ b/client/job.lua
@@ -1,7 +1,7 @@
local CurrentAction, CurrentActionMsg, CurrentActionData = nil, '', {}
local HasAlreadyEnteredMarker, LastHospital, LastPart, LastPartNum
local isBusy, deadPlayers, deadPlayerBlips, isOnDuty = false, {}, {}, false
-local spawnedVehicles, isInShopMenu = {}, false
+isInShopMenu = false
function OpenAmbulanceActionsMenu()
local elements = {
@@ -365,9 +365,9 @@ Citizen.CreateThread(function()
elseif CurrentAction == 'Pharmacy' then
OpenPharmacyMenu()
elseif CurrentAction == 'Vehicles' then
- OpenVehicleSpawnerMenu(CurrentActionData.hospital, CurrentActionData.partNum)
+ OpenVehicleSpawnerMenu('car', CurrentActionData.hospital, CurrentAction, CurrentActionData.partNum)
elseif CurrentAction == 'Helicopters' then
- OpenHelicopterSpawnerMenu(CurrentActionData.hospital, CurrentActionData.partNum)
+ OpenVehicleSpawnerMenu('helicopter', CurrentActionData.hospital, CurrentAction, CurrentActionData.partNum)
elseif CurrentAction == 'FastTravelsPrompt' then
FastTravel(CurrentActionData.to, CurrentActionData.heading)
end
@@ -446,388 +446,6 @@ function OpenCloakroomMenu()
end)
end
-function OpenVehicleSpawnerMenu(hospital, partNum)
- local playerCoords = GetEntityCoords(PlayerPedId())
- local elements = {
- {label = _U('garage_storeditem'), action = 'garage'},
- {label = _U('garage_storeitem'), action = 'store_garage'},
- {label = _U('garage_buyitem'), action = 'buy_vehicle'}
- }
-
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle', {
- title = _U('garage_title'),
- align = 'top-left',
- elements = elements
- }, function(data, menu)
- if data.current.action == 'buy_vehicle' then
- local shopCoords = Config.Hospitals[hospital].Vehicles[partNum].InsideShop
- local shopElements = {}
- local authorizedVehicles = Config.AuthorizedVehicles[ESX.PlayerData.job.grade_name]
-
- if #authorizedVehicles > 0 then
- for k,vehicle in ipairs(authorizedVehicles) do
- table.insert(shopElements, {
- label = ('%s - %s'):format(vehicle.label, _U('shop_item', ESX.Math.GroupDigits(vehicle.price))),
- name = vehicle.label,
- model = vehicle.model,
- price = vehicle.price,
- type = 'car'
- })
- end
-
- OpenShopMenu(shopElements, playerCoords, shopCoords)
- end
- elseif data.current.action == 'garage' then
- local garage = {}
-
- ESX.TriggerServerCallback('esx_vehicleshop:retrieveJobVehicles', function(jobVehicles)
- if #jobVehicles > 0 then
- for k,v in ipairs(jobVehicles) do
- local props = json.decode(v.vehicle)
- local vehicleName = GetLabelText(GetDisplayNameFromVehicleModel(props.model))
- local label = ('%s - %s: '):format(vehicleName, props.plate)
-
- if v.stored then
- label = label .. ('%s'):format(_U('garage_stored'))
- else
- label = label .. ('%s'):format(_U('garage_notstored'))
- end
-
- table.insert(garage, {
- label = label,
- stored = v.stored,
- model = props.model,
- vehicleProps = props
- })
- end
-
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_garage', {
- title = _U('garage_title'),
- align = 'top-left',
- elements = garage
- }, function(data2, menu2)
- if data2.current.stored then
- local foundSpawn, spawnPoint = GetAvailableVehicleSpawnPoint(hospital, 'Vehicles', partNum)
-
- if foundSpawn then
- menu2.close()
-
- ESX.Game.SpawnVehicle(data2.current.model, spawnPoint.coords, spawnPoint.heading, function(vehicle)
- ESX.Game.SetVehicleProperties(vehicle, data2.current.vehicleProps)
-
- TriggerServerEvent('esx_vehicleshop:setJobVehicleState', data2.current.vehicleProps.plate, false)
- ESX.ShowNotification(_U('garage_released'))
- end)
- end
- else
- ESX.ShowNotification(_U('garage_notavailable'))
- end
- end, function(data2, menu2)
- menu2.close()
- end)
- else
- ESX.ShowNotification(_U('garage_empty'))
- end
- end, 'car')
- elseif data.current.action == 'store_garage' then
- StoreNearbyVehicle(playerCoords)
- end
- end, function(data, menu)
- menu.close()
- end)
-end
-
-function StoreNearbyVehicle(playerCoords)
- local vehicles, vehiclePlates = ESX.Game.GetVehiclesInArea(playerCoords, 30.0), {}
-
- if #vehicles > 0 then
- for k,v in ipairs(vehicles) do
-
- -- Make sure the vehicle we're saving is empty, or else it wont be deleted
- if GetVehicleNumberOfPassengers(v) == 0 and IsVehicleSeatFree(v, -1) then
- table.insert(vehiclePlates, {
- vehicle = v,
- plate = ESX.Math.Trim(GetVehicleNumberPlateText(v))
- })
- end
- end
- else
- ESX.ShowNotification(_U('garage_store_nearby'))
- return
- end
-
- ESX.TriggerServerCallback('esx_ambulancejob:storeNearbyVehicle', function(storeSuccess, foundNum)
- if storeSuccess then
- local vehicleId = vehiclePlates[foundNum]
- local attempts = 0
- ESX.Game.DeleteVehicle(vehicleId.vehicle)
- isBusy = true
-
- Citizen.CreateThread(function()
- while isBusy do
- Citizen.Wait(0)
- drawLoadingText(_U('garage_storing'), 255, 255, 255, 255)
- end
- end)
-
- -- Workaround for vehicle not deleting when other players are near it.
- while DoesEntityExist(vehicleId.vehicle) do
- Citizen.Wait(500)
- attempts = attempts + 1
-
- -- Give up
- if attempts > 30 then
- break
- end
-
- vehicles = ESX.Game.GetVehiclesInArea(playerCoords, 30.0)
- if #vehicles > 0 then
- for k,v in ipairs(vehicles) do
- if ESX.Math.Trim(GetVehicleNumberPlateText(v)) == vehicleId.plate then
- ESX.Game.DeleteVehicle(v)
- break
- end
- end
- end
- end
-
- isBusy = false
- ESX.ShowNotification(_U('garage_has_stored'))
- else
- ESX.ShowNotification(_U('garage_has_notstored'))
- end
- end, vehiclePlates)
-end
-
-function GetAvailableVehicleSpawnPoint(hospital, part, partNum)
- local spawnPoints = Config.Hospitals[hospital][part][partNum].SpawnPoints
- local found, foundSpawnPoint = false, nil
-
- for i=1, #spawnPoints, 1 do
- if ESX.Game.IsSpawnPointClear(spawnPoints[i].coords, spawnPoints[i].radius) then
- found, foundSpawnPoint = true, spawnPoints[i]
- break
- end
- end
-
- if found then
- return true, foundSpawnPoint
- else
- ESX.ShowNotification(_U('garage_blocked'))
- return false
- end
-end
-
-function OpenHelicopterSpawnerMenu(hospital, partNum)
- local playerCoords = GetEntityCoords(PlayerPedId())
- ESX.PlayerData = ESX.GetPlayerData()
-
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'helicopter_spawner', {
- title = _U('helicopter_title'),
- align = 'top-left',
- elements = {
- {label = _U('helicopter_garage'), action = 'garage'},
- {label = _U('helicopter_store'), action = 'store_garage'},
- {label = _U('helicopter_buy'), action = 'buy_helicopter'}
- }}, function(data, menu)
- if data.current.action == 'buy_helicopter' then
- local shopCoords = Config.Hospitals[hospital].Helicopters[partNum].InsideShop
- local shopElements = {}
- local authorizedHelicopters = Config.AuthorizedHelicopters[ESX.PlayerData.job.grade_name]
-
- if #authorizedHelicopters > 0 then
- for k,helicopter in ipairs(authorizedHelicopters) do
- table.insert(shopElements, {
- label = ('%s - %s'):format(helicopter.label, _U('shop_item', ESX.Math.GroupDigits(helicopter.price))),
- name = helicopter.label,
- model = helicopter.model,
- price = helicopter.price,
- type = 'helicopter'
- })
- end
- else
- ESX.ShowNotification(_U('helicopter_notauthorized'))
- return
- end
-
- OpenShopMenu(shopElements, playerCoords, shopCoords)
- elseif data.current.action == 'garage' then
- local garage = {}
-
- ESX.TriggerServerCallback('esx_vehicleshop:retrieveJobVehicles', function(jobVehicles)
- if #jobVehicles > 0 then
- for k,v in ipairs(jobVehicles) do
- local props = json.decode(v.vehicle)
- local vehicleName = GetLabelText(GetDisplayNameFromVehicleModel(props.model))
- local label = ('%s - %s: '):format(vehicleName, props.plate)
-
- if v.stored then
- label = label .. ('%s'):format(_U('garage_stored'))
- else
- label = label .. ('%s'):format(_U('garage_notstored'))
- end
-
- table.insert(garage, {
- label = label,
- stored = v.stored,
- model = props.model,
- vehicleProps = props
- })
- end
-
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'helicopter_garage', {
- title = _U('helicopter_garage_title'),
- align = 'top-left',
- elements = garage
- }, function(data2, menu2)
- if data2.current.stored then
- local foundSpawn, spawnPoint = GetAvailableVehicleSpawnPoint(hospital, 'Helicopters', partNum)
-
- if foundSpawn then
- menu2.close()
-
- ESX.Game.SpawnVehicle(data2.current.model, spawnPoint.coords, spawnPoint.heading, function(vehicle)
- ESX.Game.SetVehicleProperties(vehicle, data2.current.vehicleProps)
-
- TriggerServerEvent('esx_vehicleshop:setJobVehicleState', data2.current.vehicleProps.plate, false)
- ESX.ShowNotification(_U('garage_released'))
- end)
- end
- else
- ESX.ShowNotification(_U('garage_notavailable'))
- end
- end, function(data2, menu2)
- menu2.close()
- end)
- else
- ESX.ShowNotification(_U('garage_empty'))
- end
- end, 'helicopter')
- elseif data.current.action == 'store_garage' then
- StoreNearbyVehicle(playerCoords)
- end
- end, function(data, menu)
- menu.close()
- end)
-end
-
-function OpenShopMenu(elements, restoreCoords, shopCoords)
- local playerPed = PlayerPedId()
- isInShopMenu = true
-
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_shop', {
- title = _U('vehicleshop_title'),
- align = 'top-left',
- elements = elements
- }, function(data, menu)
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_shop_confirm', {
- title = _U('vehicleshop_confirm', data.current.name, data.current.price),
- align = 'top-left',
- elements = {
- {label = _U('confirm_no'), value = 'no'},
- {label = _U('confirm_yes'), value = 'yes'}
- }}, function(data2, menu2)
- if data2.current.value == 'yes' then
- local newPlate = exports['esx_vehicleshop']:GeneratePlate()
- local vehicle = GetVehiclePedIsIn(playerPed, false)
- local props = ESX.Game.GetVehicleProperties(vehicle)
- props.plate = newPlate
-
- ESX.TriggerServerCallback('esx_ambulancejob:buyJobVehicle', function (bought)
- if bought then
- ESX.ShowNotification(_U('vehicleshop_bought', data.current.name, ESX.Math.GroupDigits(data.current.price)))
-
- isInShopMenu = false
- ESX.UI.Menu.CloseAll()
-
- DeleteSpawnedVehicles()
- FreezeEntityPosition(playerPed, false)
- SetEntityVisible(playerPed, true)
-
- ESX.Game.Teleport(playerPed, restoreCoords)
- else
- ESX.ShowNotification(_U('vehicleshop_money'))
- menu2.close()
- end
- end, props, data.current.type)
- else
- menu2.close()
- end
-
- end, function(data2, menu2)
- menu2.close()
- end)
-
- end, function(data, menu)
- isInShopMenu = false
- ESX.UI.Menu.CloseAll()
-
- DeleteSpawnedVehicles()
- FreezeEntityPosition(playerPed, false)
- SetEntityVisible(playerPed, true)
-
- ESX.Game.Teleport(playerPed, restoreCoords)
- end, function(data, menu)
- DeleteSpawnedVehicles()
- WaitForVehicleToLoad(data.current.model)
-
- ESX.Game.SpawnLocalVehicle(data.current.model, shopCoords, 0.0, function(vehicle)
- table.insert(spawnedVehicles, vehicle)
- TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
- FreezeEntityPosition(vehicle, true)
- SetModelAsNoLongerNeeded(data.current.model)
- end)
- end)
-
- WaitForVehicleToLoad(elements[1].model)
- ESX.Game.SpawnLocalVehicle(elements[1].model, shopCoords, 0.0, function(vehicle)
- table.insert(spawnedVehicles, vehicle)
- TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
- FreezeEntityPosition(vehicle, true)
- SetModelAsNoLongerNeeded(elements[1].model)
- end)
-end
-
-Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
-
- if isInShopMenu then
- DisableControlAction(0, 75, true) -- Disable exit vehicle
- DisableControlAction(27, 75, true) -- Disable exit vehicle
- else
- Citizen.Wait(500)
- end
- end
-end)
-
-function DeleteSpawnedVehicles()
- while #spawnedVehicles > 0 do
- local vehicle = spawnedVehicles[1]
- ESX.Game.DeleteVehicle(vehicle)
- table.remove(spawnedVehicles, 1)
- end
-end
-
-function WaitForVehicleToLoad(modelHash)
- modelHash = (type(modelHash) == 'number' and modelHash or GetHashKey(modelHash))
-
- if not HasModelLoaded(modelHash) then
- RequestModel(modelHash)
-
- BeginTextCommandBusyspinnerOn('STRING')
- AddTextComponentSubstringPlayerName(_U('vehicleshop_awaiting_model'))
- EndTextCommandBusyspinnerOn(4)
-
- while not HasModelLoaded(modelHash) do
- Citizen.Wait(0)
- DisableAllControlActions(0)
- end
-
- BusyspinnerOff()
- end
-end
-
function OpenPharmacyMenu()
ESX.UI.Menu.CloseAll()
diff --git a/client/vehicle.lua b/client/vehicle.lua
new file mode 100644
index 00000000..39c5ce90
--- /dev/null
+++ b/client/vehicle.lua
@@ -0,0 +1,297 @@
+local spawnedVehicles = {}
+
+function OpenVehicleSpawnerMenu(type, hospital, part, partNum)
+ local playerCoords = GetEntityCoords(PlayerPedId())
+
+ ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle', {
+ title = _U('garage_title'),
+ align = 'top-left',
+ elements = {
+ {label = _U('garage_storeditem'), action = 'garage'},
+ {label = _U('garage_storeitem'), action = 'store_garage'},
+ {label = _U('garage_buyitem'), action = 'buy_vehicle'}
+ }}, function(data, menu)
+ if data.current.action == 'buy_vehicle' then
+ local shopElements = {}
+ local authorizedVehicles = Config.AuthorizedVehicles[type][ESX.PlayerData.job.grade_name]
+ local shopCoords = Config.Hospitals[hospital][part][partNum].InsideShop
+
+ if #authorizedVehicles > 0 then
+ for k,vehicle in ipairs(authorizedVehicles) do
+ local vehicleLabel = GetLabelText(GetDisplayNameFromVehicleModel(vehicle.model))
+
+ table.insert(shopElements, {
+ label = ('%s - %s'):format(vehicleLabel, _U('shop_item', ESX.Math.GroupDigits(vehicle.price))),
+ name = vehicleLabel,
+ model = vehicle.model,
+ price = vehicle.price,
+ props = vehicle.props,
+ type = type
+ })
+ end
+
+ OpenShopMenu(shopElements, playerCoords, shopCoords)
+ end
+ elseif data.current.action == 'garage' then
+ local garage = {}
+
+ ESX.TriggerServerCallback('esx_vehicleshop:retrieveJobVehicles', function(jobVehicles)
+ if #jobVehicles > 0 then
+ for k,v in ipairs(jobVehicles) do
+ local props = json.decode(v.vehicle)
+ local vehicleName = GetLabelText(GetDisplayNameFromVehicleModel(props.model))
+ local label = ('%s - %s: '):format(vehicleName, props.plate)
+
+ if v.stored then
+ label = label .. ('%s'):format(_U('garage_stored'))
+ else
+ label = label .. ('%s'):format(_U('garage_notstored'))
+ end
+
+ table.insert(garage, {
+ label = label,
+ stored = v.stored,
+ model = props.model,
+ vehicleProps = props
+ })
+ end
+
+ ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_garage', {
+ title = _U('garage_title'),
+ align = 'top-left',
+ elements = garage
+ }, function(data2, menu2)
+ if data2.current.stored then
+ local foundSpawn, spawnPoint = GetAvailableVehicleSpawnPoint(hospital, part, partNum)
+
+ if foundSpawn then
+ menu2.close()
+
+ ESX.Game.SpawnVehicle(data2.current.model, spawnPoint.coords, spawnPoint.heading, function(vehicle)
+ ESX.Game.SetVehicleProperties(vehicle, data2.current.vehicleProps)
+
+ TriggerServerEvent('esx_vehicleshop:setJobVehicleState', data2.current.vehicleProps.plate, false)
+ ESX.ShowNotification(_U('garage_released'))
+ end)
+ end
+ else
+ ESX.ShowNotification(_U('garage_notavailable'))
+ end
+ end, function(data2, menu2)
+ menu2.close()
+ end)
+ else
+ ESX.ShowNotification(_U('garage_empty'))
+ end
+ end, type)
+ elseif data.current.action == 'store_garage' then
+ StoreNearbyVehicle(playerCoords)
+ end
+ end, function(data, menu)
+ menu.close()
+ end)
+end
+
+function StoreNearbyVehicle(playerCoords)
+ local vehicles, vehiclePlates = ESX.Game.GetVehiclesInArea(playerCoords, 30.0), {}
+
+ if #vehicles > 0 then
+ for k,v in ipairs(vehicles) do
+
+ -- Make sure the vehicle we're saving is empty, or else it wont be deleted
+ if GetVehicleNumberOfPassengers(v) == 0 and IsVehicleSeatFree(v, -1) then
+ table.insert(vehiclePlates, {
+ vehicle = v,
+ plate = ESX.Math.Trim(GetVehicleNumberPlateText(v))
+ })
+ end
+ end
+ else
+ ESX.ShowNotification(_U('garage_store_nearby'))
+ return
+ end
+
+ ESX.TriggerServerCallback('esx_ambulancejob:storeNearbyVehicle', function(storeSuccess, foundNum)
+ if storeSuccess then
+ local vehicleId = vehiclePlates[foundNum]
+ local attempts = 0
+ ESX.Game.DeleteVehicle(vehicleId.vehicle)
+ isBusy = true
+
+ Citizen.CreateThread(function()
+ while isBusy do
+ Citizen.Wait(0)
+ drawLoadingText(_U('garage_storing'), 255, 255, 255, 255)
+ end
+ end)
+
+ -- Workaround for vehicle not deleting when other players are near it.
+ while DoesEntityExist(vehicleId.vehicle) do
+ Citizen.Wait(500)
+ attempts = attempts + 1
+
+ -- Give up
+ if attempts > 30 then
+ break
+ end
+
+ vehicles = ESX.Game.GetVehiclesInArea(playerCoords, 30.0)
+ if #vehicles > 0 then
+ for k,v in ipairs(vehicles) do
+ if ESX.Math.Trim(GetVehicleNumberPlateText(v)) == vehicleId.plate then
+ ESX.Game.DeleteVehicle(v)
+ break
+ end
+ end
+ end
+ end
+
+ isBusy = false
+ ESX.ShowNotification(_U('garage_has_stored'))
+ else
+ ESX.ShowNotification(_U('garage_has_notstored'))
+ end
+ end, vehiclePlates)
+end
+
+function GetAvailableVehicleSpawnPoint(hospital, part, partNum)
+ local spawnPoints = Config.Hospitals[hospital][part][partNum].SpawnPoints
+ local found, foundSpawnPoint = false, nil
+
+ for i=1, #spawnPoints, 1 do
+ if ESX.Game.IsSpawnPointClear(spawnPoints[i].coords, spawnPoints[i].radius) then
+ found, foundSpawnPoint = true, spawnPoints[i]
+ break
+ end
+ end
+
+ if found then
+ return true, foundSpawnPoint
+ else
+ ESX.ShowNotification(_U('garage_blocked'))
+ return false
+ end
+end
+
+function OpenShopMenu(elements, restoreCoords, shopCoords)
+ local playerPed = PlayerPedId()
+ isInShopMenu = true
+
+ ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_shop', {
+ title = _U('vehicleshop_title'),
+ align = 'top-left',
+ elements = elements
+ }, function(data, menu)
+ ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_shop_confirm', {
+ title = _U('vehicleshop_confirm', data.current.name, data.current.price),
+ align = 'top-left',
+ elements = {
+ {label = _U('confirm_no'), value = 'no'},
+ {label = _U('confirm_yes'), value = 'yes'}
+ }}, function(data2, menu2)
+ if data2.current.value == 'yes' then
+ local newPlate = exports['esx_vehicleshop']:GeneratePlate()
+ local vehicle = GetVehiclePedIsIn(playerPed, false)
+ local props = ESX.Game.GetVehicleProperties(vehicle)
+ props.plate = newPlate
+
+ ESX.TriggerServerCallback('esx_ambulancejob:buyJobVehicle', function(bought)
+ if bought then
+ ESX.ShowNotification(_U('vehicleshop_bought', data.current.name, ESX.Math.GroupDigits(data.current.price)))
+
+ isInShopMenu = false
+ ESX.UI.Menu.CloseAll()
+
+ DeleteSpawnedVehicles()
+ FreezeEntityPosition(playerPed, false)
+ SetEntityVisible(playerPed, true)
+
+ ESX.Game.Teleport(playerPed, restoreCoords)
+ else
+ ESX.ShowNotification(_U('vehicleshop_money'))
+ menu2.close()
+ end
+ end, props, data.current.type)
+ else
+ menu2.close()
+ end
+ end, function(data2, menu2)
+ menu2.close()
+ end)
+ end, function(data, menu)
+ isInShopMenu = false
+ ESX.UI.Menu.CloseAll()
+
+ DeleteSpawnedVehicles()
+ FreezeEntityPosition(playerPed, false)
+ SetEntityVisible(playerPed, true)
+
+ ESX.Game.Teleport(playerPed, restoreCoords)
+ end, function(data, menu)
+ DeleteSpawnedVehicles()
+ WaitForVehicleToLoad(data.current.model)
+
+ ESX.Game.SpawnLocalVehicle(data.current.model, shopCoords, 0.0, function(vehicle)
+ table.insert(spawnedVehicles, vehicle)
+ TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
+ FreezeEntityPosition(vehicle, true)
+ SetModelAsNoLongerNeeded(data.current.model)
+
+ if data.current.props then
+ ESX.Game.SetVehicleProperties(vehicle, data.current.props)
+ end
+ end)
+ end)
+
+ WaitForVehicleToLoad(elements[1].model)
+ ESX.Game.SpawnLocalVehicle(elements[1].model, shopCoords, 0.0, function(vehicle)
+ table.insert(spawnedVehicles, vehicle)
+ TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
+ FreezeEntityPosition(vehicle, true)
+ SetModelAsNoLongerNeeded(elements[1].model)
+
+ if elements[1].props then
+ ESX.Game.SetVehicleProperties(vehicle, elements[1].props)
+ end
+ end)
+end
+
+Citizen.CreateThread(function()
+ while true do
+ Citizen.Wait(0)
+
+ if isInShopMenu then
+ DisableControlAction(0, 75, true) -- Disable exit vehicle
+ DisableControlAction(27, 75, true) -- Disable exit vehicle
+ else
+ Citizen.Wait(500)
+ end
+ end
+end)
+
+function DeleteSpawnedVehicles()
+ while #spawnedVehicles > 0 do
+ local vehicle = spawnedVehicles[1]
+ ESX.Game.DeleteVehicle(vehicle)
+ table.remove(spawnedVehicles, 1)
+ end
+end
+
+function WaitForVehicleToLoad(modelHash)
+ modelHash = (type(modelHash) == 'number' and modelHash or GetHashKey(modelHash))
+
+ if not HasModelLoaded(modelHash) then
+ RequestModel(modelHash)
+
+ BeginTextCommandBusyspinnerOn('STRING')
+ AddTextComponentSubstringPlayerName(_U('vehicleshop_awaiting_model'))
+ EndTextCommandBusyspinnerOn(4)
+
+ while not HasModelLoaded(modelHash) do
+ Citizen.Wait(0)
+ DisableAllControlActions(0)
+ end
+
+ BusyspinnerOff()
+ end
+end
diff --git a/config.lua b/config.lua
index 20e848f9..7bb21f18 100644
--- a/config.lua
+++ b/config.lua
@@ -127,37 +127,39 @@ Config.Hospitals = {
}
Config.AuthorizedVehicles = {
- ambulance = {
- {model = 'ambulance', label = 'Ambulance Van', price = 5000}
+ car = {
+ ambulance = {
+ {model = 'ambulance', price = 5000}
+ },
+
+ doctor = {
+ {model = 'ambulance', price = 4500}
+ },
+
+ chief_doctor = {
+ {model = 'ambulance', price = 3000}
+ },
+
+ boss = {
+ {model = 'ambulance', price = 2000}
+ }
},
- doctor = {
- {model = 'ambulance', label = 'Ambulance Van', price = 4500}
- },
+ helicopter = {
+ ambulance = {},
- chief_doctor = {
- {model = 'ambulance', label = 'Ambulance Van', price = 3000}
- },
+ doctor = {
+ {model = 'buzzard2', price = 150000}
+ },
- boss = {
- {model = 'ambulance', label = 'Ambulance Van', price = 2000}
- }
-}
-
-Config.AuthorizedHelicopters = {
- ambulance = {},
-
- doctor = {
- {model = 'buzzard2', label = 'Nagasaki Buzzard', price = 150000}
- },
-
- chief_doctor = {
- {model = 'buzzard2', label = 'Nagasaki Buzzard', price = 150000},
- {model = 'seasparrow', label = 'Sea Sparrow', price = 300000}
- },
-
- boss = {
- {model = 'buzzard2', label = 'Nagasaki Buzzard', price = 10000},
- {model = 'seasparrow', label = 'Sea Sparrow', price = 250000}
+ chief_doctor = {
+ {model = 'buzzard2', price = 150000},
+ {model = 'seasparrow', price = 300000}
+ },
+
+ boss = {
+ {model = 'buzzard2', price = 10000},
+ {model = 'seasparrow', price = 250000}
+ }
}
}
diff --git a/fxmanifest.lua b/fxmanifest.lua
index 7acca84c..ba925897 100644
--- a/fxmanifest.lua
+++ b/fxmanifest.lua
@@ -33,7 +33,8 @@ client_scripts {
'locales/cs.lua',
'config.lua',
'client/main.lua',
- 'client/job.lua'
+ 'client/job.lua',
+ 'client/vehicle.lua',
}
dependencies {
diff --git a/locales/br.lua b/locales/br.lua
index 4d88eed3..9e3147d0 100644
--- a/locales/br.lua
+++ b/locales/br.lua
@@ -6,12 +6,6 @@ Locales['br'] = {
-- Vehicles
['ambulance'] = 'ambulancia',
['helicopter_prompt'] = 'pressione ~INPUT_CONTEXT~ para acessar a ~y~Helicopter Actions~s~.',
- ['helicopter_buy'] = 'loja de helicóptero',
- ['helicopter_garage'] = 'garagem aberta',
- ['helicopter_store'] = 'helicóptero da loja entregue na garagem',
- ['helicopter_garage_title'] = 'garagem de helicóptero',
- ['helicopter_title'] = 'ações do helicóptero',
- ['helicopter_notauthorized'] = 'você não está autorizado a comprar helicópteros.',
['garage_prompt'] = 'pressione ~INPUT_CONTEXT~ para entra no ~y~Vehicle Actions~s~.',
['garage_title'] = 'ações do veiculo',
['garage_stored'] = 'guardado',
@@ -30,7 +24,7 @@ Locales['br'] = {
['shop_item'] = '$%s',
['vehicleshop_title'] = 'loja de veículos',
['vehicleshop_confirm'] = 'você quer comprar este veículo?',
- ['vehicleshop_bought'] = 'você comprou ~y~%s~s~ para ~r~$%s~s~',
+ ['vehicleshop_bought'] = 'você comprou ~y~%s~s~ para ~g~$%s~s~',
['vehicleshop_money'] = 'você não pode pagar esse veículo',
['vehicleshop_awaiting_model'] = 'o veículo está atualmente ~g~DOWNLOADING & LOADING~s~, por favor aguarde',
['confirm_no'] = 'não',
diff --git a/locales/cs.lua b/locales/cs.lua
index 5e3690d7..37d65c5a 100644
--- a/locales/cs.lua
+++ b/locales/cs.lua
@@ -6,12 +6,6 @@ Locales['cs'] = {
-- Vehicles
['ambulance'] = 'ambulance',
['helicopter_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Helicopter Actions~s~.',
- ['helicopter_buy'] = 'helicopter shop',
- ['helicopter_garage'] = 'open garage',
- ['helicopter_store'] = 'store helicopter in garage',
- ['helicopter_garage_title'] = 'helicopter Garage',
- ['helicopter_title'] = 'helicopter Actions',
- ['helicopter_notauthorized'] = 'you\'re not authorized to buy helicopters.',
['garage_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Vehicle Actions~s~.',
['garage_title'] = 'vehicle Actions',
['garage_stored'] = 'stored',
@@ -30,7 +24,7 @@ Locales['cs'] = {
['shop_item'] = '$%s',
['vehicleshop_title'] = 'vehicle Shop',
['vehicleshop_confirm'] = 'do you want to buy this vehicle?',
- ['vehicleshop_bought'] = 'you have bought ~y~%s~s~ for ~r~$%s~s~',
+ ['vehicleshop_bought'] = 'you have bought ~y~%s~s~ for ~g~$%s~s~',
['vehicleshop_money'] = 'you cannot afford that vehicle',
['vehicleshop_awaiting_model'] = 'the vehicle is currently ~g~DOWNLOADING & LOADING~s~ please wait',
['confirm_no'] = 'no',
diff --git a/locales/en.lua b/locales/en.lua
index 14111578..5b5f6d24 100644
--- a/locales/en.lua
+++ b/locales/en.lua
@@ -6,12 +6,6 @@ Locales['en'] = {
-- Vehicles
['ambulance'] = 'ambulance',
['helicopter_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Helicopter Actions~s~.',
- ['helicopter_buy'] = 'helicopter shop',
- ['helicopter_garage'] = 'open garage',
- ['helicopter_store'] = 'store helicopter in garage',
- ['helicopter_garage_title'] = 'helicopter Garage',
- ['helicopter_title'] = 'helicopter Actions',
- ['helicopter_notauthorized'] = 'you\'re not authorized to buy helicopters.',
['garage_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Vehicle Actions~s~.',
['garage_title'] = 'vehicle Actions',
['garage_stored'] = 'stored',
@@ -30,7 +24,7 @@ Locales['en'] = {
['shop_item'] = '$%s',
['vehicleshop_title'] = 'vehicle Shop',
['vehicleshop_confirm'] = 'do you want to buy this vehicle?',
- ['vehicleshop_bought'] = 'you have bought ~y~%s~s~ for ~r~$%s~s~',
+ ['vehicleshop_bought'] = 'you have bought ~y~%s~s~ for ~g~$%s~s~',
['vehicleshop_money'] = 'you cannot afford that vehicle',
['vehicleshop_awaiting_model'] = 'the vehicle is currently ~g~DOWNLOADING & LOADING~s~ please wait',
['confirm_no'] = 'no',
diff --git a/locales/es.lua b/locales/es.lua
index 656a4d53..e231db54 100644
--- a/locales/es.lua
+++ b/locales/es.lua
@@ -6,12 +6,6 @@ Locales['es'] = {
-- Vehicles
['ambulance'] = 'ambulance',
['helicopter_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Helicopter Actions~s~.',
- ['helicopter_buy'] = 'helicopter shop',
- ['helicopter_garage'] = 'open garage',
- ['helicopter_store'] = 'store helicopter in garage',
- ['helicopter_garage_title'] = 'helicopter Garage',
- ['helicopter_title'] = 'helicopter Actions',
- ['helicopter_notauthorized'] = 'you\'re not authorized to buy helicopters.',
['garage_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Vehicle Actions~s~.',
['garage_title'] = 'vehicle Actions',
['garage_stored'] = 'stored',
@@ -30,7 +24,7 @@ Locales['es'] = {
['shop_item'] = '$%s',
['vehicleshop_title'] = 'vehicle Shop',
['vehicleshop_confirm'] = 'do you want to buy this vehicle?',
- ['vehicleshop_bought'] = 'you have bought ~y~%s~s~ for ~r~$%s~s~',
+ ['vehicleshop_bought'] = 'you have bought ~y~%s~s~ for ~g~$%s~s~',
['vehicleshop_money'] = 'you cannot afford that vehicle',
['vehicleshop_awaiting_model'] = 'the vehicle is currently ~g~DOWNLOADING & LOADING~s~ please wait',
['confirm_no'] = 'no',
diff --git a/locales/fi.lua b/locales/fi.lua
index d98cf398..9ef6caf8 100644
--- a/locales/fi.lua
+++ b/locales/fi.lua
@@ -6,12 +6,6 @@ Locales['fi'] = {
-- Vehicles
['ambulance'] = 'ambulance',
['helicopter_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Helicopter Actions~s~.',
- ['helicopter_buy'] = 'helicopter shop',
- ['helicopter_garage'] = 'open garage',
- ['helicopter_store'] = 'store helicopter in garage',
- ['helicopter_garage_title'] = 'helicopter Garage',
- ['helicopter_title'] = 'helicopter Actions',
- ['helicopter_notauthorized'] = 'you\'re not authorized to buy helicopters.',
['garage_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Vehicle Actions~s~.',
['garage_title'] = 'vehicle Actions',
['garage_stored'] = 'stored',
@@ -30,7 +24,7 @@ Locales['fi'] = {
['shop_item'] = '$%s',
['vehicleshop_title'] = 'vehicle Shop',
['vehicleshop_confirm'] = 'do you want to buy this vehicle?',
- ['vehicleshop_bought'] = 'you have bought ~y~%s~s~ for ~r~$%s~s~',
+ ['vehicleshop_bought'] = 'you have bought ~y~%s~s~ for ~g~$%s~s~',
['vehicleshop_money'] = 'you cannot afford that vehicle',
['vehicleshop_awaiting_model'] = 'the vehicle is currently ~g~DOWNLOADING & LOADING~s~ please wait',
['confirm_no'] = 'no',
diff --git a/locales/fr.lua b/locales/fr.lua
index 51d558ff..fb750289 100644
--- a/locales/fr.lua
+++ b/locales/fr.lua
@@ -6,12 +6,6 @@ Locales['fr'] = {
-- Vehicles
['ambulance'] = 'ambulance',
['helicopter_prompt'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder aux ~y~Actions de l\'hélicoptère~s~.',
- ['helicopter_buy'] = 'magasin hélicoptère',
- ['helicopter_garage'] = 'ouvrir le garage',
- ['helicopter_store'] = 'garer l\'hélicoptère dans le garage',
- ['helicopter_garage_title'] = 'garage hélicoptère',
- ['helicopter_title'] = 'actions hélicoptère',
- ['helicopter_notauthorized'] = 'vous n\'êtes pas autorisé à acheter un hélicoptère.',
['garage_prompt'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder aux ~y~Actions des véhciules~s~.',
['garage_title'] = 'actions véhicules',
['garage_stored'] = 'rangé',
@@ -30,7 +24,7 @@ Locales['fr'] = {
['shop_item'] = '$%s',
['vehicleshop_title'] = 'magasin véhicule',
['vehicleshop_confirm'] = 'voulez-vous acheter ce véhicule?',
- ['vehicleshop_bought'] = 'vous avez acheté ~y~%s~s~ pour ~r~$%s~s~',
+ ['vehicleshop_bought'] = 'vous avez acheté ~y~%s~s~ pour ~g~$%s~s~',
['vehicleshop_money'] = 'vous ne pouvez pas acheter ce véhicule',
['vehicleshop_awaiting_model'] = 'le véhicule est actuellement en ~g~PRÉPARATION~s~ veuillez patienter',
['confirm_no'] = 'non',
diff --git a/locales/pl.lua b/locales/pl.lua
index 007c8383..ebf082c1 100644
--- a/locales/pl.lua
+++ b/locales/pl.lua
@@ -6,12 +6,6 @@ Locales['pl'] = {
-- Vehicles
['ambulance'] = 'ambulance',
['helicopter_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Helicopter Actions~s~.',
- ['helicopter_buy'] = 'helicopter shop',
- ['helicopter_garage'] = 'open garage',
- ['helicopter_store'] = 'store helicopter in garage',
- ['helicopter_garage_title'] = 'helicopter Garage',
- ['helicopter_title'] = 'helicopter Actions',
- ['helicopter_notauthorized'] = 'you\'re not authorized to buy helicopters.',
['garage_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Vehicle Actions~s~.',
['garage_title'] = 'vehicle Actions',
['garage_stored'] = 'stored',
@@ -30,7 +24,7 @@ Locales['pl'] = {
['shop_item'] = '$%s',
['vehicleshop_title'] = 'vehicle Shop',
['vehicleshop_confirm'] = 'do you want to buy this vehicle?',
- ['vehicleshop_bought'] = 'you have bought ~y~%s~s~ for ~r~$%s~s~',
+ ['vehicleshop_bought'] = 'you have bought ~y~%s~s~ for ~g~$%s~s~',
['vehicleshop_money'] = 'you cannot afford that vehicle',
['vehicleshop_awaiting_model'] = 'the vehicle is currently ~g~DOWNLOADING & LOADING~s~ please wait',
['confirm_no'] = 'no',
diff --git a/locales/sv.lua b/locales/sv.lua
index c7f55b6e..b0d736aa 100644
--- a/locales/sv.lua
+++ b/locales/sv.lua
@@ -5,13 +5,7 @@ Locales['sv'] = {
['ems_clothes_ems'] = 'ambulanskläder',
-- Vehicles
['ambulance'] = 'ambulans',
- ['helicopter_prompt'] = 'klicka på ~INPUT_CONTEXT~ för att komma åt ~y~garaget~s~.',
- ['helicopter_buy'] = 'fordonshandel',
- ['helicopter_garage'] = 'öppna garage',
- ['helicopter_store'] = 'ställ in helikopter',
- ['helicopter_garage_title'] = 'garage',
- ['helicopter_title'] = 'garage',
- ['helicopter_notauthorized'] = 'du har inte behörighet till att köpa en helikopter.',
+ ['helicopter_prompt'] = 'tryck ~INPUT_CONTEXT~ för att komma åt ~y~helikoptergaraget~s~.',
['garage_prompt'] = 'tryck ~INPUT_CONTEXT~ för att komma åt ~y~garaget~s~.',
['garage_title'] = 'garage',
['garage_stored'] = 'inställt',
@@ -30,7 +24,7 @@ Locales['sv'] = {
['shop_item'] = '%s SEK',
['vehicleshop_title'] = 'fordonshandel',
['vehicleshop_confirm'] = 'vill du köpa detta fordon?',
- ['vehicleshop_bought'] = 'du köpte ~y~%s~s~ för ~r~$%s~s~',
+ ['vehicleshop_bought'] = 'du köpte ~y~%s~s~ för ~g~%s SEK~s~',
['vehicleshop_money'] = 'du har inte råd med detta fordon',
['vehicleshop_awaiting_model'] = 'fordonet ~g~LADDAS NED OCH LADDAS IN~s~ var god vänta',
['confirm_no'] = 'nej',
diff --git a/server/main.lua b/server/main.lua
index 08eff022..4b24fb5e 100644
--- a/server/main.lua
+++ b/server/main.lua
@@ -207,22 +207,12 @@ ESX.RegisterServerCallback('esx_ambulancejob:storeNearbyVehicle', function(sourc
end
end)
-function getPriceFromHash(hashKey, jobGrade, type)
- if type == 'helicopter' then
- local vehicles = Config.AuthorizedHelicopters[jobGrade]
+function getPriceFromHash(vehicleHash, jobGrade, type)
+ local vehicles = Config.AuthorizedVehicles[type][jobGrade]
- for k,v in ipairs(vehicles) do
- if GetHashKey(v.model) == hashKey then
- return v.price
- end
- end
- elseif type == 'car' then
- local vehicles = Config.AuthorizedVehicles[jobGrade]
-
- for k,v in ipairs(vehicles) do
- if GetHashKey(v.model) == hashKey then
- return v.price
- end
+ for k,v in ipairs(vehicles) do
+ if GetHashKey(v.model) == vehicleHash then
+ return v.price
end
end