помогите с findAllRandomVehiclesInSphere

TaoTan

Участник
Автор темы
62
3
Версия MoonLoader
.026-beta
помогите с findAllRandomVehiclesInSphere
Как сделать так, что бы я поставил маркер на карту и после ввода команды мне в чат отправило, енсть ли там машина свободная или нет?
Сама функция, если не ошибаюсь " findAllRandomVehiclesInSphere "
 

DeKzer

Известный
518
223
Желательно код)
Lua:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("findcar", findcar)
    findcar = lua_thread.create_suspended(findcar2)

    while true do
        wait(0)
    end
end

function findcar()
    findcar:run()
end

function findcar2()
    x, y, u = getCharCoordinates(PLAYER_PED)
    resul, x, y, z = getTargetBlipCoordinates()
    if not resul then
        sampAddChatMessage("метку поставь", -1)
    else
        setCharCoordinates(PLAYER_PED, x, y, z)
        wait(150)
        result, findcar = findAllRandomVehiclesInSphere(x, y, z, 20, true, true)
        wait(150)
        if result then
            sampAddChatMessage("Нашел тачку", -1)
            setCharCoordinates(PLAYER_PED, x, y, u)
        else
            sampAddChatMessage("не нашел тачку", -1)
            setCharCoordinates(PLAYER_PED, x, y, u)
        end
    end
end
 
  • Bug
Реакции: yung milonov

yung milonov

Известный
1,027
531
Lua:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("findcar", findcar)
    findcar = lua_thread.create_suspended(findcar2)

    while true do
        wait(0)
    end
end

function findcar()
    findcar:run()
end

function findcar2()
    x, y, u = getCharCoordinates(PLAYER_PED)
    resul, x, y, z = getTargetBlipCoordinates()
    if not resul then
        sampAddChatMessage("метку поставь", -1)
    else
        setCharCoordinates(PLAYER_PED, x, y, z)
        wait(150)
        result, findcar = findAllRandomVehiclesInSphere(x, y, z, 20, true, true)
        wait(150)
        if result then
            sampAddChatMessage("Нашел тачку", -1)
            setCharCoordinates(PLAYER_PED, x, y, u)
        else
            sampAddChatMessage("не нашел тачку", -1)
            setCharCoordinates(PLAYER_PED, x, y, u)
        end
    end
end
можно и короче сделать
Lua:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("findcar", function()
        lua_thread.create(function()
            x, y, z = getCharCoordinates(PLAYER_PED)
            local res, mx, my, mz = getTargetBlipCoordinates()
            if res then
                setCharCoordinates(PLAYER_PED, mx, my, mz)
                wait(150)
                result, findcar = findAllRandomVehiclesInSphere(mx, my, mz, 20, true, true)
                wait(150)
                if result then
                    sampAddChatMessage("нашел тачку", -1)
                    setCharCoordinates(PLAYER_PED, x, y, z)
                else
                    sampAddChatMessage("не нашел тачку", -1)
                    setCharCoordinates(PLAYER_PED, x, y, z)
                end
            end
        end)
    end)
    wait(-1)
end
 
  • Bug
Реакции: SomaGnoma

DeKzer

Известный
518
223
можно и короче сделать
Lua:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("findcar", function()
        lua_thread.create(function()
            x, y, z = getCharCoordinates(PLAYER_PED)
            local res, mx, my, mz = getTargetBlipCoordinates()
            if res then
                setCharCoordinates(PLAYER_PED, mx, my, mz)
                wait(150)
                result, findcar = findAllRandomVehiclesInSphere(mx, my, mz, 20, true, true)
                wait(150)
                if result then
                    sampAddChatMessage("нашел тачку", -1)
                    setCharCoordinates(PLAYER_PED, x, y, z)
                else
                    sampAddChatMessage("не нашел тачку", -1)
                    setCharCoordinates(PLAYER_PED, x, y, z)
                end
            end
        end)
    end)
    wait(-1)
end
Из-за 5 строчек жаться?
 

yung milonov

Известный
1,027
531
Из-за 5 строчек жаться?
1643652949586.png
1643652959935.png

да, жаться из-за 5 строчек