LUA | Активация / деактивация командой

3211Marlon1123

Участник
Автор темы
130
12
Версия MoonLoader
.027.0-preview
Хочу сделать так, чтобы событие выполнялось только после прописи команды, как это можно сделать? ( И чтобы при активации/деактивации высвечивалось сообщение по типу: Включено, выключено )

Событие:
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    lua_thread.create(function ()
        wait(0)
        if dialogId == 872 then
            sampCloseCurrentDialogWithButton(1)
        end
        if dialogId == 873 then
            sampSetCurrentDialogEditboxText("100")     -- -------------------------- Вместо 1 в этой строке введите мин. значение
            sampCloseCurrentDialogWithButton(1)
        end
        if dialogId == 874 then
            sampSetCurrentDialogEditboxText("200")     -- -------------------------- Вместо 2 в этой строке введите макс. значение
            sampCloseCurrentDialogWithButton(1)
        end
    end)
end
 

damag

Женюсь на официантке в моем любимом баре
Проверенный
1,152
1,193
говно:
local enabled = false
function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand('test', function()
    enabled = not enabled
    sampAddChatMessage(enabled and '{ffffff}Активирован' or '{ffffff}Деактивирован', -1)
  end)
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if enabled then
        lua_thread.create(function ()
            wait(0)
            if dialogId == 872 then
                sampCloseCurrentDialogWithButton(1)
            end
            if dialogId == 873 then
                sampSetCurrentDialogEditboxText("100")     -- -------------------------- Вместо 1 в этой строке введите мин. значение
                sampCloseCurrentDialogWithButton(1)
            end
            if dialogId == 874 then
                sampSetCurrentDialogEditboxText("200")     -- -------------------------- Вместо 2 в этой строке введите макс. значение
                sampCloseCurrentDialogWithButton(1)
            end
        end)
    end
end
 
  • Нравится
Реакции: Nelit и Rei

3211Marlon1123

Участник
Автор темы
130
12
говно:
local enabled = false
function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand('test', function()
    enabled = not enabled
    sampAddChatMessage(enabled and '{ffffff}Активирован' or '{ffffff}Деактивирован', -1)
  end)
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if enabled then
        lua_thread.create(function ()
            wait(0)
            if dialogId == 872 then
                sampCloseCurrentDialogWithButton(1)
            end
            if dialogId == 873 then
                sampSetCurrentDialogEditboxText("100")     -- -------------------------- Вместо 1 в этой строке введите мин. значение
                sampCloseCurrentDialogWithButton(1)
            end
            if dialogId == 874 then
                sampSetCurrentDialogEditboxText("200")     -- -------------------------- Вместо 2 в этой строке введите макс. значение
                sampCloseCurrentDialogWithButton(1)
            end
        end)
    end
end
не работает, прописываю команду и просто пишет активировано/деактивировано, функционал не изменился
говно:
local enabled = false
function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand('test', function()
    enabled = not enabled
    sampAddChatMessage(enabled and '{ffffff}Активирован' or '{ffffff}Деактивирован', -1)
  end)
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if enabled then
        lua_thread.create(function ()
            wait(0)
            if dialogId == 872 then
                sampCloseCurrentDialogWithButton(1)
            end
            if dialogId == 873 then
                sampSetCurrentDialogEditboxText("100")     -- -------------------------- Вместо 1 в этой строке введите мин. значение
                sampCloseCurrentDialogWithButton(1)
            end
            if dialogId == 874 then
                sampSetCurrentDialogEditboxText("200")     -- -------------------------- Вместо 2 в этой строке введите макс. значение
                sampCloseCurrentDialogWithButton(1)
            end
        end)
    end
end


вот мой код, пропиши тут, если не сложно






Код:
require "lib.moonloader"
local mem = require "memory"
local sampev = require 'lib.samp.events'

local tag = "[ Black Jack Bot ] -"
local color = 0x7CFC00
local color_text = "{7CFC00}"
local fcolor = 0xFF0A37
local fcolor_text = "{FF0A37}"
local main_color = 0x8A2BE2
local main_color_text = "{8A2BE2}"
local white_color = "{FFFFFF}"



function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    wait(3000)
    sampAddChatMessage(tag .. white_color .. " Скрипт загружен!" .. color_text .. " Автор:" .. fcolor_text .. " Marlon <3", main_color)
    while true do
    wait(0)
    end 
    wait(-1)
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    lua_thread.create(function ()
        wait(0)
        if dialogId == 872 then
            sampCloseCurrentDialogWithButton(1)
        end
        if dialogId == 873 then
            sampSetCurrentDialogEditboxText("100")     -- -------------------------- Вместо 1 в этой строке введите мин. значение
            sampCloseCurrentDialogWithButton(1)
        end
        if dialogId == 874 then
            sampSetCurrentDialogEditboxText("200")     -- -------------------------- Вместо 2 в этой строке введите макс. значение
            sampCloseCurrentDialogWithButton(1)
        end
    end)
end
говно:
local enabled = false
function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand('test', function()
    enabled = not enabled
    sampAddChatMessage(enabled and '{ffffff}Активирован' or '{ffffff}Деактивирован', -1)
  end)
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if enabled then
        lua_thread.create(function ()
            wait(0)
            if dialogId == 872 then
                sampCloseCurrentDialogWithButton(1)
            end
            if dialogId == 873 then
                sampSetCurrentDialogEditboxText("100")     -- -------------------------- Вместо 1 в этой строке введите мин. значение
                sampCloseCurrentDialogWithButton(1)
            end
            if dialogId == 874 then
                sampSetCurrentDialogEditboxText("200")     -- -------------------------- Вместо 2 в этой строке введите макс. значение
                sampCloseCurrentDialogWithButton(1)
            end
        end)
    end
end
Cори, это я дебил, я просто 2 скрипта создал с одинаковыми функциями - один исходник, другой с этой командой )))
 
Последнее редактирование: