Синхра

Neil_

Известный
Автор темы
204
32
Версия MoonLoader
Другое
Lua:
    while true do
        wait(50)
        mb.updateCallbacks()
        if (followInfo.status) then
            local offset = 0
            for _, lBot in pairs(bots) do
                wait(10)
                if (lBot.logined) then
                    offset = offset + 1
                    local sync, bot = mb.getPlayerData(), mb.getBotHandleByIndex(lBot.index)
                    local result, ped = sampGetCharHandleBySampPlayerId(followInfo.targetId)
                    if result then
                        if isCharOnFoot(ped) and not sampIsPlayerNpc(followInfo.targetId) then
                            local angle = getCharHeading(ped) + 90
                            local playerCoord = {getCharCoordinates(ped)}
                            local qw, qx, qy, qz = getCharQuaternion(ped)
                            print(qw, qx, qy, qz)
                            sync.position.x, sync.position.y, sync.position.z = playerCoord[1] + (math.sin(-math.rad(angle)) * offset), playerCoord[2] + (math.cos(-math.rad(angle)) * offset), playerCoord[3]
                            sync.health = getCharHealth(PLAYER_PED)
                            --sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = qw, qx, qy, qz
                            sync.armor = 0
                            sync.moveSpeed.x, sync.moveSpeed.y = 0.01, 0.01
                            bot:sendPlayerData(sync)
                            lBot.position = {x = playerCoord[1], y = playerCoord[2], z = playerCoord[3]}
                        else
                            followInfo.status = false
                        end
                    else
                        followInfo.status = false
                    end
                end
            end
        end
    end
end
Код:

Почему когда я убираю комментарии из sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = qw, qx, qy, qz, бота кикает? Если если закоментить, всё норм работает
 
Решение
Lua:
    while true do
        wait(50)
        mb.updateCallbacks()
        if (followInfo.status) then
            local offset = 0
            for _, lBot in pairs(bots) do
                wait(10)
                if (lBot.logined) then
                    offset = offset + 1
                    local sync, bot = mb.getPlayerData(), mb.getBotHandleByIndex(lBot.index)
                    local result, ped = sampGetCharHandleBySampPlayerId(followInfo.targetId)
                    if result then
                        if isCharOnFoot(ped) and not sampIsPlayerNpc(followInfo.targetId) then
                            local angle = getCharHeading(ped) + 90
                            local playerCoord = {getCharCoordinates(ped)}...

whyega52

Eblang головного мозга
Модератор
2,873
2,853
Lua:
    while true do
        wait(50)
        mb.updateCallbacks()
        if (followInfo.status) then
            local offset = 0
            for _, lBot in pairs(bots) do
                wait(10)
                if (lBot.logined) then
                    offset = offset + 1
                    local sync, bot = mb.getPlayerData(), mb.getBotHandleByIndex(lBot.index)
                    local result, ped = sampGetCharHandleBySampPlayerId(followInfo.targetId)
                    if result then
                        if isCharOnFoot(ped) and not sampIsPlayerNpc(followInfo.targetId) then
                            local angle = getCharHeading(ped) + 90
                            local playerCoord = {getCharCoordinates(ped)}
                            local qw, qx, qy, qz = getCharQuaternion(ped)
                            print(qw, qx, qy, qz)
                            sync.position.x, sync.position.y, sync.position.z = playerCoord[1] + (math.sin(-math.rad(angle)) * offset), playerCoord[2] + (math.cos(-math.rad(angle)) * offset), playerCoord[3]
                            sync.health = getCharHealth(PLAYER_PED)
                            --sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = qw, qx, qy, qz
                            sync.armor = 0
                            sync.moveSpeed.x, sync.moveSpeed.y = 0.01, 0.01
                            bot:sendPlayerData(sync)
                            lBot.position = {x = playerCoord[1], y = playerCoord[2], z = playerCoord[3]}
                        else
                            followInfo.status = false
                        end
                    else
                        followInfo.status = false
                    end
                end
            end
        end
    end
end
Код:

Почему когда я убираю комментарии из sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = qw, qx, qy, qz, бота кикает? Если если закоментить, всё норм работает
Потому-что функция getCharQuaternion возвращает значения в ином порядке (x, y, z, w). Т.е. первым идёт не W, а X
 
  • Нравится
Реакции: Neil_