Как сделать скрипт, который бы при сообщении в чате нажимал клавишу?

fhghfg

Новичок
Автор темы
7
1
Версия MoonLoader
.027.0-preview
Мне нужен скрипт, который бы нажимал клавишу, когда в чате будет определенное сообщение.
В моем случае клавиша ALT и сообщение "пришло сообщение от".

Буду благодарен.
 
Решение
можешь еще сделать активацию по команде, пожалуйста?
Lua:
local sampev = require('lib.samp.events')

local activate = false

-- В main
sampRegisterChatCommand("act", function()
    activate = not activate
    sampAddChatMessage(activate and "Activated" or "Deactivated", -1)
end)

--
function sampev.onServerMessage(color, text)
    if activate then
        if text:match('пришло сообщение от') then
            lua_thread.create(function()
                setGameKeyState(21, 255)
                wait(1)
                setGameKeyState(21, 0)
            end)
        end
    end
end

fhghfg

Новичок
Автор темы
7
1
Lua:
local sampev = require('lib.samp.events')
function sampev.onServerMessage(color, text)
    if text:match('пришло сообщение от') then
        lua_thread.create(function()
            setGameKeyState(21, 255)
            wait(1)
            setGameKeyState(21, 0)
        end)
    end
end
можешь еще сделать активацию по команде, пожалуйста?
 

Dmitriy Makarov

25.05.2021
Проверенный
2,478
1,113
можешь еще сделать активацию по команде, пожалуйста?
Lua:
local sampev = require('lib.samp.events')

local activate = false

-- В main
sampRegisterChatCommand("act", function()
    activate = not activate
    sampAddChatMessage(activate and "Activated" or "Deactivated", -1)
end)

--
function sampev.onServerMessage(color, text)
    if activate then
        if text:match('пришло сообщение от') then
            lua_thread.create(function()
                setGameKeyState(21, 255)
                wait(1)
                setGameKeyState(21, 0)
            end)
        end
    end
end