как работает этот код? 	local events = require('samp.events')
local ffi = require('ffi')
local sampfuncs = require('sampfuncs')
local raknet = require('samp.raknet')
local memory = require ('memory')
local renderFont = renderCreateFont('Arial', 7, 4)
local font = renderCreateFont('Arial', 9, 4)

function SCMF(...) return sampAddChatMessage(string.format('{696969}[DCTeleport]:{FFFFFF} %s', string.format(...)), -1) end

local TELEPORT = {
    STATE = false,
    BOOST = false,
    RENDER = true,
    lPackets = 0,
    sPackets = 0,
    STEP = 9,
    PLOSS = 0,
    DISTANCE = 0,
    PROCENT = 0,
    CIRCLE = {0, 0, 0},
    --VEHICLES = {449, 433, 408, 582, 578, 413, 407, 456, 430, 570, 455, 446, 483, 544, 452, 414, 443, 453, 454, 472, 473, 478, 484, 493, 554, 543, 595, 422, 605, 600, 567}
	VEHICLES = 
	{
		602, 545, 496, 517, 401, 410, 518, 600, 527, 436, 589, 580, 419, 439, 533, 549, 526, 491, 474, 445, 467, 604, 426, 507, 547, 585, 405, 587,
		409, 466, 550, 492, 566, 546, 540, 551, 421, 516, 529, 592, 553, 577, 488, 511, 497, 548, 563, 512, 476, 593, 447, 425, 519, 520, 460, 417,
		469, 487, 513, 581, 510, 509, 522, 481, 461, 462, 448, 521, 468, 463, 586, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 485, 552, 431,
		438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 523, 470, 598, 499, 588, 609, 403, 498, 514,
		524, 423, 532, 414, 578, 443, 486, 515, 406, 531, 573, 456, 455, 459, 543, 422, 583, 482, 478, 605, 554, 530, 418, 572, 582, 413, 440, 536,
		575, 534, 567, 535, 576, 412, 402, 542, 603, 475, 449, 537, 538, 570, 441, 464, 501, 465, 564, 568, 557, 424, 471, 504, 495, 457, 539, 483,
		508, 571, 500, 444, 556, 429, 411, 541, 559, 415, 561, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489,
		505, 479, 442, 458, 606, 607, 610, 590, 569, 611, 584, 608, 435, 450, 591, 594 
	}
};

function Draw3DCircle(x, y, z, radius, color)
    local screen_x_line_old, screen_y_line_old;
    for rot = 0, 360 do
        local rot_temp = math.rad(rot)
        local lineX, lineY, lineZ = radius * math.cos(rot_temp) + x, radius * math.sin(rot_temp) + y, z
        local screen_x_line, screen_y_line = convert3DCoordsToScreen(lineX, lineY, lineZ)
        if screen_x_line ~= nil and screen_x_line_old ~= nil and isPointOnScreen(lineX, lineY, lineZ, 1) then 
            renderDrawLine(screen_x_line, screen_y_line, screen_x_line_old, screen_y_line_old, 3, color) 
        end
        screen_x_line_old, screen_y_line_old = screen_x_line, screen_y_line
    end
end

function rainbow(speed, alpha)
    local time = os.clock()
    return (math.sin(time * speed) * 127 + 128), (math.sin(time * speed + 2) * 127 + 128), (math.sin(time * speed + 4) * 127 + 128), alpha
end

function join_argb(a, r, g, b)
    local argb = b  -- b
    argb = bit.bor(argb, bit.lshift(g, 8))  -- g
    argb = bit.bor(argb, bit.lshift(r, 16)) -- r
    argb = bit.bor(argb, bit.lshift(a, 24)) -- a
    return argb
end

