Thank you this worked.
Can someone tell me how I can edit the script to be able to park boats and planes and helicopters and so on?
Do you know of a way to make a garage for only police and ems with this?
Hi, itâs actually not that complicated. Ill give an example, but i wrote it in portuguese
First you need to add garages to your config.lua:
Config.GaragemPrivadas = {
policia = { -- name of the garage
trabalho = 'police', -- job
offtrabalho = 'offpolice', -- off service because i use esx_duty
garageName = "Garagem Privada PSP", -- text that will show up at the marker
getVehicle = vector3(457.331, -978.633, 25.690),
spawnPoint = {
coords = vector3(449.808, -976.428, 25.821),
heading = 88.593
},
storeVehicle = vector3(452.439, -990.013, 25.690)
}
}
Then you will beed to load up the new garages on the client.lua this is 2 parts, one to store the vehicle and another to pick up the vehicle. Just add this next to the other garages / impounds:
-- Garagens Privadas (para trabalhadores psp inem mecanico etc)
--criacao de blip por trabalho para garagem privada
--apenas quando estiverem de servico vao ter acesso a garagem
for k, v in pairs (Config.GaragemPrivadas) do
if ESX.PlayerData.job.name == v.trabalho or ESX.PlayerData.job.name == v.offtrabalho then
if GetDistanceBetweenCoords(playerPosition, v.getVehicle.x, v.getVehicle.y, v.getVehicle.z) <= 15 then
DrawMarker(2, v.getVehicle.x, v.getVehicle.y, v.getVehicle.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.2, 0.15, 255, 0, 0, 222, false, false, false, true, false, false, false)
if GetDistanceBetweenCoords(playerPosition, v.getVehicle.x, v.getVehicle.y, v.getVehicle.z) <= 1.5 then
if not IsPedInAnyVehicle(playerPed) then
DrawText3D(v.getVehicle.x, v.getVehicle.y, v.getVehicle.z + 0.25, '~g~E~w~ - Abrir Garagem')
if IsControlJustReleased(0, 38) then
openGarageMenu(k)
currentGarage = v
end
end
elseif GetDistanceBetweenCoords(playerPosition, v.getVehicle.x, v.getVehicle.y, v.getVehicle.z) <= 5 then
DrawText3D(v.getVehicle.x, v.getVehicle.y, v.getVehicle.z + 0.25, v.garageName)
end
end
-- criacao de blip para levantar o carro!
if IsPedInAnyVehicle(playerPed) then
if GetDistanceBetweenCoords(playerPosition, v.storeVehicle.x, v.storeVehicle.y, v.storeVehicle.z) <= 15 then
DrawMarker(1, v.storeVehicle.x, v.storeVehicle.y, v.storeVehicle.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5, 1.9, 1.0, 200, 0, 0, 222, false, false, false, true, false, false, false)
if GetDistanceBetweenCoords(playerPosition, v.storeVehicle.x, v.storeVehicle.y, v.storeVehicle.z) <= 2.5 then
DrawText3D(v.storeVehicle.x, v.storeVehicle.y, v.storeVehicle.z + 0.25, '~g~E~w~ - Guardar VeĂculo')
if IsControlJustReleased(0, 38) then
storeVehicle(k)
currentGarage = v
end
elseif GetDistanceBetweenCoords(playerPosition, v.storeVehicle.x, v.storeVehicle.y, v.storeVehicle.z) <= 5 then
DrawText3D(v.storeVehicle.x, v.storeVehicle.y, v.storeVehicle.z + 0.25, 'Estacionar veĂculo...')
end
end
end
end
end
Let me know how it goes
And how would I add the vehicles to the police garage? Just spawn them as admin and put them in for everyone to use?
I think I understood it wrong. I thought I asked for the employees to be able to park at their work. So they can drive their own cars to the police station for example and park them there.
But u want this for the ems institutions to have their garage? So they can store their emergency vehicles right?
Yes this is correct a garage that only police can use and has a list of cars in the garage and an ems garage with only ems vehicles in the garage
I wouldnât use this garage for that because that would imply changing too many scripts. For that you have the garage esx_policejob or the esx_PoliceGarage.
Yeah I just liked the idea of it being a constant garage with damages recorded and the lightweight system this uses. Ahh too bad
Doesnât work for me, I canât take my parked vehicle even if stored == 1, it skips the if condiction and tells me the vehicle is probably impound, but actually itâs not
Def wanna go into your DB and set TINYINT to INT(1)
add a print(ESX.PlayerData.job.name, v.job) before the line 77
1 of those values is nil, we need to be sure which one of them. At first sight i dont see anything wrong. Will only be able to run / test tonight.
@Pride1922 put that right above on line 76 and it says this now:
print(ESX.PlayerData.job.name, v.job)
for k, v in pairs (Config.PoliceGarage) do
if ESX.PlayerData.job.name == v.job or ESX.PlayerData.job.name == v.offjob then
if GetDistanceBetweenCoords(playerPosition, v.getVehicle.x, v.getVehicle.y, v.getVehicle.z) <= 15 then
DrawMarker(2, v.getVehicle.x, v.getVehicle.y, v.getVehicle.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.2, 0.15, 255, 0, 0, 222, false, false, false, true, false, false, false)
if GetDistanceBetweenCoords(playerPosition, v.getVehicle.x, v.getVehicle.y, v.getVehicle.z) <= 1.5 then
if not IsPedInAnyVehicle(playerPed) then
DrawText3D(v.getVehicle.x, v.getVehicle.y, v.getVehicle.z + 0.25, '~g~E~w~ - Open Garage')
if IsControlJustReleased(0, 38) then
openGarageMenu(k)
currentGarage = v
end
end
elseif GetDistanceBetweenCoords(playerPosition, v.getVehicle.x, v.getVehicle.y, v.getVehicle.z) <= 5 then
DrawText3D(v.getVehicle.x, v.getVehicle.y, v.getVehicle.z + 0.25, v.garageName)
end
end
for k, v in pairs (Config.PoliceGarage) do
print(ESX.PlayerData.job.name, v.job)
if ESX.PlayerData.job.name == v.job or ESX.PlayerData.job.name == v.offjob then
if GetDistanceBetweenCoords(playerPosition, v.getVehicle.x, v.getVehicle.y, v.getVehicle.z) <= 15 then
DrawMarker(2, v.getVehicle.x, v.getVehicle.y, v.getVehicle.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.2, 0.15, 255, 0, 0, 222, false, false, false, true, false, false, false)
if GetDistanceBetweenCoords(playerPosition, v.getVehicle.x, v.getVehicle.y, v.getVehicle.z) <= 1.5 then
if not IsPedInAnyVehicle(playerPed) then
DrawText3D(v.getVehicle.x, v.getVehicle.y, v.getVehicle.z + 0.25, '~g~E~w~ - Open Garage')
if IsControlJustReleased(0, 38) then
openGarageMenu(k)
currentGarage = v
end
end
elseif GetDistanceBetweenCoords(playerPosition, v.getVehicle.x, v.getVehicle.y, v.getVehicle.z) <= 5 then
DrawText3D(v.getVehicle.x, v.getVehicle.y, v.getVehicle.z + 0.25, v.garageName)
end
end
Dropped that in and still getting the main.lua 77 attempt to index a nil value (field âjobâ)
eeeek
look at your F8 console, at the error you should have more information (from the print command)
could you post a photo from it here pls?
I got another image for ya as well.
FINALLY got it to print:
BTW it does work if I ensure it after loading into the game completely MANUALLY, but it does not start without me ensuring it after joining and after it spit that error.