Круиз контроль на луа.

Morli.K

Новичок
Автор темы
23
2
Версия SA-MP
  1. 0.3.7 (R1)
cruise:
local enable = false
local speed = 0
local limit = 0
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    local font = renderCreateFont("Arial", 10, 9)
    while true do
        wait(0)
        if isCharInAnyCar(playerPed) then
            local _, y = getScreenResolution()
            if isKeyJustPressed(0x26) then speed = speed + 3.576 end
            if isKeyJustPressed(0x28) then speed = speed - 3.576 end
            limit = speed
            if enable then
            local text = ("Cruise Control %s {FFCCCCCC}Speed: {FFFFFF00}%.0f, {FFCCCCCC}Limit: {FFFFFF00}%.0f"):format(enable and "{FF00CC00}ON" or "{FFCC0000}OFF", speed * 2.8, limit * 2.8 + 10)
            renderDrawBox(0, y - 15, renderGetFontDrawTextLength(font, text) + 10, 15, 0xFF323232)
            renderFontDrawText(font, text, 5, y - 15, 0xFFCCCCCC)
                if getCarSpeed(storeCarCharIsInNoSave(playerPed)) < speed then
                    writeMemory(0xB73458 + 0x20, 255, 150, false)
                end
                if speed < 0 then
                    speed = 0
                end
                if getCarSpeed(storeCarCharIsInNoSave(playerPed)) > limit + 3.5 then
                    writeMemory(0xB73458 + 0x21, 255, 255, false)
                end
            end
            if isKeyJustPressed(0xBB) then
                enable = not enable
                speed = 0
                if enable and speed == 0 then
                    speed = getCarSpeed(storeCarCharIsInNoSave(playerPed))
                end
            end
        end
    end
end
Кароче, я немного переписал этот круиз под себя(автор: https://www.blast.hk/threads/75772/). Я чайник в этом всём и хотел бы спросить код адреса памяти тормоза. Сейчас тормоз это функция адреса памяти ехать назад:
tormoz:
if getCarSpeed(storeCarCharIsInNoSave(playerPed)) > limit + 3.5 then
writeMemory(0xB73458 + 0x21, 255, 255, false)
Так-же был бы благодарен если найдёте ошибку и поможете исправить или улучшить.
 
Последнее редактирование:

YarikVL

Известный
Проверенный
4,820
1,826
cruise:
local enable = false
local speed = 0
local limit = 0
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    local font = renderCreateFont("Arial", 10, 9)
    while true do
        wait(0)
        if isCharInAnyCar(playerPed) then
            local _, y = getScreenResolution()
            if isKeyJustPressed(0x26) then speed = speed + 3.576 end
            if isKeyJustPressed(0x28) then speed = speed - 3.576 end
            limit = speed
            if enable then
            local text = ("Cruise Control %s {FFCCCCCC}Speed: {FFFFFF00}%.0f, {FFCCCCCC}Limit: {FFFFFF00}%.0f"):format(enable and "{FF00CC00}ON" or "{FFCC0000}OFF", speed * 2.8, limit * 2.8 + 10)
            renderDrawBox(0, y - 15, renderGetFontDrawTextLength(font, text) + 10, 15, 0xFF323232)
            renderFontDrawText(font, text, 5, y - 15, 0xFFCCCCCC)
                if getCarSpeed(storeCarCharIsInNoSave(playerPed)) < speed then
                    writeMemory(0xB73458 + 0x20, 255, 150, false)
                end
                if speed < 0 then
                    speed = 0
                end
                if getCarSpeed(storeCarCharIsInNoSave(playerPed)) > limit + 3.5 then
                    writeMemory(0xB73458 + 0x21, 255, 255, false)
                end
            end
            if isKeyJustPressed(0xBB) then
                enable = not enable
                speed = 0
                if enable and speed == 0 then
                    speed = getCarSpeed(storeCarCharIsInNoSave(playerPed))
                end
            end
        end
    end
end
Кароче, я немного переписал этот круиз под себя(автор: https://www.blast.hk/threads/75772/). Я чайник в этом всём и хотел бы спросить код клавиши Space. Сейчас тормоз это буква S:
tormoz:
if getCarSpeed(storeCarCharIsInNoSave(playerPed)) > limit + 3.5 then
writeMemory(0xB73458 + 0x21, 255, 255, false)
Так-же был бы благодарен если найдёте ошибку и поможете исправить или улучшить.
А чего функцией муна не реализовал?
 

shrug228

Активный
212
75
Я чайник в этом всём и хотел бы спросить код клавиши Space.
Клавиши можно посмотреть тут. Код пробела - 32. Важный момент:
Lua:
0x16     -- вот так ты записываешь клавиши у себя в скрипте
16         -- а вот так их нужно записывать с этими кодами. например:
if isKeyJustPressed(16) then
    -- code
end
Но можно записывать проще: VK_SPACE

Так-же был бы благодарен если найдёте ошибку и поможете исправить или улучшить.
Если есть какая-то ошибка, которую ты заметил - описание и текст ошибки (при наличии, посмотреть можно в moonloader/moonloader.log) в тему.
 

Morli.K

Новичок
Автор темы
23
2
на
if isKeyJustPressed(VK_SPACE) then
Клавиши можно посмотреть тут. Код пробела - 32. Важный момент:
Lua:
0x16     -- вот так ты записываешь клавиши у себя в скрипте
16         -- а вот так их нужно записывать с этими кодами. например:
if isKeyJustPressed(16) then
    -- code
end
Но можно записывать проще: VK_SPACE


Если есть какая-то ошибка, которую ты заметил - описание и текст ошибки (при наличии, посмотреть можно в moonloader/moonloader.log) в тему.
Блин, немного не поняли. Там похуй, то мне не надо(хотя я уже поменял). Мне надо чтобы машина тормозила если скорость превышает условно на 10 км\ч. допустим машина на круизе 20 км\ч, лимит 30 км\ч и если машина едет быстрее чем 30 км\ч использовался адрес памяти тормоза(для ускорения машины используется адрес памяти)

tormoz:
if getCarSpeed(storeCarCharIsInNoSave(playerPed)) > limit + 3.5 then
writeMemory(0xB73458 + 0x21, 255, 255, false)
код тормоза. тут используется в качестве тормоза функция памяти "ехать назад", а мне надо чтобы использовалась функция тормоза именно который на пробел

я изначало неправильно объяснил. мой косяк