Можно луа, /lock на l, /key на k

Валерия

Потрачен
Автор темы
142
14
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.

Можно луа, /lock на l, /key на k​

 

scroll.

bud' chelovekom
Проверенный
4,166
1,431
 

ARMOR

Waitin' on another black summer to end
Модератор
5,055
7,279
kod:
function main()
repeat wait(0) until isSampAvailable()
wait(0)
while true do
  wait(0)
  if wasKeyPressed(0x5A) then -- 0x5A это Z клавиша, подберай себе тругой
  sampSendChat("/lock")
  end
end
end
А где проверки на: Отыкрытый чат, открытый диалог, открытую консоль сампфункса, и вообще на включенный курсор?
 
  • Нравится
Реакции: scroll.

ARMOR

Waitin' on another black summer to end
Модератор
5,055
7,279
могу проверку на мозги сделать 😂
тут просто при нажатии Z - он вводит в чат /lock и нажимает enter
Ну да, но каждый раз когда ты будешь к примеру писать в чат букву "Z" или в Диалог, или в консоль сампфункса, то скрипт будет отправлять "/lock" в чат
 

ARMOR

Waitin' on another black summer to end
Модератор
5,055
7,279
Binder:
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_L) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() then
            sampSendChat("/lock")
        end
        if isKeyJustPressed(VK_K) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and isChatInAnyCar(PLAYER_PED) then
            sampSendChat("/key")
        end
    end
end
Должно работать
 

[w0te]

Известный
776
501
@Валерия
cod:
require 'lib.moonloader'

function main()
repeat wait(0) until isSampAvailable()
wait(0)
while true do
  wait(0)
   if isKeyJustPressed(0x4C) then -- L
       sampSendChat("/lock")
    end
       if isKeyJustPressed(0x4B) then -- K
          sampSendChat("/key")
        end
    end
end
это рабочий код, я просто перепутал клавиши вот и не работало, когда будет открыт чат оно не напишит.

вот код с ON/OFF

cod:
function main()
repeat wait(0) until isSampAvailable()
wait(0)
sampRegisterChatCommand("k", k)
sampRegisterChatCommand("l", k)
while true do
  wait(0)
   if isKeyJustPressed(0x4C) and l then -- L
       sampSendChat("/lock")
    end
       if isKeyJustPressed(0x4B) and k  then -- K
          sampSendChat("/key")
        end
    end
end

function k()
if k then
  k = false
  sampAddChatMessage("OFF")
else
    k = false
  sampAddChatMessage("ON")
  end
end

function l()
if l then
  l = false
  sampAddChatMessage("OFF")
else
    l = false
  sampAddChatMessage("ON")
  end
end
 

Вложения

  • KeyJust.lua
    315 байт · Просмотры: 20
Последнее редактирование:

ARMOR

Waitin' on another black summer to end
Модератор
5,055
7,279
@Валерия
cod:
require 'lib.moonloader'

function main()
repeat wait(0) until isSampAvailable()
wait(0)
while true do
  wait(0)
   if isKeyJustPressed(0x4C) then -- L
       sampSendChat("/lock")
    end
       if isKeyJustPressed(0x4B) then -- K
          sampSendChat("/key")
        end
    end
end
это рабочий код, я просто перепутал клавиши вот и не работало, когда будет открыт чат оно не напишит.

вот код с ON/OFF

cod:
function main()
repeat wait(0) until isSampAvailable()
wait(0)
sampRegisterChatCommand("k", k)
sampRegisterChatCommand("l", k)
while true do
  wait(0)
   if isKeyJustPressed(0x4C) and l then -- L
       sampSendChat("/lock")
    end
       if isKeyJustPressed(0x4B) and k  then -- K
          sampSendChat("/key")
        end
    end
end

function k()
if k then
  k = false
  sampAddChatMessage("OFF")
else
    k = false
  sampAddChatMessage("ON")
  end
end

function l()
if l then
  l = false
  sampAddChatMessage("OFF")
else
    l = false
  sampAddChatMessage("ON")
  end
end
Код хуйня, можно было сделать намного лучше)
 

ARMOR

Waitin' on another black summer to end
Модератор
5,055
7,279
чем?
сократить одну букву?
Ну да, целую одну букву...
Lua:
require "lib.moonloader"
local enableK = true
local enableL = true

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("l", function()
        enableL = not enableL
        sampAddChatMessage(enableL and "Открытие на L работает" or "Открытие на L не работает", -1)
    end)
    sampRegisterChatCommand("l", function()
        enableK = not enableK
        sampAddChatMessage(enableK and "Ключи на K работают" or "Ключи на K не работают", -1)
    end)

    while true do
        wait(0)
        if isKeyJustPressed(VK_L) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and enableL then
            sampSendChat("/lock")
        elseif isKeyJustPressed(VK_K) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and isChatInAnyCar(PLAYER_PED) and enableK then
           sampSendChat("/key")
       end
    end
end
 

[w0te]

Известный
776
501
Ну да, целую одну букву...
Lua:
require "lib.moonloader"
local enableK = false
local enableL = false

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("l", function()
        enableL = not enableL
        sampAddChatMessage(enableL and "Открытие на L работает" or "Открытие на L не работает", -1)
    end)
    sampRegisterChatCommand("l", function()
        enableK = not enableK
        sampAddChatMessage(enableK and "Ключи на K работают" or "Ключи на K не работают", -1)
    end)

    while true do
        wait(0)
        if isKeyJustPressed(VK_L) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and enableL then
            sampSendChat("/lock")
        elseif isKeyJustPressed(VK_K) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and isChatInAnyCar(PLAYER_PED) and enableK then
           sampSendChat("/key")
       end
    end
end
ебля бесполезная.
 

Валерия

Потрачен
Автор темы
142
14
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
@Валерия
cod:
require 'lib.moonloader'

function main()
repeat wait(0) until isSampAvailable()
wait(0)
while true do
  wait(0)
   if isKeyJustPressed(0x4C) then -- L
       sampSendChat("/lock")
    end
       if isKeyJustPressed(0x4B) then -- K
          sampSendChat("/key")
        end
    end
end
это рабочий код, я просто перепутал клавиши вот и не работало, когда будет открыт чат оно не напишит.

вот код с ON/OFF

cod:
function main()
repeat wait(0) until isSampAvailable()
wait(0)
sampRegisterChatCommand("k", k)
sampRegisterChatCommand("l", k)
while true do
  wait(0)
   if isKeyJustPressed(0x4C) and l then -- L
       sampSendChat("/lock")
    end
       if isKeyJustPressed(0x4B) and k  then -- K
          sampSendChat("/key")
        end
    end
end

function k()
if k then
  k = false
  sampAddChatMessage("OFF")
else
    k = false
  sampAddChatMessage("ON")
  end
end

function l()
if l then
  l = false
  sampAddChatMessage("OFF")
else
    l = false
  sampAddChatMessage("ON")
  end
end
Не работает.
 

ARMOR

Waitin' on another black summer to end
Модератор
5,055
7,279
Ну да, целую одну букву...
Lua:
require "lib.moonloader"
local enableK = true
local enableL = true

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("l", function()
        enableL = not enableL
        sampAddChatMessage(enableL and "Открытие на L работает" or "Открытие на L не работает", -1)
    end)
    sampRegisterChatCommand("l", function()
        enableK = not enableK
        sampAddChatMessage(enableK and "Ключи на K работают" or "Ключи на K не работают", -1)
    end)

    while true do
        wait(0)
        if isKeyJustPressed(VK_L) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and enableL then
            sampSendChat("/lock")
        elseif isKeyJustPressed(VK_K) and not isSampfuncsConsoleActive() and not sampIsChatInputActive() and not sampIsDialogActive() and isChatInAnyCar(PLAYER_PED) and enableK then
           sampSendChat("/key")
       end
    end
end
Так хуйня или нет?
Этот код работает, другой не проверял