Вопрос экспертам Vkeys

Mr_kaneki

Активный
Автор темы
314
74
Вопщем делал вроде по примерам вроде бы все правильно а вроде и нет, основной функционал работает а вот бинды на клавиши нет немогу понять почему
Lua:
local samp = require 'lib.samp.events'
local vkeys = require 'vkeys'
local info = nil

local Weapon = {
    ["fgc"]  = "COLT",
    ["fgd"]  = "EAGLE",
    ["fgs"]  = "Дробовик",
    ["fgu"]  = "TEC",
    ["fgmp"] = "MP5",
    ["fgak"] = "AK47",
    ["fgm"]  = "M4",
    ["fgr"]  = "Винтовка",
}

local Binds = {
    [vkeys.VK_F] = "fgm",
    [vkeys.VK_2] = "fgd",
    [vkeys.VK_3] = "fgs",
    [vkeys.VK_4] = "fgu",
    [vkeys.VK_5] = "fgak",
    [vkeys.VK_6] = "fgmp",
    [vkeys.VK_7] = "fgr",
}

function main()
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
        if not sampIsCursorActive() and not sampIsChatInputActive() and not sampIsDialogActive() then
            if not info then
                for key, weaponKey in pairs(Binds) do
                    if wasKeyPressed(key) then
                        local weapon = Weapon[weaponKey]
                        if weapon then
                            info = {
                                step = 0,
                                weapon = weapon,
                                count = 50
                            }
                            sampSendChat("/gun")
                        end
                    end
                end
            end
        end
    end
end
 
Решение
Lua:
local samp = require 'lib.samp.events'
local vkeys = require 'vkeys'

local Weapon = {
    ["fgc"]  = "COLT",
    ["fgd"]  = "EAGLE",
    ["fgs"]  = "Дробовик",
    ["fgu"]  = "TEC",
    ["fgmp"] = "MP5",
    ["fgak"] = "AK47",
    ["fgm"]  = "M4",
    ["fgr"]  = "Винтовка",
}

local Binds = {
    [vkeys.VK_F] = "fgm",
    [vkeys.VK_2] = "fgd",
    [vkeys.VK_3] = "fgs",
    [vkeys.VK_4] = "fgu",
    [vkeys.VK_5] = "fgak",
    [vkeys.VK_6] = "fgmp",
    [vkeys.VK_7] = "fgr",
}

local info = nil

function main()
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
        if not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsCursorActive() then
            for key, weaponKey in...

undefineders

Участник
41
22
Lua:
local samp = require 'lib.samp.events'
local vkeys = require 'vkeys'

local Weapon = {
    ["fgc"]  = "COLT",
    ["fgd"]  = "EAGLE",
    ["fgs"]  = "Дробовик",
    ["fgu"]  = "TEC",
    ["fgmp"] = "MP5",
    ["fgak"] = "AK47",
    ["fgm"]  = "M4",
    ["fgr"]  = "Винтовка",
}

local Binds = {
    [vkeys.VK_F] = "fgm",
    [vkeys.VK_2] = "fgd",
    [vkeys.VK_3] = "fgs",
    [vkeys.VK_4] = "fgu",
    [vkeys.VK_5] = "fgak",
    [vkeys.VK_6] = "fgmp",
    [vkeys.VK_7] = "fgr",
}

local info = nil

function main()
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
        if not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsCursorActive() then
            for key, weaponKey in pairs(Binds) do
                if wasKeyPressed(key) then
                    local weaponName = Weapon[weaponKey]
                    if weaponName then
                        info = {
                            step = 0,
                            weapon = weaponName,
                            count = 50
                        }
                        sampSendChat("/gun")
                        wait(100)
                    end
                end
            end
        end
    end
end
 
  • Нравится
Реакции: Mr_kaneki