Кнопка-переключатель

mmia

Новичок
Автор темы
1
0
Версия MoonLoader
Как добавить кнопка включения и выключения для этого, например, на F2.
Код:
local events = require("samp.events")
function events.onServerMessage(_, text)
  if string.find(text, 'when this shows up') then
    sampSendChat("/sendsthiscommand")
  end
end
 

Refraktor

Известный
136
72
Lua:
local sampev    = require "lib.samp.events"
local keys        = require "vkeys"

local enabled    = false

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    while true do
        if isKeyJustPressed(keys.VK_F2) then
            enabled = not enabled
        end
        wait(0)
    end
end

function sampev.onServerMessage(color, text)
    if text:find("when this shows up") and enabled then
        sampSendChat("/sendsthiscommand")
    end
    return {color, text}
end
 
Последнее редактирование: