mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
Minor cleanup (#32)
* Update for newest ESX * Minor cleanup * Update readme * Link fix in readme * I forgot this * And this * Minor cleanup 2
This commit is contained in:
+4
-53
@@ -1,8 +1,5 @@
|
||||
ESX = nil
|
||||
local LastGarage = nil
|
||||
local LastPart = nil
|
||||
local LastParking = nil
|
||||
local thisGarage = nil
|
||||
ESX = nil
|
||||
local LastGarage, LastPart, LastParking, thisGarage = nil, nil, nil, nil
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while ESX == nil do
|
||||
@@ -21,9 +18,7 @@ AddEventHandler('instance:onCreate', function(instance)
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
|
||||
if part == 'ExteriorEntryPoint' then
|
||||
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
local garage = Config.Garages[name]
|
||||
@@ -36,7 +31,6 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
end
|
||||
|
||||
if IsPedInAnyVehicle(playerPed, false) then
|
||||
|
||||
local vehicle = GetVehiclePedIsIn(playerPed, false)
|
||||
local maxHealth = GetEntityMaxHealth(vehicle)
|
||||
local health = GetEntityHealth(vehicle)
|
||||
@@ -45,7 +39,6 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
if healthPercent < Config.MinimumHealthPercent then
|
||||
ESX.ShowNotification(_U('veh_health'))
|
||||
else
|
||||
|
||||
if GetPedInVehicleSeat(vehicle, -1) == playerPed then
|
||||
|
||||
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
|
||||
@@ -73,7 +66,6 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
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)
|
||||
@@ -89,22 +81,15 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
}, garage.Parkings[i].Heading, function(vehicle)
|
||||
ESX.Game.SetVehicleProperties(vehicle, vehicles[j].vehicle)
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
spawn(j)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end, name)
|
||||
|
||||
end)
|
||||
|
||||
else
|
||||
|
||||
ESX.Game.Teleport(playerPed, {
|
||||
x = garage.InteriorSpawnPoint.Pos.x,
|
||||
y = garage.InteriorSpawnPoint.Pos.y,
|
||||
@@ -119,7 +104,6 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
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)
|
||||
@@ -139,22 +123,14 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
end
|
||||
|
||||
spawn(j)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end, name)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
ESX.Game.Teleport(playerPed, {
|
||||
x = garage.InteriorSpawnPoint.Pos.x,
|
||||
y = garage.InteriorSpawnPoint.Pos.y,
|
||||
@@ -169,7 +145,6 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
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)
|
||||
@@ -185,26 +160,18 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
}, garage.Parkings[i].Heading, function(vehicle)
|
||||
ESX.Game.SetVehicleProperties(vehicle, vehicles[j].vehicle)
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
spawn(j)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end, name)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if part == 'InteriorExitPoint' then
|
||||
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
local garage = thisGarage
|
||||
@@ -231,10 +198,8 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
|
||||
ESX.Game.SetVehicleEngineOn(vehicle, (not GetIsVehicleEngineRunning(vehicle)), false, true)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
|
||||
else
|
||||
|
||||
ESX.Game.Teleport(playerPed,{
|
||||
@@ -244,7 +209,6 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
}, function()
|
||||
TriggerEvent('instance:close')
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
for i=1, #garage.Parkings, 1 do
|
||||
@@ -264,7 +228,6 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
end
|
||||
|
||||
thisGarage = nil
|
||||
|
||||
end
|
||||
|
||||
if part == 'Parking' then
|
||||
@@ -283,11 +246,8 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
|
||||
if Config.EnableOwnedVehicles then
|
||||
TriggerServerEvent('esx_garage:updateOwnedVehicle', vehicleProps)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_property:hasExitedMarker', function(name, part, parking)
|
||||
@@ -301,9 +261,7 @@ AddEventHandler('esx_property:hasExitedMarker', function(name, part, parking)
|
||||
if IsPedInAnyVehicle(playerPed, false) and not IsAnyVehicleNearPoint(parkingPos.x, parkingPos.y, parkingPos.z, 1.0) then
|
||||
TriggerServerEvent('esx_garage:setParking', name, parking, false)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
-- Create Blips
|
||||
@@ -375,9 +333,7 @@ end)
|
||||
|
||||
-- Enter / Exit marker events
|
||||
Citizen.CreateThread(function()
|
||||
|
||||
while true do
|
||||
|
||||
Citizen.Wait(1)
|
||||
|
||||
local playerPed = PlayerPedId()
|
||||
@@ -403,7 +359,6 @@ Citizen.CreateThread(function()
|
||||
end
|
||||
|
||||
for i=1, #v.Parkings, 1 do
|
||||
|
||||
local parking = v.Parkings[i]
|
||||
|
||||
if (not v.disabled and GetDistanceBetweenCoords(coords, parking.Pos.x, parking.Pos.y, parking.Pos.z, true) < Config.ParkingMarkerSize.x) then
|
||||
@@ -412,10 +367,8 @@ Citizen.CreateThread(function()
|
||||
currentPart = 'Parking'
|
||||
currentParking = i
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if isInMarker and not HasAlreadyEnteredMarker or (isInMarker and (LastGarage ~= currentGarage or LastPart ~= currentPart or LastParking ~= currentParking) ) then
|
||||
@@ -433,11 +386,9 @@ Citizen.CreateThread(function()
|
||||
end
|
||||
|
||||
if not isInMarker and HasAlreadyEnteredMarker then
|
||||
|
||||
HasAlreadyEnteredMarker = false
|
||||
|
||||
|
||||
TriggerEvent('esx_property:hasExitedMarker', LastGarage, LastPart, LastParking)
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user