for o = 1, #POLICE_STATIONS.parking_slot_general do
-- It's here that i want to test if a car is on the parking slot or not.
if ParkingSlotIsEmpty then
-- Get the nearest parking slot available
if GetDistanceBetweenCoords(POLICE_STATIONS.parking_slot_general[o][1],POLICE_STATIONS.parking_slot_general[o][2],POLICE_STATIONS.parking_slot_general[o][3],xA,yA,zA,false) < nearestDistance then
nearestDistance = GetDistanceBetweenCoords(POLICE_STATIONS.parking_slot_general[o][1],POLICE_STATIONS.parking_slot_general[o][2],POLICE_STATIONS.parking_slot_general[o][3],xA,yA,zA,false)
nearestPoint = o
end
end
end
I tried to place the GetClosestVehicle, IsAreaOccupied and isPositionOccupied instead of ParkingSlotIsEmpty. Theoretically, the parking lsot will be selected as the closest potential parkin space, only if the condition just above indicates that the parking slot is empty.
Otherwise, following my various tests, the vehicle continued to appear despite the fact that there is one. This generated among other things, in case of spam spawn, to spawn the vehicles into each other.
Here is an excerpt from the list of parking slot positions :
POLICE_STATIONS = {
parking_slot_general = {
{598.24,34.67,90.41,209.39}, -- Vinewood
{581.34,38.86,92.12,192.03}, -- Vinewood
{586.73,37.82,91.57,198.82}, -- Vinewood
{592.34,36.37,91.0,198.15}, -- Vinewood
{604.35,32.36,89.77,200.61}, -- Vinewood
{610.31,30.22,89.15,201.51}, -- Vinewood
{615.93,28.34,88.57,202.81}, -- Vinewood
{621.63,26.59,87.98,214.79}, -- Vinewood
{627.51,24.14,87.36,202.58}, -- Vinewood
{407.91,-998.57,28.87,238.99}, -- Mission Row
{408.05,-993.21,28.87,230.72}, -- Mission Row
{407.94,-988.84,29.02,231.48}, -- Mission Row
{408.39,-984.62,29.02,229.9}, -- Mission Row
{408.41,-980.08,29.02,231.26}, -- Mission Row
{431.32,-1027.79,28.67,359.35}, -- Mission Row
{428.0,-1028.07,28.59,175.79}, -- Mission Row
{435.04,-1027.32,28.46,0.75}, -- Mission Row
{438.76,-1027.18,28.39,0.94}, -- Mission Row
{442.58,-1026.58,28.32,180.12}, -- Mission Row
{446.76,-1025.97,28.24,2.33}, -- Mission Row
}
}
Thank you