Помогите сделать активацию/дезактивацию на кнопку или команду пж

BLADE123

Новичок
Автор темы
27
0
Надо сделать активацию и дезактивацию к этому скрипту на кнопку или команду.
Помогите пожалуйста.
lua:
local sampev = require('lib.samp.events')

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

function sampev.onServerMessage(color, text)
    if text:find(' [Жалоба]') then
        sampSendChat('/ot')
        print('I found REPORT!!!')
    end
end
 
Решение
По команде:
local sampev = require('lib.samp.events')
local enabled = false -- или true

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('test', function() enabled = not enabled end)
    wait(-1)
end

function sampev.onServerMessage(color, text)
    if text:find(' [Жалоба]') and enabled then
        sampSendChat('/ot')
        print('I found REPORT!!!')
    end
end
По кнопке:
local sampev = require('lib.samp.events')
local enabled = false

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    addEventHandler("onWindowMessage", function (msg, wparam...

PanSeek

t.me/dailypanseek
Всефорумный модератор
899
1,744
По команде:
local sampev = require('lib.samp.events')
local enabled = false -- или true

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('test', function() enabled = not enabled end)
    wait(-1)
end

function sampev.onServerMessage(color, text)
    if text:find(' [Жалоба]') and enabled then
        sampSendChat('/ot')
        print('I found REPORT!!!')
    end
end
По кнопке:
local sampev = require('lib.samp.events')
local enabled = false

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    addEventHandler("onWindowMessage", function (msg, wparam, lparam)
        if msg == wm.WM_KEYDOWN or msg == wm.WM_SYSKEYDOWN then
            if wparam == VK_F2 then
                enabled = not enabled
            end
        end
    end)
    wait(-1)
end

function sampev.onServerMessage(color, text)
    if text:find(' [Жалоба]') and enabled then
        sampSendChat('/ot')
        print('I found REPORT!!!')
    end
end
 
  • Нравится
Реакции: James Saula и BLADE123