Пишу себе LUAшку

William_Mariensi

Новичок
Автор темы
17
3
Версия MoonLoader
.026-beta
Ребзя, знач делаю себе бинд на луа чтоб воспроизводило мне при нажатии на "Q" анимацию. Но вот не задача, когда я печатаю слова в которых встречаются "Й", "Q" то восспроизодится данная анимация. Как это пофиксить? Подскажите, я в lua не шарю, точнее ваще отбитый, заранее спасибо.
require "lib.moonloader"
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
while true do
wait(0)
if isKeyJustPressed(VK_Q) then
sampSendChat("/anim 2 2")
end
end
end
 
Решение
да потому что он проверяет isKeyDown, а не isKeyJustPressed. короче, правильно так:

Lua:
require "lib.moonloader"

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(0) end
    while true do
        wait(0)
        if isKeyJustPressed(VK_Q) and not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsScoreboardOpen() and not isSampfuncsConsoleActive() then
            sampSendChat("/anim 2 2")
        end
    end
end

William_Mariensi

Новичок
Автор темы
17
3

Vintik

Мечтатель
Проверенный
1,487
953
Ребят, еще не забывайте про диалог. В твоем случае при вводе текста в диалог будет срабатывать, поэтому...

Lua:
if isKeyJustPressed(VK_Q) and not sampIsChatInputActive() and not sampIsDialogActive() then
Это вместо 8 строки кода, который скинул @Shamanije
 

creacrowz

Участник
25
7
Проверка на ввод в чат, на открытый диалог, на открытый таб, на открытую консоль SF

Lua:
require "lib.moonloader"

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
        if isKeyDown(VK_Q) and not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsScoreboardOpen() and not isSampfuncsConsoleActive() then
            sampSendChat("/anim 2 2")
        end
    end
end
 
  • Нравится
Реакции: Vintik

William_Mariensi

Новичок
Автор темы
17
3
Проверка на ввод в чат, на открытый диалог, на открытый таб, на открытую консоль SF

Lua:
require "lib.moonloader"

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
        if isKeyDown(VK_Q) and not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsScoreboardOpen() and not isSampfuncsConsoleActive() then
            sampSendChat("/anim 2 2")
        end
    end
end
попробовал как у тебя, оно флудит 4 раза данную команду
 

Vintik

Мечтатель
Проверенный
1,487
953
да потому что он проверяет isKeyDown, а не isKeyJustPressed. короче, правильно так:

Lua:
require "lib.moonloader"

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(0) end
    while true do
        wait(0)
        if isKeyJustPressed(VK_Q) and not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsScoreboardOpen() and not isSampfuncsConsoleActive() then
            sampSendChat("/anim 2 2")
        end
    end
end
 
  • Нравится
Реакции: shizzard и lieer