LUA рандом координат

Статус
В этой теме нельзя размещать новые ответы.

Bananious

Известный
Автор темы
238
17
Помогите пожалуйста. У меня есть бот который бегает по кордам
Lua:
BeginToPoint(16.2390,1850.8606,18.6309,1.000000, -255, false)
И мне нужно как-то сделать чтобы из масива в котором есть 4 координаты рандомно выбирались корды но этого не происходит, я думаю что это из-за "кавычек".
Lua:
require "lib.moonloader"
local str_rand = {
    "766.979980, -2.110000, 1000.739990", 
    "769.090027, -2.580000, 1000.750000", 
    "770.890015, 13.550000, 1000.719971", 
    "768.530029, 13.550000, 1000.719971"
}
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    sampRegisterChatCommand("bcmd", cmd_bot)
    local saveX = {}
    local saveY = {}
    local saveZ = {}
    while true do
        wait(0)
        if isPlayerPlaying(playerHandle) and enabled then
            rand = math.random(1, #str_rand)
---------------------------------------------------------------------------
            BeginToPoint(str_rand[rand][1], str_rand[rand][2], str_rand[rand][3], 1.000000, -255, false)
            wait(1000)
            enabled = false
---------------------------------------------------------------------------
        end
    end
end
--------------------------- STANDART FUNCTIONS ---------------------------
function BeginToPoint(x, y, z, radius, move_code, isSprint)
    repeat
        local posX, posY, posZ = GetCoordinates()
        SetAngle(x, y, z)
        MovePlayer(move_code, isSprint)
        local dist = getDistanceBetweenCoords3d(x, y, z, posX, posY, z)
        wait(0)
    until not enabled or dist < radius
end
function MovePlayer(move_code, isSprint)
    setGameKeyState(1, move_code)
    --[[255 - обычный бег назад
       -255 - обычный бег вперед
      65535 - идти шагом вперед
     -65535 - идти шагом назад]]
    if isSprint then setGameKeyState(16, 255) end
end
function SetAngle(x, y, z)
    local posX, posY, posZ = GetCoordinates()
    local pX = x - posX
    local pY = y - posY
    local zAngle = getHeadingFromVector2d(pX, pY)
    if isCharInAnyCar(playerPed) then
        local car = storeCarCharIsInNoSave(playerPed)
        setCarHeading(car, zAngle)
    else
        setCharHeading(playerPed, zAngle)
    end
    restoreCameraJumpcut()
end
function GetCoordinates()
    if isCharInAnyCar(playerPed) then
        local car = storeCarCharIsInNoSave(playerPed)
        return getCarCoordinates(car)
    else
        return getCharCoordinates(playerPed)
    end
end
function cmd_bot(param)
    enabled = not enabled
    if enabled then
        sampAddChatMessage(string.format("[%s]: Активирован", thisScript().name), 0x40FF40)
    else
        sampAddChatMessage(string.format("[%s]: Деактивирован", thisScript().name), 0xFF4040)
    end
end
-- Teleport from ClickWarp (by FYP)
function teleportPlayer(x, y, z)
    if isCharInAnyCar(playerPed) then
        setCharCoordinates(playerPed, x, y, z)
    end
    setCharCoordinatesDontResetAnim(playerPed, x, y, z)
end
function setCharCoordinatesDontResetAnim(char, x, y, z)
    if doesCharExist(char) then
        local ptr = getCharPointer(char)
        setEntityCoordinates(ptr, x, y, z)
    end
end
function setEntityCoordinates(entityPtr, x, y, z)
    if entityPtr ~= 0 then
        local matrixPtr = readMemory(entityPtr + 0x14, 4, false)
        if matrixPtr ~= 0 then
            local posPtr = matrixPtr + 0x30
            writeMemory(posPtr + 0, 4, representFloatAsInt(x), false) --X
            writeMemory(posPtr + 4, 4, representFloatAsInt(y), false) --Y
            writeMemory(posPtr + 8, 4, representFloatAsInt(z), false) --Z
        end
    end
end
-- End Teleport code
--------------------------- ADDITIONAL FUNCTIONS ---------------------------
 
Последнее редактирование:
Решение
Бля я хз почему не работает
Lua:
require "lib.moonloader"
local str_rand = {
    766.979980, -2.110000, 1000.739990,
    769.090027, -2.580000, 1000.750000,
    770.890015, 13.550000, 1000.719971,
    768.530029, 13.550000, 1000.719971
}
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    sampRegisterChatCommand("bcmd", cmd_bot)
    local saveX = {}
    local saveY = {}
    local saveZ = {}
    while true do
        wait(0)
        if isPlayerPlaying(playerHandle) and enabled then
            rand = math.random(1, #str_rand)
---------------------------------------------------------------------------
            BeginToPoint(str_rand[rand][1], str_rand[rand][2], str_rand[rand][3], 1.000000, -255, false)...

winten

Потрачен
409
182
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Lua:
local srt_rand = {
    16.2390, 1750.8606, 18.6309,
    12.2390, 78.8606, 18.6309,
    6.2390, 150.8606, 18.6309,
    4.2390, 4785.8606, 18.6309,
}

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    sampRegisterChatCommand("bot", cmd_bot)
    
    local saveX = {}
    local saveY = {}
    local saveZ = {}

    while true do
        wait(0)
        if isPlayerPlaying(playerHandle) and enabled then
            rand = math.random(1, #str_rand)

            BeginToPoint(str_rand[rand][1], str_rand[rand][2], str_rand[rand][3], 1.0, -255, false)
            setVirtualKeyDown(18, true)
            wait(20)
            setVirtualKeyDown(18, false)
            wait(500)
            enabled = false
        end
    end
end
 
  • Злость
Реакции: Izvinisb

Bananious

Известный
Автор темы
238
17
Lua:
local srt_rand = {
    16.2390, 1750.8606, 18.6309,
    12.2390, 78.8606, 18.6309,
    6.2390, 150.8606, 18.6309,
    4.2390, 4785.8606, 18.6309,
}

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    sampRegisterChatCommand("bot", cmd_bot)
  
    local saveX = {}
    local saveY = {}
    local saveZ = {}

    while true do
        wait(0)
        if isPlayerPlaying(playerHandle) and enabled then
            rand = math.random(1, #str_rand)

            BeginToPoint(str_rand[rand][1], str_rand[rand][2], str_rand[rand][3], 1.0, -255, false)
            setVirtualKeyDown(18, true)
            wait(20)
            setVirtualKeyDown(18, false)
            wait(500)
            enabled = false
        end
    end
end
Бля я хз почему не работает
Lua:
require "lib.moonloader"
local str_rand = {
    766.979980, -2.110000, 1000.739990, 
    769.090027, -2.580000, 1000.750000, 
    770.890015, 13.550000, 1000.719971, 
    768.530029, 13.550000, 1000.719971
}
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    sampRegisterChatCommand("bcmd", cmd_bot)
    local saveX = {}
    local saveY = {}
    local saveZ = {}
    while true do
        wait(0)
        if isPlayerPlaying(playerHandle) and enabled then
            rand = math.random(1, #str_rand)
---------------------------------------------------------------------------
            BeginToPoint(str_rand[rand][1], str_rand[rand][2], str_rand[rand][3], 1.000000, -255, false)
            wait(1000)
            enabled = false
---------------------------------------------------------------------------
        end
    end
end
--------------------------- STANDART FUNCTIONS ---------------------------
function BeginToPoint(x, y, z, radius, move_code, isSprint)
    repeat
        local posX, posY, posZ = GetCoordinates()
        SetAngle(x, y, z)
        MovePlayer(move_code, isSprint)
        local dist = getDistanceBetweenCoords3d(x, y, z, posX, posY, z)
        wait(0)
    until not enabled or dist < radius
end
function MovePlayer(move_code, isSprint)
    setGameKeyState(1, move_code)
    --[[255 - обычный бег назад
       -255 - обычный бег вперед
      65535 - идти шагом вперед
     -65535 - идти шагом назад]]
    if isSprint then setGameKeyState(16, 255) end
end
function SetAngle(x, y, z)
    local posX, posY, posZ = GetCoordinates()
    local pX = x - posX
    local pY = y - posY
    local zAngle = getHeadingFromVector2d(pX, pY)
    if isCharInAnyCar(playerPed) then
        local car = storeCarCharIsInNoSave(playerPed)
        setCarHeading(car, zAngle)
    else
        setCharHeading(playerPed, zAngle)
    end
    restoreCameraJumpcut()
end
function GetCoordinates()
    if isCharInAnyCar(playerPed) then
        local car = storeCarCharIsInNoSave(playerPed)
        return getCarCoordinates(car)
    else
        return getCharCoordinates(playerPed)
    end
end
function cmd_bot(param)
    enabled = not enabled
    if enabled then
        sampAddChatMessage(string.format("[%s]: Активирован", thisScript().name), 0x40FF40)
    else
        sampAddChatMessage(string.format("[%s]: Деактивирован", thisScript().name), 0xFF4040)
    end
end
-- Teleport from ClickWarp (by FYP)
function teleportPlayer(x, y, z)
    if isCharInAnyCar(playerPed) then
        setCharCoordinates(playerPed, x, y, z)
    end
    setCharCoordinatesDontResetAnim(playerPed, x, y, z)
end
function setCharCoordinatesDontResetAnim(char, x, y, z)
    if doesCharExist(char) then
        local ptr = getCharPointer(char)
        setEntityCoordinates(ptr, x, y, z)
    end
end
function setEntityCoordinates(entityPtr, x, y, z)
    if entityPtr ~= 0 then
        local matrixPtr = readMemory(entityPtr + 0x14, 4, false)
        if matrixPtr ~= 0 then
            local posPtr = matrixPtr + 0x30
            writeMemory(posPtr + 0, 4, representFloatAsInt(x), false) --X
            writeMemory(posPtr + 4, 4, representFloatAsInt(y), false) --Y
            writeMemory(posPtr + 8, 4, representFloatAsInt(z), false) --Z
        end
    end
end
-- End Teleport code
--------------------------- ADDITIONAL FUNCTIONS ---------------------------
 

winten

Потрачен
409
182
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Бля я хз почему не работает
Lua:
require "lib.moonloader"
local str_rand = {
    766.979980, -2.110000, 1000.739990,
    769.090027, -2.580000, 1000.750000,
    770.890015, 13.550000, 1000.719971,
    768.530029, 13.550000, 1000.719971
}
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    sampRegisterChatCommand("bcmd", cmd_bot)
    local saveX = {}
    local saveY = {}
    local saveZ = {}
    while true do
        wait(0)
        if isPlayerPlaying(playerHandle) and enabled then
            rand = math.random(1, #str_rand)
---------------------------------------------------------------------------
            BeginToPoint(str_rand[rand][1], str_rand[rand][2], str_rand[rand][3], 1.000000, -255, false)
            wait(1000)
            enabled = false
---------------------------------------------------------------------------
        end
    end
end
--------------------------- STANDART FUNCTIONS ---------------------------
function BeginToPoint(x, y, z, radius, move_code, isSprint)
    repeat
        local posX, posY, posZ = GetCoordinates()
        SetAngle(x, y, z)
        MovePlayer(move_code, isSprint)
        local dist = getDistanceBetweenCoords3d(x, y, z, posX, posY, z)
        wait(0)
    until not enabled or dist < radius
end
function MovePlayer(move_code, isSprint)
    setGameKeyState(1, move_code)
    --[[255 - обычный бег назад
       -255 - обычный бег вперед
      65535 - идти шагом вперед
     -65535 - идти шагом назад]]
    if isSprint then setGameKeyState(16, 255) end
end
function SetAngle(x, y, z)
    local posX, posY, posZ = GetCoordinates()
    local pX = x - posX
    local pY = y - posY
    local zAngle = getHeadingFromVector2d(pX, pY)
    if isCharInAnyCar(playerPed) then
        local car = storeCarCharIsInNoSave(playerPed)
        setCarHeading(car, zAngle)
    else
        setCharHeading(playerPed, zAngle)
    end
    restoreCameraJumpcut()
end
function GetCoordinates()
    if isCharInAnyCar(playerPed) then
        local car = storeCarCharIsInNoSave(playerPed)
        return getCarCoordinates(car)
    else
        return getCharCoordinates(playerPed)
    end
end
function cmd_bot(param)
    enabled = not enabled
    if enabled then
        sampAddChatMessage(string.format("[%s]: Активирован", thisScript().name), 0x40FF40)
    else
        sampAddChatMessage(string.format("[%s]: Деактивирован", thisScript().name), 0xFF4040)
    end
end
-- Teleport from ClickWarp (by FYP)
function teleportPlayer(x, y, z)
    if isCharInAnyCar(playerPed) then
        setCharCoordinates(playerPed, x, y, z)
    end
    setCharCoordinatesDontResetAnim(playerPed, x, y, z)
end
function setCharCoordinatesDontResetAnim(char, x, y, z)
    if doesCharExist(char) then
        local ptr = getCharPointer(char)
        setEntityCoordinates(ptr, x, y, z)
    end
end
function setEntityCoordinates(entityPtr, x, y, z)
    if entityPtr ~= 0 then
        local matrixPtr = readMemory(entityPtr + 0x14, 4, false)
        if matrixPtr ~= 0 then
            local posPtr = matrixPtr + 0x30
            writeMemory(posPtr + 0, 4, representFloatAsInt(x), false) --X
            writeMemory(posPtr + 4, 4, representFloatAsInt(y), false) --Y
            writeMemory(posPtr + 8, 4, representFloatAsInt(z), false) --Z
        end
    end
end
-- End Teleport code
--------------------------- ADDITIONAL FUNCTIONS ---------------------------
ля, мой косяк
Lua:
require "lib.moonloader"
local str_rand = {
    {766.979980, -2.110000, 1000.739990},
    {769.090027, -2.580000, 1000.750000},
    {770.890015, 13.550000, 1000.719971},
    {768.530029, 13.550000, 1000.719971}
}
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    sampRegisterChatCommand("bcmd", cmd_bot)
    local saveX = {}
    local saveY = {}
    local saveZ = {}
    while true do
        wait(0)
        if isPlayerPlaying(playerHandle) and enabled then
            rand = math.random(1, #str_rand)
---------------------------------------------------------------------------
            BeginToPoint(str_rand[rand][1], str_rand[rand][2], str_rand[rand][3], 1.000000, -255, false)
            wait(1000)
            enabled = false
---------------------------------------------------------------------------
        end
    end
end
--------------------------- STANDART FUNCTIONS ---------------------------
function BeginToPoint(x, y, z, radius, move_code, isSprint)
    repeat
        local posX, posY, posZ = GetCoordinates()
        SetAngle(x, y, z)
        MovePlayer(move_code, isSprint)
        local dist = getDistanceBetweenCoords3d(x, y, z, posX, posY, z)
        wait(0)
    until not enabled or dist < radius
end
function MovePlayer(move_code, isSprint)
    setGameKeyState(1, move_code)
    --[[255 - обычный бег назад
       -255 - обычный бег вперед
      65535 - идти шагом вперед
     -65535 - идти шагом назад]]
    if isSprint then setGameKeyState(16, 255) end
end
function SetAngle(x, y, z)
    local posX, posY, posZ = GetCoordinates()
    local pX = x - posX
    local pY = y - posY
    local zAngle = getHeadingFromVector2d(pX, pY)
    if isCharInAnyCar(playerPed) then
        local car = storeCarCharIsInNoSave(playerPed)
        setCarHeading(car, zAngle)
    else
        setCharHeading(playerPed, zAngle)
    end
    restoreCameraJumpcut()
end
function GetCoordinates()
    if isCharInAnyCar(playerPed) then
        local car = storeCarCharIsInNoSave(playerPed)
        return getCarCoordinates(car)
    else
        return getCharCoordinates(playerPed)
    end
end
function cmd_bot(param)
    enabled = not enabled
    if enabled then
        sampAddChatMessage(string.format("[%s]: Активирован", thisScript().name), 0x40FF40)
    else
        sampAddChatMessage(string.format("[%s]: Деактивирован", thisScript().name), 0xFF4040)
    end
end
-- Teleport from ClickWarp (by FYP)
function teleportPlayer(x, y, z)
    if isCharInAnyCar(playerPed) then
        setCharCoordinates(playerPed, x, y, z)
    end
    setCharCoordinatesDontResetAnim(playerPed, x, y, z)
end
function setCharCoordinatesDontResetAnim(char, x, y, z)
    if doesCharExist(char) then
        local ptr = getCharPointer(char)
        setEntityCoordinates(ptr, x, y, z)
    end
end
function setEntityCoordinates(entityPtr, x, y, z)
    if entityPtr ~= 0 then
        local matrixPtr = readMemory(entityPtr + 0x14, 4, false)
        if matrixPtr ~= 0 then
            local posPtr = matrixPtr + 0x30
            writeMemory(posPtr + 0, 4, representFloatAsInt(x), false) --X
            writeMemory(posPtr + 4, 4, representFloatAsInt(y), false) --Y
            writeMemory(posPtr + 8, 4, representFloatAsInt(z), false) --Z
        end
    end
end
-- End Teleport code
--------------------------- ADDITIONAL FUNCTIONS ---------------------------
 
  • Нравится
Реакции: tihonok
Статус
В этой теме нельзя размещать новые ответы.