Почему не работает

Nerykery

Известный
Автор темы
522
125
Версия MoonLoader
.025-beta
Lua:
local vk = require "vkeys"
function main()
local toggle = false
 while true do
        wait(0)
if isKeyJustPressed(VK_M) then
    toggle = not toggle
    sampAddChatMessage(toggle and "ON" or "OFF", -1)
end

 if toggle then

      setVirtualKeyDown(0x12, true)
      wait(10)
      setVirtualKeyDown(0x12, false)


end
end
end
 
Решение
Lua:
local vk = require "vkeys"
function main()
local toggle = false
 while true do
        wait(0)
if isKeyJustPressed(VK_M) then
    toggle = not toggle
    sampAddChatMessage(toggle and "ON" or "OFF", -1)
end

 if toggle then

      setVirtualKeyDown(0x12, true)
      wait(10)
      setVirtualKeyDown(0x12, false)


end
end
end
Бро, шо с табуляцией? 😕 Скинь ошибку из лога

хуега)

РП игрок
Модератор
2,569
2,273
Lua:
local vk = require "vkeys"
function main()
local toggle = false
 while true do
        wait(0)
if isKeyJustPressed(VK_M) then
    toggle = not toggle
    sampAddChatMessage(toggle and "ON" or "OFF", -1)
end

 if toggle then

      setVirtualKeyDown(0x12, true)
      wait(10)
      setVirtualKeyDown(0x12, false)


end
end
end
Бро, шо с табуляцией? 😕 Скинь ошибку из лога
 
  • Нравится
Реакции: Nerykery

хуега)

РП игрок
Модератор
2,569
2,273
Более читабельно мне кажется так будет
Lua:
require "lib.moonloader"

local vk = require "vkeys"
local toggle = false

function main()
    while not isSampAvailable() do wait(100) end

    while true do
        wait(0)
        
        if isKeyJustPressed(VK_M) then
            toggle = not toggle
            sampAddChatMessage(toggle and "ON" or "OFF", -1)
        end

        if toggle then
            setVirtualKeyDown(0x12, true)
            wait(10)
            setVirtualKeyDown(0x12, false)
        end
    end
end

Более читабельно мне кажется так будет
Lua:
require "lib.moonloader"

local vk = require "vkeys"
local toggle = false

function main()
    while not isSampAvailable() do wait(100) end

    while true do
        wait(0)
       
        if isKeyJustPressed(VK_M) then
            toggle = not toggle
            sampAddChatMessage(toggle and "ON" or "OFF", -1)
        end

        if toggle then
            setVirtualKeyDown(0x12, true)
            wait(10)
            setVirtualKeyDown(0x12, false)
        end
    end
end
И если это весь код, то vkeys можно не подключать