function main()
    while not isSampAvailable() do wait(0) end 
    SCMF('Успешно загружен [t.me/quesada_team]')
    sampRegisterChatCommand('dctp',
    function(value)
        checkValue(value)
    end)
    while true do wait(0)
        if TELEPORT.STATE then 
            local PLAYER_POS = {getCharCoordinates(PLAYER_PED)}
            local wX, wY = convert3DCoordsToScreen(PLAYER_POS[1], PLAYER_POS[2], PLAYER_POS[3])
            local hypebarpizdazalupa = ('{32CD32}*'):rep(math.floor(TELEPORT.PROCENT / 99 * 6)) .. ('-'):rep(math.ceil((99 - TELEPORT.PROCENT) / 99 * 6))
            if TELEPORT.CIRCLE[1] ~= 0 then 
                Draw3DCircle(TELEPORT.CIRCLE[1], TELEPORT.CIRCLE[2], TELEPORT.CIRCLE[3] - 0.1, 1.5, 0xff20b2aa)
            end
            renderFontDrawText(font, string.format('Teleporting %s{FFFFFF} {20b2aa}(%d%%){FFFFFF}\nlPackets {20b2aa}(%d/%d){FFFFFF}\npLoss {20b2aa}(%d)', hypebarpizdazalupa, TELEPORT.PROCENT, TELEPORT.sPackets, TELEPORT.lPackets, TELEPORT.PLOSS), wX, wY - 0.1, -1)
        else
            if TELEPORT.RENDER then 
                local result, vehicleId = getAvailableVehicle(300, false, false)
                if result then 
                    local handle = select(2, sampGetCarHandleBySampVehicleId(vehicleId))
                    local CAR_POS = {getCarCoordinates(handle)}
                    if isPointOnScreen(CAR_POS[1], CAR_POS[2], CAR_POS[3], 5) then 
                        local wX, wY = convert3DCoordsToScreen(CAR_POS[1], CAR_POS[2], CAR_POS[3])
                        local r, g, b, a = rainbow(1, 255)
                        renderFontDrawText(renderFont, string.format('AVAILABLE TO TELEPORT! [VehicleID: %d]', vehicleId), wX - 20, wY, join_argb(a, r, g, b))
                    end
                end
            end
        end
    end
end

function TogglePlayerControlable(value)
    bitStream = raknetNewBitStream()
    raknetBitStreamWriteInt8(bitStream, value)
    raknetEmulRpcReceiveBitStream(15, bitStream)
    raknetDeleteBitStream(bitStream)
end

function checkValue(value)
    if TELEPORT.STATE then 
        return SCMF('Подождите уже телепортируемся!') 
    end
    if value == 'render' then 
        TELEPORT.RENDER = not TELEPORT.RENDER
        return 
    end
    if value == 'cpm' or value == 'CPM' then 
        result, x, y, z = SearchMarker()
    else
        result, x, y, z = getTargetBlipCoordinatesFixed()
    end
    if result then 
        if isCharOnFoot(PLAYER_PED) then 
            if select(1, getAvailableVehicle(45, false, false)) then 
                local vehicleId = select(2, getAvailableVehicle(45, false, false))
                local CAR_POS = {getCarCoordinates(select(2, sampGetCarHandleBySampVehicleId(vehicleId)))}
                for i = 1, 3 do TELEPORT.CIRCLE[i] = CAR_POS[i] end
                TELEPORT.STATE = true;
                lua_thread.create(function()
                    wait(0)
                    PLAYER_SYNC(0, CAR_POS[1], CAR_POS[2], CAR_POS[3], false)
                    wait(300)
                    TELEPORT_LOOP(vehicleId, x, y, z, CAR_POS[1], CAR_POS[2], CAR_POS[3])
                end)
            end
        elseif isCharInAnyCar(PLAYER_PED) then 
            SCMF('Ну в машине патом будет')
        else
            SCMF('эээ хз чо написать подпишись пж сюда t.me/quesada_team')
        end
    else
        SCMF('Метка не найдена!')
    end
end

