Auto set to closest destination


How would I go about making it so when someone inputs a destination like the 24/7 or LS customs that it would set it to the closest one to the player?


Get the player coordinates then compare it to all the destinations then you can get the closest.
I can show you a sample when I get home.


That would be great


Sry, I forgot it.

listofshops = {
    {x = 100, y = 100, z = 100},
    {x = 100, y = 100, z = 100} -- random cords
closest = nil
closestshop = nil
for _, shop in pairs(listofshops) do
    cords = GetEntityCoords(PlayerPedId())
    distance = GetDistanceBetweenCoords(cords.x, cords.y, cords.z, shop.x, shop.y, shop, z, false)
    if closest == nil then
        closest = distance
        closestshop = shop
        if distance < closest then
            closest = distance
            closestshop = shop

closestshop is the value you need
This should work however I didn’t tested it.


Ok thank you so much