Другое С/С++ Вопрос - Ответ

twixjr12s

Новичок
17
0
SF->getGame()->isKeyPressed не работает в диалоге, шо делать если надо получить нажатие клавиш в диалоге
 

twixjr12s

Новичок
17
0
isKeyPressed не работает с диалогом, а GetAsyncKeyState флудит при зажатии клавиши, какие ещё есть?
 

twixjr12s

Новичок
17
0
Lua:
function main()
    for i = 48, 57 do
        if isKeyJustPressed(i) then
            if state < 5 then
                state = state + 1
            end
        end
    end
end

function samp.onShowDialog(id, style, title, btn, btn, text)
    state = 0
    dtitle = title

    if dtitle:find('репорт') then
        if state == 1 then
            sampSetCurrentDialogEditboxText("а")
        elseif state == 2 then
            sampSetCurrentDialogEditboxText("ад")
        elseif state == 3 then
            sampSetCurrentDialogEditboxText("адм")
        elseif state == 4 then
            sampSetCurrentDialogEditboxText("адми")
        elseif state == 5 then
            sampSetCurrentDialogEditboxText("админ")
        elseif state == 0 then
            sampSetCurrentDialogEditboxText('')
        end
    end
end
как перенести данное произведение на C++, isKeyPressed не работает в диалоге, GetAsyncState флудит
 

-raymond-

Известный
110
9
Lua:
function main()
    for i = 48, 57 do
        if isKeyJustPressed(i) then
            if state < 5 then
                state = state + 1
            end
        end
    end
end

function samp.onShowDialog(id, style, title, btn, btn, text)
    state = 0
    dtitle = title

    if dtitle:find('репорт') then
        if state == 1 then
            sampSetCurrentDialogEditboxText("а")
        elseif state == 2 then
            sampSetCurrentDialogEditboxText("ад")
        elseif state == 3 then
            sampSetCurrentDialogEditboxText("адм")
        elseif state == 4 then
            sampSetCurrentDialogEditboxText("адми")
        elseif state == 5 then
            sampSetCurrentDialogEditboxText("админ")
        elseif state == 0 then
            sampSetCurrentDialogEditboxText('')
        end
    end
end
как перенести данное произведение на C++, isKeyPressed не работает в диалоге, GetAsyncState флудит
я же ответил, хукни wndprochandler или юзай функцию в потоке
C++:
void checkKey()
{
    static DWORD tick = GetTickCount();

    if (tick - GetTickCount() <= 0)
    {

        if (GetAsyncKeyState(key))
        {
            // code
        }

        tick = GetTickCount() + 800; // 800 - задержка в мс, если будет флудить ставь больше
    }
}
 

twixjr12s

Новичок
17
0
я же ответил, хукни wndprochandler или юзай функцию в потоке
C++:
void checkKey()
{
    static DWORD tick = GetTickCount();

    if (tick - GetTickCount() <= 0)
    {

        if (GetAsyncKeyState(key))
        {
            // code
        }

        tick = GetTickCount() + 800; // 800 - задержка в мс, если будет флудить ставь больше
    }
}
вообще не работает)