function TELEPORT_LOOP(vehicleId, x, y, z, cx, cy, cz)
    if TELEPORT.STATE then 
        local vehicleHandle = select(2, sampGetCarHandleBySampVehicleId(vehicleId))

        local vector = 
        {   vX = x - cx, 
            vY = y - cy, 
            vZ = z - cz 
        } 

        local vecDist = getDistanceBetweenCoords3d(x, y, z, cx, cy, cz)
        local DISTANCE = getDistanceBetweenCoords3d(x, y, z, cx, cy, cz)

        if vecDist > 300 then 
            TELEPORT.BOOST = true;
        end

        while DISTANCE > TELEPORT.STEP and TELEPORT.STATE do 
            DISTANCE = getDistanceBetweenCoords3d(x, y, z, cx, cy, cz)
            TELEPORT.DISTANCE = DISTANCE
            TELEPORT.PROCENT = math.floor(100 - (DISTANCE / vecDist) * 100)

            mx = vector.vX / vecDist;
            my = vector.vY / vecDist;
            mz = vector.vZ / vecDist;

            cx = cx + mx * TELEPORT.STEP
            cy = cy + my * TELEPORT.STEP
            cz = cz + mz * TELEPORT.STEP

            PLAYER_SYNC(0, cx, cy, cz, false)
            UNOCCUPIED_SYNC(vehicleId, cx, cy, cz)
            PLAYER_SYNC(vehicleId, cx, cy, cz, true)
            if DISTANCE < 300 and TELEPORT.BOOST then 
                TELEPORT.BOOST = false;
            end
        end

        TogglePlayerControlable(0)

        while TELEPORT.lPackets ~= TELEPORT.sPackets and TELEPORT.PLOSS < 5 do wait(0)
            TELEPORT.PLOSS = TELEPORT.PLOSS + 1
            if TELEPORT.PLOSS < 5 then 
                wait(1000)
            end
        end

        setCharCoordinates(PLAYER_PED, x, y, z)
        setCarCoordinates(vehicleHandle, x + 2, y + 3, z - 2)

        PLAYER_SYNC(0, x, y, z, false)
        UNOCCUPIED_SYNC(vehicleId, x, y, z)

        TogglePlayerControlable(1)
        wait(200)

        resetTeleport('ONFOOT')
    end
end

function resetTeleport(type)
    if type == 'ONFOOT' then 
        TELEPORT.lPackets = 0;
        TELEPORT.sPackets = 0;
        TELEPORT.PLOSS = 0;
        TELEPORT.DISTANCE = 0;
        TELEPORT.PROCENT = 0;
        TELEPORT.CIRCLE[1] = 0;
        TELEPORT.STATE = false 
        TogglePlayerControlable(1)
    end
end

function onReceivePacket(id, bitStream, priority, reliability, orderingChannel)
    if TELEPORT.STATE then  
        if id == 32 then 
            resetTeleport('ONFOOT')
        end
    end
end

function events.onSetPlayerPos()
    if TELEPORT.STATE then 
        if TELEPORT.PLOSS > 0 then 
            TELEPORT.PLOSS = TELEPORT.PLOSS - 1
        end
        TELEPORT.sPackets = TELEPORT.sPackets + 1
        return false 
    end
end

function UNOCCUPIED_SYNC(vehicleId, x, y, z)
    local vehicleHandle = select(2, sampGetCarHandleBySampVehicleId(vehicleId))
    local rx, ry, rz, dx, dy, dz = getCarRealMatrix(vehicleHandle)
    local data = samp_create_sync_data('unoccupied')
    data.roll = {rx, ry, rz}
    data.direction = {dx, dy, dz}
    data.vehicleId = tonumber(vehicleId)
    data.moveSpeed = {0.09, 0.11, -0.15}
    data.turnSpeed = {-0.016, 0.016, 0.09}
    data.seatId = 0
    data.position = {x, y, z}
    data.send()
end

function PLAYER_SYNC(vehicleId, x, y, z, setPos)
    local data = samp_create_sync_data('player')
    if vehicleId ~= 0 then 
        data.surfingVehicleId = tonumber(vehicleId)
        data.surfingOffsets = {1, 1, -50}
    end
    data.moveSpeed = {0.16, 0.16, -0.44}
    if setPos then 
        TELEPORT.lPackets = TELEPORT.lPackets + 1
        data.position = {x, y, z - 50}
    else 
        data.position = {x, y, z}
    end
    data.send()
end

function events.onVehicleStreamIn()
    if TELEPORT.BOOST then 
        return false 
    end
end

function events.onCreateObject(objectId, data)
    if TELEPORT.BOOST then 
        return false 
    end
end

function events.onSendPlayerSync(data)
    if TELEPORT.STATE then 
        return false 
    end
end

