mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-03 03:38:50 +00:00
Add health check
This commit is contained in:
+94
-86
@@ -31,114 +31,122 @@ AddEventHandler('esx_property:hasEnteredMarker', function(name, part, parking)
|
||||
|
||||
if IsPedInAnyVehicle(playerPed, false) then
|
||||
|
||||
local vehicle = GetVehiclePedIsIn(playerPed, false)
|
||||
|
||||
if GetPedInVehicleSeat(vehicle, -1) == playerPed then
|
||||
|
||||
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
|
||||
|
||||
local spawnCoords = {
|
||||
x = garage.InteriorSpawnPoint.Pos.x,
|
||||
y = garage.InteriorSpawnPoint.Pos.y,
|
||||
z = garage.InteriorSpawnPoint.Pos.z + Config.ZDiff
|
||||
}
|
||||
|
||||
ESX.Game.DeleteVehicle(vehicle)
|
||||
|
||||
ESX.Game.Teleport(playerPed, spawnCoords, function()
|
||||
|
||||
TriggerEvent('instance:create', 'garage')
|
||||
|
||||
ESX.Game.SpawnLocalVehicle(vehicleProps.model, spawnCoords, garage.InteriorSpawnPoint.Heading, function(vehicle)
|
||||
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
|
||||
ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
|
||||
end)
|
||||
|
||||
ESX.TriggerServerCallback('esx_vehicleshop:getVehiclesInGarage', function(vehicles)
|
||||
|
||||
for i=1, #garage.Parkings, 1 do
|
||||
for j=1, #vehicles, 1 do
|
||||
|
||||
if i == vehicles[j].zone then
|
||||
|
||||
local spawn = function(j)
|
||||
|
||||
local vehicle = GetClosestVehicle(garage.Parkings[i].Pos.x, garage.Parkings[i].Pos.y, garage.Parkings[i].Pos.z, 2.0, 0, 71)
|
||||
|
||||
if DoesEntityExist(vehicle) then
|
||||
ESX.Game.DeleteVehicle(vehicle)
|
||||
end
|
||||
|
||||
ESX.Game.SpawnLocalVehicle(vehicles[j].vehicle.model, {
|
||||
x = garage.Parkings[i].Pos.x,
|
||||
y = garage.Parkings[i].Pos.y,
|
||||
z = garage.Parkings[i].Pos.z + Config.ZDiff
|
||||
}, garage.Parkings[i].Heading, function(vehicle)
|
||||
ESX.Game.SetVehicleProperties(vehicle, vehicles[j].vehicle)
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
spawn(j)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end, name)
|
||||
|
||||
end)
|
||||
local vehicle = GetVehiclePedIsIn(playerPed, false)
|
||||
local maxHealth = GetEntityMaxHealth(vehicle)
|
||||
local health = GetEntityHealth(vehicle)
|
||||
local healthPercent = (health / maxHealth) * 100
|
||||
|
||||
if healthPercent < Config.MinimumHealthPercent then
|
||||
ESX.ShowNotification('Vous devez d\'abord réparer votre véhicule')
|
||||
else
|
||||
|
||||
ESX.Game.Teleport(playerPed, {
|
||||
x = garage.InteriorSpawnPoint.Pos.x,
|
||||
y = garage.InteriorSpawnPoint.Pos.y,
|
||||
z = garage.InteriorSpawnPoint.Pos.z + Config.ZDiff
|
||||
}, function()
|
||||
if GetPedInVehicleSeat(vehicle, -1) == playerPed then
|
||||
|
||||
TriggerEvent('instance:create', 'garage')
|
||||
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
|
||||
|
||||
ESX.TriggerServerCallback('esx_vehicleshop:getVehiclesInGarage', function(vehicles)
|
||||
local spawnCoords = {
|
||||
x = garage.InteriorSpawnPoint.Pos.x,
|
||||
y = garage.InteriorSpawnPoint.Pos.y,
|
||||
z = garage.InteriorSpawnPoint.Pos.z + Config.ZDiff
|
||||
}
|
||||
|
||||
for i=1, #garage.Parkings, 1 do
|
||||
for j=1, #vehicles, 1 do
|
||||
ESX.Game.DeleteVehicle(vehicle)
|
||||
|
||||
if i == vehicles[j].zone then
|
||||
|
||||
local spawn = function(j)
|
||||
ESX.Game.Teleport(playerPed, spawnCoords, function()
|
||||
|
||||
local vehicle = GetClosestVehicle(garage.Parkings[i].Pos.x, garage.Parkings[i].Pos.garage.Parkings[i].Pos.y, garage.Parkings[i].Pos.z, 2.0, 0, 71)
|
||||
TriggerEvent('instance:create', 'garage')
|
||||
|
||||
ESX.Game.SpawnLocalVehicle(vehicleProps.model, spawnCoords, garage.InteriorSpawnPoint.Heading, function(vehicle)
|
||||
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
|
||||
ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
|
||||
end)
|
||||
|
||||
ESX.TriggerServerCallback('esx_vehicleshop:getVehiclesInGarage', function(vehicles)
|
||||
|
||||
for i=1, #garage.Parkings, 1 do
|
||||
for j=1, #vehicles, 1 do
|
||||
|
||||
if i == vehicles[j].zone then
|
||||
|
||||
local spawn = function(j)
|
||||
|
||||
local vehicle = GetClosestVehicle(garage.Parkings[i].Pos.x, garage.Parkings[i].Pos.y, garage.Parkings[i].Pos.z, 2.0, 0, 71)
|
||||
|
||||
if DoesEntityExist(vehicle) then
|
||||
ESX.Game.DeleteVehicle(vehicle)
|
||||
end
|
||||
|
||||
ESX.Game.SpawnLocalVehicle(vehicles[j].vehicle.model, {
|
||||
x = garage.Parkings[i].Pos.x,
|
||||
y = garage.Parkings[i].Pos.y,
|
||||
z = garage.Parkings[i].Pos.z + Config.ZDiff
|
||||
}, garage.Parkings[i].Heading, function(vehicle)
|
||||
ESX.Game.SetVehicleProperties(vehicle, vehicles[j].vehicle)
|
||||
end)
|
||||
|
||||
if DoesEntityExist(vehicle) then
|
||||
ESX.Game.DeleteVehicle(vehicle)
|
||||
end
|
||||
|
||||
ESX.Game.SpawnLocalVehicle(vehicles[j].vehicle.model, {
|
||||
x = garage.Parkings[i].Pos.x,
|
||||
y = garage.Parkings[i].Pos.y,
|
||||
z = garage.Parkings[i].Pos.z + Config.ZDiff
|
||||
}, garage.Parkings[i].Heading, function(vehicle)
|
||||
ESX.Game.SetVehicleProperties(vehicle, vehicles[j].vehicle)
|
||||
end)
|
||||
spawn(j)
|
||||
|
||||
end
|
||||
|
||||
spawn(j)
|
||||
end
|
||||
end
|
||||
|
||||
end, name)
|
||||
|
||||
end)
|
||||
|
||||
else
|
||||
|
||||
ESX.Game.Teleport(playerPed, {
|
||||
x = garage.InteriorSpawnPoint.Pos.x,
|
||||
y = garage.InteriorSpawnPoint.Pos.y,
|
||||
z = garage.InteriorSpawnPoint.Pos.z + Config.ZDiff
|
||||
}, function()
|
||||
|
||||
TriggerEvent('instance:create', 'garage')
|
||||
|
||||
ESX.TriggerServerCallback('esx_vehicleshop:getVehiclesInGarage', function(vehicles)
|
||||
|
||||
for i=1, #garage.Parkings, 1 do
|
||||
for j=1, #vehicles, 1 do
|
||||
|
||||
if i == vehicles[j].zone then
|
||||
|
||||
local spawn = function(j)
|
||||
|
||||
local vehicle = GetClosestVehicle(garage.Parkings[i].Pos.x, garage.Parkings[i].Pos.garage.Parkings[i].Pos.y, garage.Parkings[i].Pos.z, 2.0, 0, 71)
|
||||
|
||||
if DoesEntityExist(vehicle) then
|
||||
ESX.Game.DeleteVehicle(vehicle)
|
||||
end
|
||||
|
||||
ESX.Game.SpawnLocalVehicle(vehicles[j].vehicle.model, {
|
||||
x = garage.Parkings[i].Pos.x,
|
||||
y = garage.Parkings[i].Pos.y,
|
||||
z = garage.Parkings[i].Pos.z + Config.ZDiff
|
||||
}, garage.Parkings[i].Heading, function(vehicle)
|
||||
ESX.Game.SetVehicleProperties(vehicle, vehicles[j].vehicle)
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
spawn(j)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end, name)
|
||||
end, name)
|
||||
|
||||
end)
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
|
||||
ESX.Game.Teleport(playerPed, {
|
||||
|
||||
+10
-9
@@ -1,12 +1,13 @@
|
||||
Config = {}
|
||||
Config.DrawDistance = 100.0
|
||||
Config.MarkerType = 1
|
||||
Config.MarkerSize = {x = 2.0, y = 2.0, z = 1.0}
|
||||
Config.MarkerColor = {r = 204, g = 204, b = 0}
|
||||
Config.ParkingMarkerSize = {x = 3.0, y = 3.0, z = 2.0}
|
||||
Config.ParkingMarkerColor = {r = 102, g = 102, b = 204}
|
||||
Config.ZDiff = 0.5
|
||||
Config.EnableOwnedVehicles = true
|
||||
Config = {}
|
||||
Config.DrawDistance = 100.0
|
||||
Config.MarkerType = 1
|
||||
Config.MarkerSize = {x = 2.0, y = 2.0, z = 1.0}
|
||||
Config.MarkerColor = {r = 204, g = 204, b = 0}
|
||||
Config.ParkingMarkerSize = {x = 3.0, y = 3.0, z = 2.0}
|
||||
Config.ParkingMarkerColor = {r = 102, g = 102, b = 204}
|
||||
Config.ZDiff = 0.5
|
||||
Config.EnableOwnedVehicles = true
|
||||
Config.MinimumHealthPercent = 0
|
||||
|
||||
Config.Locale = 'fr'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user