updated to allow re-using garages and exit on foot

- updated to fix bug where you can't exit garages on foot
- updated to allow you to re-use the same garage in multiple locations without randomly spawning at another location (see config for additional garage locations)
This commit is contained in:
aprilkae
2018-08-13 22:35:31 -04:00
committed by GitHub
parent 60cece3a0c
commit 6f232d9250
2 changed files with 333 additions and 43 deletions
+59 -40
View File
@@ -1,7 +1,8 @@
ESX = nil
local LastGarage = nil
local LastPart = nil
local LastParking = nil
ESX = nil
local LastGarage = nil
local LastPart = nil
local LastParking = nil
local thisGarage = nil
Citizen.CreateThread(function()
while ESX == nil do
@@ -19,13 +20,20 @@ AddEventHandler('instance:onCreate', function(instance)
end
end)
AddEventHandler('esx_property:hasEnteredMarker', function(name, part, parking)
AddEventHandler('esx_garage:hasEnteredMarker', function(name, part, parking)
if part == 'ExteriorEntryPoint' then
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
local garage = Config.Garages[name]
thisGarage = garage
for i=1, #Config.Garages, 1 do
if Config.Garages[i].name ~= name then
Config.Garages[i].disabled = true
end
end
if IsPedInAnyVehicle(playerPed, false) then
@@ -199,7 +207,7 @@ AddEventHandler('esx_property:hasEnteredMarker', function(name, part, parking)
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
local garage = Config.Garages[name]
local garage = thisGarage
if IsPedInAnyVehicle(playerPed, false) then
@@ -221,6 +229,7 @@ AddEventHandler('esx_property:hasEnteredMarker', function(name, part, parking)
ESX.Game.SpawnVehicle(vehicleProps.model, spawnCoords, garage.ExteriorSpawnPoint.Heading, function(vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
ESX.Game.SetVehicleEngineOn(vehicle, (not GetIsVehicleEngineRunning(vehicle)), false, true)
end)
end)
@@ -228,7 +237,11 @@ AddEventHandler('esx_property:hasEnteredMarker', function(name, part, parking)
else
ESX.Game.Teleport(playerPed,garage.ExteriorSpawnPoint.Pos.x, function()
ESX.Game.Teleport(playerPed,{
x = garage.ExteriorSpawnPoint.Pos.x,
y = garage.ExteriorSpawnPoint.Pos.y,
z = garage.ExteriorSpawnPoint.Pos.z
}, function()
TriggerEvent('instance:close')
end)
@@ -243,13 +256,21 @@ AddEventHandler('esx_property:hasEnteredMarker', function(name, part, parking)
end
end
for i=1, #Config.Garages, 1 do
if Config.Garages[i].name ~= name then
Config.Garages[i].disabled = false
end
end
thisGarage = nil
end
if part == 'Parking' then
local playerPed = PlayerPedId()
local garage = Config.Garages[name]
local garage = thisGarage
local parkingPos = garage.Parkings[parking].Pos
if IsPedInAnyVehicle(playerPed, false) and not IsAnyVehicleNearPoint(parkingPos.x, parkingPos.y, parkingPos.z, 1.0) then
@@ -274,13 +295,13 @@ AddEventHandler('esx_property:hasExitedMarker', function(name, part, parking)
if part == 'Parking' then
local playerPed = PlayerPedId()
local garage = Config.Garages[name]
local garage = thisGarage
local parkingPos = garage.Parkings[parking].Pos
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)
@@ -323,11 +344,11 @@ Citizen.CreateThread(function()
if v.IsClosed then
if(GetDistanceBetweenCoords(coords, v.ExteriorEntryPoint.Pos.x, v.ExteriorEntryPoint.Pos.y, v.ExteriorEntryPoint.Pos.z, true) < Config.DrawDistance) then
if(not v.disabled and GetDistanceBetweenCoords(coords, v.ExteriorEntryPoint.Pos.x, v.ExteriorEntryPoint.Pos.y, v.ExteriorEntryPoint.Pos.z, true) < Config.DrawDistance) then
DrawMarker(Config.MarkerType, v.ExteriorEntryPoint.Pos.x, v.ExteriorEntryPoint.Pos.y, v.ExteriorEntryPoint.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
end
if(GetDistanceBetweenCoords(coords, v.InteriorExitPoint.Pos.x, v.InteriorExitPoint.Pos.y, v.InteriorExitPoint.Pos.z, true) < Config.DrawDistance) then
if(not v.disabled and GetDistanceBetweenCoords(coords, v.InteriorExitPoint.Pos.x, v.InteriorExitPoint.Pos.y, v.InteriorExitPoint.Pos.z, true) < Config.DrawDistance) then
DrawMarker(Config.MarkerType, v.InteriorExitPoint.Pos.x, v.InteriorExitPoint.Pos.y, v.InteriorExitPoint.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
end
@@ -339,7 +360,7 @@ Citizen.CreateThread(function()
local parking = v.Parkings[i]
if(GetDistanceBetweenCoords(coords, parking.Pos.x, parking.Pos.y, parking.Pos.z, true) < Config.DrawDistance) then
if(not v.disabled and GetDistanceBetweenCoords(coords, parking.Pos.x, parking.Pos.y, parking.Pos.z, true) < Config.DrawDistance) then
DrawMarker(Config.MarkerType, parking.Pos.x, parking.Pos.y, parking.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.ParkingMarkerSize.x, Config.ParkingMarkerSize.y, Config.ParkingMarkerSize.z, Config.ParkingMarkerColor.r, Config.ParkingMarkerColor.g, Config.ParkingMarkerColor.b, 100, false, true, 2, false, false, false, false)
end
@@ -357,7 +378,7 @@ Citizen.CreateThread(function()
while true do
Wait(0)
Citizen.Wait(1)
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
@@ -365,37 +386,35 @@ Citizen.CreateThread(function()
local currentGarage = nil
local currentPart = nil
local currentParking = nil
for k,v in pairs(Config.Garages) do
if v.IsClosed then
if v.IsClosed then
if (not v.disabled and GetDistanceBetweenCoords(coords, v.ExteriorEntryPoint.Pos.x, v.ExteriorEntryPoint.Pos.y, v.ExteriorEntryPoint.Pos.z, true) < Config.MarkerSize.x) then
isInMarker = true
currentGarage = k
currentPart = 'ExteriorEntryPoint'
end
if GetDistanceBetweenCoords(coords, v.ExteriorEntryPoint.Pos.x, v.ExteriorEntryPoint.Pos.y, v.ExteriorEntryPoint.Pos.z, true) < Config.MarkerSize.x then
isInMarker = true
currentGarage = k
currentPart = 'ExteriorEntryPoint'
end
if (not v.disabled and GetDistanceBetweenCoords(coords, v.InteriorExitPoint.Pos.x, v.InteriorExitPoint.Pos.y, v.InteriorExitPoint.Pos.z, true) < Config.MarkerSize.x) then
isInMarker = true
currentGarage = k
currentPart = 'InteriorExitPoint'
end
for i=1, #v.Parkings, 1 do
if GetDistanceBetweenCoords(coords, v.InteriorExitPoint.Pos.x, v.InteriorExitPoint.Pos.y, v.InteriorExitPoint.Pos.z, true) < Config.MarkerSize.x then
isInMarker = true
currentGarage = k
currentPart = 'InteriorExitPoint'
end
local parking = v.Parkings[i]
for i=1, #v.Parkings, 1 do
if (not v.disabled and GetDistanceBetweenCoords(coords, parking.Pos.x, parking.Pos.y, parking.Pos.z, true) < Config.ParkingMarkerSize.x) then
isInMarker = true
currentGarage = k
currentPart = 'Parking'
currentParking = i
end
local parking = v.Parkings[i]
if GetDistanceBetweenCoords(coords, parking.Pos.x, parking.Pos.y, parking.Pos.z, true) < Config.ParkingMarkerSize.x then
isInMarker = true
currentGarage = k
currentPart = 'Parking'
currentParking = i
end
end
end
end
end
end
@@ -410,7 +429,7 @@ Citizen.CreateThread(function()
LastPart = currentPart
LastParking = currentParking
TriggerEvent('esx_property:hasEnteredMarker', currentGarage, currentPart, currentParking)
TriggerEvent('esx_garage:hasEnteredMarker', currentGarage, currentPart, currentParking)
end
if not isInMarker and HasAlreadyEnteredMarker then
+274 -3
View File
@@ -9,7 +9,7 @@ Config.ZDiff = 0.5
Config.EnableOwnedVehicles = true
Config.MinimumHealthPercent = 0
Config.Locale = 'fr'
Config.Locale = 'en'
Config.Zones = {}
@@ -18,7 +18,7 @@ Config.Garages = {
MiltonDrive = {
IsClosed = true,
ExteriorEntryPoint = {
Pos = {x= -796.542, y = 318.137, z = 84.673},
},
@@ -80,6 +80,277 @@ Config.Garages = {
},
}
}
},
IntegrityWay = {
IsClosed = true,
ExteriorEntryPoint = {
Pos = {x= -37.01, y = -702.82, z = 31.34},
},
ExteriorSpawnPoint = {
Pos = {x = -34.79, y = -697.73, z = 32.34},
Heading = 350.42
},
InteriorSpawnPoint = {
Pos = {x = 228.930, y = -1000.698, z = -100.000},
Heading = 0.0
},
InteriorExitPoint = {
Pos = {x = 224.613, y = -1004.769, z = -100.000},
},
Parkings = {
{
Pos = {x = 224.500, y = -998.695, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 224.500, y = -994.630, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 224.500, y = -990.255, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 224.500, y = -986.628, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 224.500, y = -982.496, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 232.500, y = -982.496, z = -100.000},
Heading = 135.0
},
{
Pos = {x = 232.500, y = -986.628, z = -100.000},
Heading = 135.0
},
{
Pos = {x = 232.500, y = -990.255, z = -100.000},
Heading = 135.0
},
{
Pos = {x = 232.500, y = -994.630, z = -100.000},
Heading = 135.0
},
{
Pos = {x = 232.500, y = -998.695, z = -100.000},
Heading = 135.0
},
}
},
DidionWay = {
IsClosed = true,
ExteriorEntryPoint = {
Pos = {x= -259.88, y = 395.19, z = 109.02},
},
ExteriorSpawnPoint = {
Pos = {x = -259.82, y = 397.33, z = 109.01},
Heading = 12.15
},
InteriorSpawnPoint = {
Pos = {x = 202.27, y = -1004.1, z =-100.00},
Heading = 0.0
},
InteriorExitPoint = {
Pos = {x = 196.69, y = -1006.26, z = -100.000},
},
Parkings = {
{
Pos = {x = 193.06, y = -995.95, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 192.61, y = -1000.16, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 192.06, y = -1003.64, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 205.85, y = -1002.17, z = -100.000},
Heading = 105.0
},
{
Pos = {x =201.98, y = -996.98, z = -100.000},
Heading = 175.0
},
{
Pos = {x = 198.33, y = -996.42, z = -100.000},
Heading = 175.0
},
}
},
VinewoodEstate2650 = {
IsClosed = true,
ExteriorEntryPoint = {
Pos = {x= -102.79, y = 824.03, z = 234.73},
},
ExteriorSpawnPoint = {
Pos = {x = -106.94, y =833.55, z = 234.72},
Heading = 346.42
},
InteriorSpawnPoint = {
Pos = {x = 228.930, y = -1000.698, z = -100.000},
Heading = 0.0
},
InteriorExitPoint = {
Pos = {x = 224.613, y = -1004.769, z = -100.000},
},
Parkings = {
{
Pos = {x = 224.500, y = -998.695, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 224.500, y = -994.630, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 224.500, y = -990.255, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 224.500, y = -986.628, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 224.500, y = -982.496, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 232.500, y = -982.496, z = -100.000},
Heading = 135.0
},
{
Pos = {x = 232.500, y = -986.628, z = -100.000},
Heading = 135.0
},
{
Pos = {x = 232.500, y = -990.255, z = -100.000},
Heading = 135.0
},
{
Pos = {x = 232.500, y = -994.630, z = -100.000},
Heading = 135.0
},
{
Pos = {x = 232.500, y = -998.695, z = -100.000},
Heading = 135.0
},
}
},
ImaginationCt265 = {
IsClosed = true,
ExteriorEntryPoint = {
Pos = {x=-1129.65, y = -1072.38, z = 1.15},
},
ExteriorSpawnPoint = {
Pos = {x = -1126.48, y =-1069.065, z =1.1},
Heading = 15.87
},
InteriorSpawnPoint = {
Pos = {x = 174.11, y = -1007.15, z = -100.000},
Heading = 0.0
},
InteriorExitPoint = {
Pos = {x = 171.71, y = -1007.4, z = -100.000},
},
Parkings = {
{
Pos = {x = 176.07, y = -1001.51, z = -100.000},
Heading = 173.03
},
{
Pos = {x = 170.73, y = -1002.39, z = -100.000},
Heading = 173.03
},
}
},
SteeleWay1150 = {
IsClosed = true,
ExteriorEntryPoint = {
Pos = {x= -924.81, y = 211.54, z = 66.46},
},
ExteriorSpawnPoint = {
Pos = {x =-931.5, y = 210.98, z = 66.46},
Heading = 12.15
},
InteriorSpawnPoint = {
Pos = {x = 202.27, y = -1004.1, z =-100.00},
Heading = 0.0
},
InteriorExitPoint = {
Pos = {x = 196.69, y = -1006.26, z = -100.000},
},
Parkings = {
{
Pos = {x = 193.06, y = -995.95, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 192.61, y = -1000.16, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 192.06, y = -1003.64, z = -100.000},
Heading = 225.0
},
{
Pos = {x = 205.85, y = -1002.17, z = -100.000},
Heading = 105.0
},
{
Pos = {x =201.98, y = -996.98, z = -100.000},
Heading = 175.0
},
{
Pos = {x = 198.33, y = -996.42, z = -100.000},
Heading = 175.0
},
}
},
}