#include "../../config/events.lua"
#include "../../script/helpers/entity.lua"
#include "../../script/helpers/utils.lua"

local loc_tr, vehs

function init()
    loc_tr = GetLocationTransform(FindLocation("move"))
    vehs = FindVehicles()

    RegisterListenerTo(EVENTS.MAIN_FIRST_TICK, "OnFirstTick")
end

function OnFirstTick()
    UnregisterListener(EVENTS.MAIN_FIRST_TICK, "OnFirstTick")

    for i = 1, #vehs do
        local veh = vehs[i]
        if IsHandleValid(veh) then
            utils:TeleportBody(GetVehicleBody(veh), loc_tr)
        end
    end

    cEntity:EnqueueDeletion()
end
