mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-01 10:48:52 +00:00
Fixes #44 and spawning job vehicle, minor cleanup
This commit is contained in:
@@ -30,8 +30,8 @@ Config.Jobs.fueler = {
|
||||
GPS = {x = 554.59, y = -2314.43, z = 4.86}
|
||||
},
|
||||
|
||||
ChampPetrol = {
|
||||
Pos = {x = 609.58, y = 2856.74, z = 39.49},
|
||||
OilFarm = {
|
||||
Pos = {x = 609.58, y = 2856.74, z = 38.90},
|
||||
Size = {x = 20.0, y = 20.0, z = 1.0},
|
||||
Color = {r = 204, g = 204, b = 0},
|
||||
Marker = 1,
|
||||
@@ -55,7 +55,7 @@ Config.Jobs.fueler = {
|
||||
GPS = {x = 2736.94, y = 1417.99, z = 23.48}
|
||||
},
|
||||
|
||||
Raffinerie = {
|
||||
OilRefinement = {
|
||||
Pos = {x = 2736.94, y = 1417.99, z = 23.48},
|
||||
Size = {x = 10.0, y = 10.0, z = 1.0},
|
||||
Color = {r = 204, g = 204, b = 0},
|
||||
@@ -80,7 +80,7 @@ Config.Jobs.fueler = {
|
||||
GPS = {x = 265.75, y = -3013.39, z = 4.73}
|
||||
},
|
||||
|
||||
Melange = {
|
||||
OilMix = {
|
||||
Pos = {x = 265.75, y = -3013.39, z = 4.73},
|
||||
Size = {x = 10.0, y = 10.0, z = 1.0},
|
||||
Color = {r = 204, g = 204, b = 0},
|
||||
@@ -168,7 +168,7 @@ Config.Jobs.fueler = {
|
||||
}
|
||||
},
|
||||
|
||||
Hint = _U("f_deliver_gas"),
|
||||
Hint = _U("f_deliver_gas_button"),
|
||||
GPS = {x = 609.58, y = 2856.74, z = 39.49}
|
||||
}
|
||||
|
||||
|
||||
+41
-50
@@ -19,13 +19,9 @@ local JobBlips = {}
|
||||
|
||||
local collectedItem = nil
|
||||
local collectedQtty = 0
|
||||
local collectedQttyUpToDate = false
|
||||
local previousCollectedItem = nil
|
||||
local previousCollectedQtty = 0
|
||||
local isInMarker = false
|
||||
local isInPublicMarker = false
|
||||
|
||||
local newTask = false
|
||||
local hintToDisplay = "no hint to display"
|
||||
local jobDone = false
|
||||
local onDuty = false
|
||||
@@ -55,6 +51,7 @@ Citizen.CreateThread(function()
|
||||
end
|
||||
|
||||
PlayerData = ESX.GetPlayerData()
|
||||
refreshBlips()
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
@@ -113,40 +110,36 @@ AddEventHandler('esx_jobs:action', function(job, zone)
|
||||
TriggerServerEvent('esx_jobs:startWork', zone.Item)
|
||||
end
|
||||
elseif zone.Type == "vehspawner" then
|
||||
TriggerServerEvent('esx_jobs:requestPlayerData', 'refresh_bank_account')
|
||||
local spawnpt = nil
|
||||
local deliverypt = nil
|
||||
local spawnPoint = nil
|
||||
local vehicle = nil
|
||||
|
||||
for k,v in pairs(Config.Jobs) do
|
||||
if PlayerData.job.name == k then
|
||||
for l,w in pairs(v.Zones) do
|
||||
if w.Type == "vehspawnpt" and w.Spawner == zone.Spawner then
|
||||
spawnpt = w
|
||||
spawnPoint = w
|
||||
spawner = w.Spawner
|
||||
end
|
||||
end
|
||||
|
||||
for m,x in pairs(v.Vehicles) do
|
||||
if (x.Spawner == zone.Spawner) then
|
||||
if x.Spawner == zone.Spawner then
|
||||
vehicle = x
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local caution = zone.Caution
|
||||
if ESX.Game.IsSpawnPointClear(spawnPoint.Pos, 5.0) then
|
||||
TriggerServerEvent('esx_jobs:setCautionInCaseOfDrop', zone.Caution)
|
||||
cautionVehicleInCaseofDrop = zone.Caution
|
||||
maxCautionVehicleInCaseofDrop = cautionVehicleInCaseofDrop
|
||||
|
||||
if deliverypt == nil then
|
||||
deliverypt = 0
|
||||
spawnVehicle(spawnPoint, vehicle)
|
||||
else
|
||||
ESX.ShowNotification(_U('spawn_blocked'))
|
||||
end
|
||||
|
||||
TriggerServerEvent('esx_jobs:setCautionInCaseOfDrop', caution)
|
||||
cautionVehicleInCaseofDrop = caution
|
||||
maxCautionVehicleInCaseofDrop = cautionVehicleInCaseofDrop
|
||||
|
||||
spawncar(spawnpt, vehicle)
|
||||
|
||||
elseif zone.Type == "vehdelete" then
|
||||
local looping = true
|
||||
|
||||
@@ -267,10 +260,11 @@ function refreshBlips()
|
||||
|
||||
if zoneValues.Blip then
|
||||
local blip = AddBlipForCoord(zoneValues.Pos.x, zoneValues.Pos.y, zoneValues.Pos.z)
|
||||
SetBlipSprite (blip, jobValues.BlipInfos.Sprite)
|
||||
SetBlipDisplay(blip, 4)
|
||||
SetBlipScale (blip, 1.2)
|
||||
SetBlipColour (blip, jobValues.BlipInfos.Color)
|
||||
SetBlipSprite (blip, jobValues.BlipInfos.Sprite)
|
||||
SetBlipDisplay (blip, 4)
|
||||
SetBlipScale (blip, 1.2)
|
||||
SetBlipCategory(blip, 3)
|
||||
SetBlipColour (blip, jobValues.BlipInfos.Color)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
@@ -284,44 +278,41 @@ function refreshBlips()
|
||||
end
|
||||
end
|
||||
|
||||
function spawncar(spawnPoint, vehicle)
|
||||
hintToDisplay = "no hint to display"
|
||||
hintIsShowed = false
|
||||
TriggerServerEvent('esx_jobs:caution', "take", cautionVehicleInCaseofDrop, spawnPoint, vehicle)
|
||||
function spawnVehicle(spawnPoint, vehicle)
|
||||
hintToDisplay = "no hint to display"
|
||||
hintIsShowed = false
|
||||
TriggerServerEvent('esx_jobs:caution', "take", cautionVehicleInCaseofDrop, spawnPoint, vehicle)
|
||||
end
|
||||
|
||||
RegisterNetEvent('esx_jobs:spawnJobVehicle')
|
||||
AddEventHandler('esx_jobs:spawnJobVehicle', function(spawnPoint, vehicle)
|
||||
local playerPed = PlayerPedId()
|
||||
|
||||
if not IsAnyVehicleNearPoint(coords.x, coords.y, coords.z, 5.0) then
|
||||
ESX.Game.SpawnVehicle(vehicle.Hash, spawnPoint.Pos, spawnPoint.heading, function(spawnedVehicle)
|
||||
|
||||
ESX.Game.SpawnVehicle(vehicle.Hash, spawnPoint.Pos, spawnPoint.heading, function(spawnedVehicle)
|
||||
if vehicle.Trailer ~= "none" then
|
||||
ESX.Game.SpawnVehicle(vehicle.Trailer, spawnPoint.Pos, spawnPoint.heading, function(trailer)
|
||||
AttachVehicleToTrailer(spawnedVehicle, trailer, 1.1)
|
||||
end)
|
||||
end
|
||||
|
||||
if vehicle.Trailer ~= "none" then
|
||||
ESX.Game.SpawnVehicle(vehicle.Trailer, spawnPoint.Pos, spawnPoint.heading, function(trailer)
|
||||
AttachVehicleToTrailer(spawnedVehicle, trailer, 1.1)
|
||||
end)
|
||||
end
|
||||
-- save & set plate
|
||||
local plate = 'WORK' .. math.random(100, 900)
|
||||
SetVehicleNumberPlateText(spawnedVehicle, plate)
|
||||
table.insert(myPlate, plate)
|
||||
plate = string.gsub(plate, " ", "")
|
||||
|
||||
-- save & set plate
|
||||
local plate = 'WORK' .. math.random(100, 900)
|
||||
SetVehicleNumberPlateText(spawnedVehicle, plate)
|
||||
table.insert(myPlate, plate)
|
||||
plate = string.gsub(plate, " ", "")
|
||||
TaskWarpPedIntoVehicle(playerPed, spawnedVehicle, -1)
|
||||
isJobVehicleDestroyed = false
|
||||
|
||||
TaskWarpPedIntoVehicle(playerPed, spawnedVehicle, -1)
|
||||
isJobVehicleDestroyed = false
|
||||
|
||||
if vehicle.HasCaution then
|
||||
vehicleInCaseofDrop = spawnedVehicle
|
||||
vehicleHashInCaseofDrop = vehicle.Hash
|
||||
vehicleObjInCaseofDrop = vehicle
|
||||
vehicleMaxHealthInCaseofDrop = GetEntityMaxHealth(spawnedVehicle)
|
||||
vehicleOldHealthInCaseofDrop = vehicleMaxHealthInCaseofDrop
|
||||
end
|
||||
end)
|
||||
end
|
||||
if vehicle.HasCaution then
|
||||
vehicleInCaseofDrop = spawnedVehicle
|
||||
vehicleHashInCaseofDrop = vehicle.Hash
|
||||
vehicleObjInCaseofDrop = vehicle
|
||||
vehicleMaxHealthInCaseofDrop = GetEntityMaxHealth(spawnedVehicle)
|
||||
vehicleOldHealthInCaseofDrop = vehicleMaxHealthInCaseofDrop
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
-- Show top left hint
|
||||
|
||||
Reference in New Issue
Block a user