работа скрипта

egorglebov

Участник
Автор темы
50
4
Версия MoonLoader
.026-beta
Я хочу чтобы после телепорта в авто, я вернулся на точку, откуда я тпшнулся в авто. Вот код
1:
local go_BOOM = false

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('ctp', function()
        local handle = findCarRadius(15)
        if handle ~= nil then
            go_BOOM = true
            warpCharIntoCar(PLAYER_PED, handle)
        end
    end)
    while true do
        wait(0)
        if go_BOOM then
            if isCharInAnyCar(PLAYER_PED) then
                setCarHealth(storeCarCharIsInNoSave(PLAYER_PED), 0)
                go_BOOM = false
            end
        end
    end
end
function findCarRadius(radius)
    local log = {}
    for k, v in pairs(getAllVehicles()) do
        if doesVehicleExist(v) then
            local mx, my, mz = getCharCoordinates(PLAYER_PED)
            local cx, cy, cz = getCarCoordinates(v)
            local dist = getDistanceBetweenCoords3d(mx, my, mz, cx, cy, cz)
            if dist <= radius then
                table.insert(log, {v, dist})
            end
        end
    end
    if #log > 0 then
        table.sort(log, function(a, b) return (a[2] < b[2]) end)
        return log[1][1]
    end
    return nil
end