function events.onSendUnoccupiedSync(data)
    if TELEPORT.STATE or TELEPORT.INCAR then 
        return false 
    end
end

function isAvailableModel(handle)
    for k, v in ipairs(TELEPORT.VEHICLES) do 
        if getCarModel(handle) == v then 
            return true 
        end
    end
    return false 
end

function getAvailableVehicle(searchDistance, passenger, driver)
    local PLAYER_POS = {getCharCoordinates(PLAYER_PED)}
    for k, handle in pairs(getAllVehicles()) do
        local result, vehicleId = sampGetVehicleIdByCarHandle(handle)
        if result then 
            local vehicleDriver = getDriverOfCar(handle) ~= -1
            if (not driver and not vehicleDriver) or (driver and vehicleDriver) then 
                local CAR_POS = {getCarCoordinates(handle)}
                local DISTANCE = getDistanceBetweenCoords3d(CAR_POS[1], CAR_POS[2], CAR_POS[3], PLAYER_POS[1], PLAYER_POS[2], PLAYER_POS[3])
                if (not passenger or getMaximumNumberOfPassengers(handle) > 0) and DISTANCE < searchDistance then 
                    if isAvailableModel(handle) then 
                        return true, vehicleId
                    end
                end
            end
        end
    end
    return false, -1
end

function getTargetBlipCoordinatesFixed()
    local bool, x, y, z = getTargetBlipCoordinates(); 
    if not bool then return false end
    requestCollision(x, y) 
    loadScene(x, y, z)
    local bool, x, y, z = getTargetBlipCoordinates()
    return bool, x, y, z
end

function SearchMarker(x, y, z)
    local ret_pos = {0.0, 0.0, 0.0}
    local isFind = false
    for id = 0, 31 do
        local MarkerStruct = 0
        MarkerStruct = 0xC7F168 + id * 56
        local Marker = {
            representIntAsFloat(readMemory(MarkerStruct + 0, 4, false)),
            representIntAsFloat(readMemory(MarkerStruct + 4, 4, false)),
            representIntAsFloat(readMemory(MarkerStruct + 8, 4, false))
        }
        if Marker[1] ~= 0.0 or Marker[2] ~= 0.0 or Marker[3] ~= 0.0 then
            ret_pos[1] = Marker[1]
            ret_pos[2] = Marker[2]
            ret_pos[3] = Marker[3]
            isFind = true
        end
    end
    return isFind, unpack(ret_pos)
end

function getCarRealMatrix(handle)
    local entity = getCarPointer(handle)
    if entity ~= 0 then
        local carMatrix = memory.getuint32(entity + 0x14, true)
        if carMatrix ~= 0 then
            local rx = memory.getfloat(carMatrix + 0 * 4, true)
            local ry = memory.getfloat(carMatrix + 1 * 4, true)
            local rz = memory.getfloat(carMatrix + 2 * 4, true)

            local dx = memory.getfloat(carMatrix + 4 * 4, true)
            local dy = memory.getfloat(carMatrix + 5 * 4, true)
            local dz = memory.getfloat(carMatrix + 6 * 4, true)
            return rx, ry, rz, dx, dy, dz
        end
    end
end

function samp_create_sync_data(sync_type, copy_from_player)
	copy_from_player = copy_from_player or true
	local sync_traits = {
		player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
		vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
		passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
		aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
		trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
		unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
		bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
		spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
	}
	local sync_info = sync_traits[sync_type] local data_type = 'struct ' .. sync_info[1]
	local data = ffi.new(data_type, {})
	local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))
	if copy_from_player then local copy_func = sync_info[3]
		if copy_func then local _, player_id if copy_from_player == true then
			_, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED) else
			player_id = tonumber(copy_from_player) end
			copy_func(player_id, raw_data_ptr) end
	end
	local func_send = function() local bs = raknetNewBitStream()
		raknetBitStreamWriteInt8(bs, sync_info[2])
		raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
		raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1) 
		raknetDeleteBitStream(bs)
	end
	local mt = {
		__index = function(t, index) return data[index] end,
		__newindex = function(t, index, value) data[index] = value
		end
	}
	return setmetatable({send = func_send}, mt)
end