Не происходит нажатие клавиши.

Firus20016

Участник
Автор темы
148
15
Версия MoonLoader
.026-beta
Пожалуйста, помогите с кодом. В игре просто не нажимается клавиша N по нажатию 2.

Lua:
require "lib.moonloader"
require "lib.sampfuncs"
local ffi = require "ffi"
ffi.cdef[[
     void keybd_event(int keycode, int scancode, int flags, int extra);
]]

function main()
        repeat wait(0) until isSampAvailable()
        wait(-1)
end

function EmulateKey(key, isDown)
    if not isDown then
        ffi.C.keybd_event(key, 0, 2, 0)
    else
        ffi.C.keybd_event(key, 0, 0, 0)
    end
end

if isKeyJustPressed(VK_2) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then
        EmulateKey(0x4E, true)
        wait(20)
        EmulateKey(0x4E, false)
        wait(100)
    end