Вопросы по Lua скриптингу

Общая тема для вопросов по разработке скриптов на языке программирования Lua, в частности под MoonLoader.
  • Задавая вопрос, убедитесь, что его нет в списке частых вопросов и что на него ещё не отвечали (воспользуйтесь поиском).
  • Поищите ответ в теме посвященной разработке Lua скриптов в MoonLoader
  • Отвечая, убедитесь, что ваш ответ корректен.
  • Старайтесь как можно точнее выразить мысль, а если проблема связана с кодом, то обязательно прикрепите его к сообщению, используя блок [code=lua]здесь мог бы быть ваш код[/code].
  • Если вопрос связан с MoonLoader-ом первым делом желательно поискать решение на wiki.

Частые вопросы

Как научиться писать скрипты? С чего начать?
Информация - Гайд - Всё о Lua скриптинге для MoonLoader(https://blast.hk/threads/22707/)
Как вывести текст на русском? Вместо русского текста у меня какие-то каракули.
Изменить кодировку файла скрипта на Windows-1251. В Atom: комбинация клавиш Ctrl+Shift+U, в Notepad++: меню Кодировки -> Кодировки -> Кириллица -> Windows-1251.
Как получить транспорт, в котором сидит игрок?
Lua:
local veh = storeCarCharIsInNoSave(PLAYER_PED)
Как получить свой id или id другого игрока?
Lua:
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED) -- получить свой ид
local _, id = sampGetPlayerIdByCharHandle(ped) -- получить ид другого игрока. ped - это хендл персонажа
Как проверить, что строка содержит какой-то текст?
Lua:
if string.find(str, 'текст', 1, true) then
-- строка str содержит "текст"
end
Как эмулировать нажатие игровой клавиши?
Lua:
local game_keys = require 'game.keys' -- где-нибудь в начале скрипта вне функции main

setGameKeyState(game_keys.player.FIREWEAPON, -1) -- будет сэмулировано нажатие клавиши атаки
Все иды клавиш находятся в файле moonloader/lib/game/keys.lua.
Подробнее о функции setGameKeyState здесь: lua - setgamekeystate | BlastHack — DEV_WIKI(https://www.blast.hk/wiki/lua:setgamekeystate)
Как получить id другого игрока, в которого целюсь я?
Lua:
local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE) -- получить хендл персонажа, в которого целится игрок
if valid and doesCharExist(ped) then -- если цель есть и персонаж существует
  local result, id = sampGetPlayerIdByCharHandle(ped) -- получить samp-ид игрока по хендлу персонажа
  if result then -- проверить, прошло ли получение ида успешно
    -- здесь любые действия с полученным идом игрока
  end
end
Как зарегистрировать команду чата SAMP?
Lua:
-- До бесконечного цикла/задержки
sampRegisterChatCommand("mycommand", function (param)
     -- param будет содержать весь текст введенный после команды, чтобы разделить его на аргументы используйте string.match()
    sampAddChatMessage("MyCMD", -1)
end)
Крашит игру при вызове sampSendChat. Как это исправить?
Это происходит из-за бага в SAMPFUNCS, когда производится попытка отправки пакета определенными функциями изнутри события исходящих RPC и пакетов. Исправления для этого бага нет, но есть способ не провоцировать его. Вызов sampSendChat изнутри обработчика исходящих RPC/пакетов нужно обернуть в скриптовый поток с нулевой задержкой:
Lua:
function onSendRpc(id)
  -- крашит:
  -- sampSendChat('Send RPC: ' .. id)

  -- норм:
  lua_thread.create(function()
    wait(0)
    sampSendChat('Send RPC: ' .. id)
  end)
end
 
Последнее редактирование:

wulfandr

Известный
637
260
как отправить сообщение в беседу в вк? Гайдов для чайников не нашел
Lua:
local leffil, effil     = pcall(require, 'effil') assert(leffil, 'Library \'effil\' not found')
local encoding          = require 'encoding'
local lsampev, sampev     = pcall(require, 'lib.samp.events') assert(lsampev, 'Library \'lib.samp.events\' not found.')

encoding.default            = 'CP1251'
u8 = encoding.UTF8

local settings = {
    ['url'] = 'http://api.vk.com/method/messages.send?', -- api method + url
    ['token'] = 'asdasdasd',
    ['peer_id'] = 2000000002 -- id of group
}


function ptext(text)
    sampAddChatMessage(('%s | {ffffff}%s'):format(script.this.name, text), 0xA52A2A)
end

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("sendmes", function(pam)
        if #pam ~= 0 then
            local _, myid = sampGetPlayerIdByCharHandle(PLAYER_PED)
            local mynick = sampGetPlayerNickname(myid)
            asyncHttpRequest('GET', settings['url']..'peer_id='.. settings['peer_id'] ..'&message='.. encodeURI(u8:encode(''.. mynick..'['.. myid..'] сказал: '..pam)) ..'&access_token='..settings['token']..'&v=5.80', nil,
            function(response)
                if response then
                    if response.status_code == 200 then ptext('Сообщение отправлено в группу.') end
                end
            end,
            function(err)
                print(err)
            end)
        else
            ptext('Используйте: /sendmes [сообщение]')
        end
    end)
    wait(-1)
end


function sendMes(pam)
    if #pam ~= 0 then
        asyncHttpRequest('GET', settings['url']..'peer_id='.. settings['peer_id'] ..'&message='.. encodeURI(u8:encode(pam)) ..'&access_token='..settings['token']..'&v=5.80', nil,
        function(response)
            if response then
                if response.status_code == 200 then ptext('Сообщение отправлено в группу.') end
            end
        end,
        function(err)
            print(err)
        end)
    end
end

function encodeURI(str)
    if (str) then
        str = string.gsub (str, "\n", "\r\n")
        str = string.gsub (str, "([^%w ])",
        function (c) return string.format ("%%%02X", string.byte(c)) end)
        str = string.gsub (str, " ", "+")
    end
    return str
end


function asyncHttpRequest(method, url, args, resolve, reject)
    local request_thread = effil.thread(function (method, url, args)
        local requests = require 'requests'
        local result, response = pcall(requests.request, method, url, args)
        if result then
            response.json, response.xml = nil, nil
            return true, response
        else
            return false, response
        end
    end) (method, url, args)
    if not resolve then resolve = function() end end
    if not reject then reject = function() end end
    lua_thread.create(function()
        local runner = request_thread
        while true do
            local status, err = runner:status()
            if not err then
                if status == 'completed' then
                    local result, response = runner:get()
                    if result then
                        resolve(response)
                    else
                        reject(response)
                    end
                return
                elseif status == 'canceled' then
                    return reject(status)
                end
            else
                return reject(err)
            end
            wait(0)
        end
    end)
end
 
  • Нравится
Реакции: rvng и chapo

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,771
11,214
Как создается свечение на земле от амулета на арз?
1630682393680.png

1630682425198.png
 
  • Влюблен
Реакции: rvng

abnomegd

Активный
335
35
Помогите поставить нормально эти гребанные енды
gg:
require "lib.moonloader" -- подключение библиотеки
local color_dialog = 0xDEB887

-- Для диалога с ID 12
local dialogArr = {"История ников", "Добавить в записную книгу", "Показать документы", "Действия", "Имущество"};
local dialogStr = ""

for _, str in ipairs(dialogArr) do
    dialogStr = dialogStr .. str .. "\n"
end

-- Для диалога с ID 13
local dialogArra = {"Паспорт", "Лицензии", "Медкарта", "МедДиплом", "Выписка из тира", "Трудовая книга", "Военный билет", "Повестка в армию", "Отчёт о работе"}
local dialogStra = ""

for _, stra in ipairs(dialogArra) do
    dialogStra = dialogStra .. stra .. "\n"
end

-- Для диалога с ID 14
local dialogArras = {"Дать денег", "Передать металл / патроны / наркотики / маски / аптечки", "Подарить цветы", "Жениться", "Предложить побег", "Поселить к себе", "Дать ключи от авто"};
local dialogStras = ""

for _, stras in ipairs(dialogArras) do
    dialogStras = dialogStras .. stras .. "\n"
end

-- Для диалога с ID 15
local dialogArrasa = {"Продать машину", "Продать дом", "Продать бизнес", "Обмен авто", "Обмен домами", "Обмен бизнесами"};
local dialogStrasa = ""

for _, strasa in ipairs(dialogArrasa) do
    dialogStrasa = dialogStrasa .. strasa .. "\n"
end
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("dialog", cmd_dialog)
    sampAddChatMessage("[HelperARP]: {FFFFFF}Скрипт загружен!", 0x5CBCFF)
    while true do
        wait(0)
        -- Блок выполняющийся бесконечно (пока самп активен)
        local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
        if valid and doesCharExist(ped) then
            local result, id = sampGetPlayerIdByCharHandle(ped)
            if result and isKeyJustPressed(VK_X) then
                playerid = id
                cmd_dialog(2)
            end
        end

        local result, button, list, input = sampHasDialogRespond(11) -- /dialog1 (InputBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                if list == 0 then
                    sampSendChat("/pay "..tostring(playerid)..' '..input)
                end
            end
    
        local result, button, list, input = sampHasDialogRespond(12) -- /dialog2 (ListBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                -- list - переменная содержащая порядковый ид нажатой в диалоге кнопки (listbox), счёт начинается с 0.
                if list == 0 then -- если нажато "История ников"
                    sampSendChat("/history "..sampGetPlayerNickname(tonumber(playerid)))
                elseif list == 1 then -- "Добавить в записную книгу"
                    sampSendChat("/add "..tostring(playerid))
                elseif list == 2 then -- "Показать документы"
                    cmd_dialog(3)
                elseif list == 3 then -- "Действия"
                    cmd_dialog(4)
                elseif list == 4 then -- "Имущество"
                    cmd_dialog(5)
                end
            end

        local result, button, list, input = sampHasDialogRespond(13) -- /dialog3 (ListBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                if list == 0 then -- Паспорт
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки паспорт")
                        wait(1000)
                        sampSendChat("/pass "..tostring(playerid))
                        end)
                elseif list == 1 then -- Лицензии
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки лицензии")
                        wait(1000)
                        sampSendChat("/lic "..tostring(playerid))
                        end)
                elseif list == 2 then -- Медкарта
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки медицинскую карту")
                        wait(1000)
                        sampSendChat("/me показывает медицинскую карту человеку напротив")
                        wait(1000)
                        sampSendChat("/med "..tostring(playerid))
                        end)
                elseif list == 3 then -- МедДиплом
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки медицинский диплом")
                        wait(1000)
                        sampSendChat("/me показывает медицинский диплом человеку напротив")
                        end)
                elseif list == 4 then -- Выписка из тира
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки выписку из тира")
                        wait(1000)
                        sampSendChat("/skill "..tostring(playerid))
                        end)
                elseif list == 5 then -- Трудовая книга
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки трудовую книгу")
                        wait(1000)
                        sampSendChat("/wbook "..tostring(playerid))
                        end)
                elseif list == 6 then -- Военный билет
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки военный билет")
                        wait(1000)
                        sampSendChat("/me показывает военный билет человеку напротив")
                        end)
                elseif list == 7 then -- Повестка в армию
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки повестку")
                        wait(1000)
                        sampSendChat("/me показывает повестку в армию человеку напротив")
                        end)
                elseif list == 8 then -- Отчёт о работе
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки отчёт о выполненой работе")
                        wait(1000)
                        sampSendChat("/team "..tostring(playerid))
                        end)
                end
            else -- если нажата вторая кнопка (Закрыть)
            end
        end

local result, button, list, input = sampHasDialogRespond(14) -- /dialog3 (ListBox)
if result then -- если диалог открыт
    if button == 1 then -- если нажата первая кнопка (Выбрать)
        if list == 0 then -- Дать денег
            cmd_dialog(1)
        elseif list == 1 then -- Передать
            sampSendChat("/give "..tostring(playerid))
        elseif list == 2 then -- Подарить цветы
            lua_thread.create(function()
                sampSendChat("В знак моего внимания к Вам,")
                wait(1000)
                sampSendChat("Прошу принять этот подарок")
                wait(1000)
                sampSendChat("/do Букет цветов в руках.")
                wait(1000)
                sampSendChat("/me передает букет в руки")
                wait(1000)
                sampSendChat("/present "..tostring(playerid))
                end)
        elseif list == 3 then -- Жениться на
           sampSendChat("/wedding "..tostring(playerid))
        elseif list == 4 then -- Предложить побег
            sampSendChat("/jailbreak "..tostring(playerid))
        elseif list == 5 then -- Поселить к себе
            sampSendChat("/live "..tostring(playerid))
        elseif list == 6 then -- Дать ключи от авто
            sampSendChat("/allow "..tostring(playerid))
        end
    else -- если нажата вторая кнопка (Закрыть)
    end
end

local result, button, list, input = sampHasDialogRespond(15) -- /dialog3 (ListBox)
if result then -- если диалог открыт
    if button == 1 then -- если нажата первая кнопка (Выбрать)
        if list == 0 then -- Продать авто
            cmd_dialog(6)
        elseif list == 1 then -- Передать
        elseif list == 2 then -- Подарить цветы
        elseif list == 3 then -- Жениться на
        elseif list == 4 then -- Предложить побег
        elseif list == 5 then -- Поселить к себе
        end
    else -- если нажата вторая кнопка (Закрыть)
    end
end


local result, button, list, input = sampHasDialogRespond(16) -- /dialog1 (InputBox)
if result then -- если диалог открыт
    if button == 1 then -- если нажата первая кнопка (Выбрать)
        if list == 0 then
            sampSendChat("/sellmycar "..tostring(playerid).." "..input)
        end
    end
end


local result, button, list, input = sampHasDialogRespond(17) -- /dialog1 (InputBox)
if result then -- если диалог открыт
    if button == 1 then -- если нажата первая кнопка (Выбрать)
        if list == 0 then
            sampSendChat("/sellmyhome "..tostring(playerid).." "..input)
            end
        end
    end
end

function cmd_dialog(arg)
    if tonumber(arg) == 1 then
        sampShowDialog(11, "{00ff00}Дать денег", "", "Дать", "Не дать", 1)
    elseif tonumber(arg) == 2 then
        sampShowDialog(12, "{00ff00}Меню взаимодействия с игроком", dialogStr, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 3 then
        sampShowDialog(13, "{00ff00}Показать документы", dialogStra, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 4 then
        sampShowDialog(14, "{00ff00}Действия", dialogStras, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 5 then
        sampShowDialog(15, "{00ff00}Имущество", dialogStrasa, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 6 then
        sampShowDialog(16, "{00ff00}Продать авто", "Введите цену машины.", "Выбрать", "Закрыть", 1)   
    elseif tonumber(arg) == 7 then
        sampShowDialog(17, "{00ff00}Продать дом", "Введите цену дома.", "Выбрать", "Закрыть", 1)   
        end
    end
 

Dmitriy Makarov

25.05.2021
Проверенный
2,478
1,113
Помогите поставить нормально эти гребанные енды
gg:
require "lib.moonloader" -- подключение библиотеки
local color_dialog = 0xDEB887

-- Для диалога с ID 12
local dialogArr = {"История ников", "Добавить в записную книгу", "Показать документы", "Действия", "Имущество"};
local dialogStr = ""

for _, str in ipairs(dialogArr) do
    dialogStr = dialogStr .. str .. "\n"
end

-- Для диалога с ID 13
local dialogArra = {"Паспорт", "Лицензии", "Медкарта", "МедДиплом", "Выписка из тира", "Трудовая книга", "Военный билет", "Повестка в армию", "Отчёт о работе"}
local dialogStra = ""

for _, stra in ipairs(dialogArra) do
    dialogStra = dialogStra .. stra .. "\n"
end

-- Для диалога с ID 14
local dialogArras = {"Дать денег", "Передать металл / патроны / наркотики / маски / аптечки", "Подарить цветы", "Жениться", "Предложить побег", "Поселить к себе", "Дать ключи от авто"};
local dialogStras = ""

for _, stras in ipairs(dialogArras) do
    dialogStras = dialogStras .. stras .. "\n"
end

-- Для диалога с ID 15
local dialogArrasa = {"Продать машину", "Продать дом", "Продать бизнес", "Обмен авто", "Обмен домами", "Обмен бизнесами"};
local dialogStrasa = ""

for _, strasa in ipairs(dialogArrasa) do
    dialogStrasa = dialogStrasa .. strasa .. "\n"
end
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("dialog", cmd_dialog)
    sampAddChatMessage("[HelperARP]: {FFFFFF}Скрипт загружен!", 0x5CBCFF)
    while true do
        wait(0)
        -- Блок выполняющийся бесконечно (пока самп активен)
        local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
        if valid and doesCharExist(ped) then
            local result, id = sampGetPlayerIdByCharHandle(ped)
            if result and isKeyJustPressed(VK_X) then
                playerid = id
                cmd_dialog(2)
            end
        end

        local result, button, list, input = sampHasDialogRespond(11) -- /dialog1 (InputBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                if list == 0 then
                    sampSendChat("/pay "..tostring(playerid)..' '..input)
                end
            end
   
        local result, button, list, input = sampHasDialogRespond(12) -- /dialog2 (ListBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                -- list - переменная содержащая порядковый ид нажатой в диалоге кнопки (listbox), счёт начинается с 0.
                if list == 0 then -- если нажато "История ников"
                    sampSendChat("/history "..sampGetPlayerNickname(tonumber(playerid)))
                elseif list == 1 then -- "Добавить в записную книгу"
                    sampSendChat("/add "..tostring(playerid))
                elseif list == 2 then -- "Показать документы"
                    cmd_dialog(3)
                elseif list == 3 then -- "Действия"
                    cmd_dialog(4)
                elseif list == 4 then -- "Имущество"
                    cmd_dialog(5)
                end
            end

        local result, button, list, input = sampHasDialogRespond(13) -- /dialog3 (ListBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                if list == 0 then -- Паспорт
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки паспорт")
                        wait(1000)
                        sampSendChat("/pass "..tostring(playerid))
                        end)
                elseif list == 1 then -- Лицензии
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки лицензии")
                        wait(1000)
                        sampSendChat("/lic "..tostring(playerid))
                        end)
                elseif list == 2 then -- Медкарта
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки медицинскую карту")
                        wait(1000)
                        sampSendChat("/me показывает медицинскую карту человеку напротив")
                        wait(1000)
                        sampSendChat("/med "..tostring(playerid))
                        end)
                elseif list == 3 then -- МедДиплом
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки медицинский диплом")
                        wait(1000)
                        sampSendChat("/me показывает медицинский диплом человеку напротив")
                        end)
                elseif list == 4 then -- Выписка из тира
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки выписку из тира")
                        wait(1000)
                        sampSendChat("/skill "..tostring(playerid))
                        end)
                elseif list == 5 then -- Трудовая книга
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки трудовую книгу")
                        wait(1000)
                        sampSendChat("/wbook "..tostring(playerid))
                        end)
                elseif list == 6 then -- Военный билет
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки военный билет")
                        wait(1000)
                        sampSendChat("/me показывает военный билет человеку напротив")
                        end)
                elseif list == 7 then -- Повестка в армию
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки повестку")
                        wait(1000)
                        sampSendChat("/me показывает повестку в армию человеку напротив")
                        end)
                elseif list == 8 then -- Отчёт о работе
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки отчёт о выполненой работе")
                        wait(1000)
                        sampSendChat("/team "..tostring(playerid))
                        end)
                end
            else -- если нажата вторая кнопка (Закрыть)
            end
        end

local result, button, list, input = sampHasDialogRespond(14) -- /dialog3 (ListBox)
if result then -- если диалог открыт
    if button == 1 then -- если нажата первая кнопка (Выбрать)
        if list == 0 then -- Дать денег
            cmd_dialog(1)
        elseif list == 1 then -- Передать
            sampSendChat("/give "..tostring(playerid))
        elseif list == 2 then -- Подарить цветы
            lua_thread.create(function()
                sampSendChat("В знак моего внимания к Вам,")
                wait(1000)
                sampSendChat("Прошу принять этот подарок")
                wait(1000)
                sampSendChat("/do Букет цветов в руках.")
                wait(1000)
                sampSendChat("/me передает букет в руки")
                wait(1000)
                sampSendChat("/present "..tostring(playerid))
                end)
        elseif list == 3 then -- Жениться на
           sampSendChat("/wedding "..tostring(playerid))
        elseif list == 4 then -- Предложить побег
            sampSendChat("/jailbreak "..tostring(playerid))
        elseif list == 5 then -- Поселить к себе
            sampSendChat("/live "..tostring(playerid))
        elseif list == 6 then -- Дать ключи от авто
            sampSendChat("/allow "..tostring(playerid))
        end
    else -- если нажата вторая кнопка (Закрыть)
    end
end

local result, button, list, input = sampHasDialogRespond(15) -- /dialog3 (ListBox)
if result then -- если диалог открыт
    if button == 1 then -- если нажата первая кнопка (Выбрать)
        if list == 0 then -- Продать авто
            cmd_dialog(6)
        elseif list == 1 then -- Передать
        elseif list == 2 then -- Подарить цветы
        elseif list == 3 then -- Жениться на
        elseif list == 4 then -- Предложить побег
        elseif list == 5 then -- Поселить к себе
        end
    else -- если нажата вторая кнопка (Закрыть)
    end
end


local result, button, list, input = sampHasDialogRespond(16) -- /dialog1 (InputBox)
if result then -- если диалог открыт
    if button == 1 then -- если нажата первая кнопка (Выбрать)
        if list == 0 then
            sampSendChat("/sellmycar "..tostring(playerid).." "..input)
        end
    end
end


local result, button, list, input = sampHasDialogRespond(17) -- /dialog1 (InputBox)
if result then -- если диалог открыт
    if button == 1 then -- если нажата первая кнопка (Выбрать)
        if list == 0 then
            sampSendChat("/sellmyhome "..tostring(playerid).." "..input)
            end
        end
    end
end

function cmd_dialog(arg)
    if tonumber(arg) == 1 then
        sampShowDialog(11, "{00ff00}Дать денег", "", "Дать", "Не дать", 1)
    elseif tonumber(arg) == 2 then
        sampShowDialog(12, "{00ff00}Меню взаимодействия с игроком", dialogStr, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 3 then
        sampShowDialog(13, "{00ff00}Показать документы", dialogStra, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 4 then
        sampShowDialog(14, "{00ff00}Действия", dialogStras, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 5 then
        sampShowDialog(15, "{00ff00}Имущество", dialogStrasa, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 6 then
        sampShowDialog(16, "{00ff00}Продать авто", "Введите цену машины.", "Выбрать", "Закрыть", 1)  
    elseif tonumber(arg) == 7 then
        sampShowDialog(17, "{00ff00}Продать дом", "Введите цену дома.", "Выбрать", "Закрыть", 1)  
        end
    end
У тебя табуляция сбита в некоторых местах, поэтому ты запутался, скорее всего. У тебя ещё не был закрыт беск. цикл и main. Попробуй вот так.
Lua:
require "lib.moonloader" -- подключение библиотеки
local color_dialog = 0xDEB887

-- Для диалога с ID 12
local dialogArr = {"История ников", "Добавить в записную книгу", "Показать документы", "Действия", "Имущество"};
local dialogStr = ""

for _, str in ipairs(dialogArr) do
    dialogStr = dialogStr .. str .. "\n"
end

-- Для диалога с ID 13
local dialogArra = {"Паспорт", "Лицензии", "Медкарта", "МедДиплом", "Выписка из тира", "Трудовая книга", "Военный билет", "Повестка в армию", "Отчёт о работе"}
local dialogStra = ""

for _, stra in ipairs(dialogArra) do
    dialogStra = dialogStra .. stra .. "\n"
end

-- Для диалога с ID 14
local dialogArras = {"Дать денег", "Передать металл / патроны / наркотики / маски / аптечки", "Подарить цветы", "Жениться", "Предложить побег", "Поселить к себе", "Дать ключи от авто"};
local dialogStras = ""

for _, stras in ipairs(dialogArras) do
    dialogStras = dialogStras .. stras .. "\n"
end

-- Для диалога с ID 15
local dialogArrasa = {"Продать машину", "Продать дом", "Продать бизнес", "Обмен авто", "Обмен домами", "Обмен бизнесами"};
local dialogStrasa = ""

for _, strasa in ipairs(dialogArrasa) do
    dialogStrasa = dialogStrasa .. strasa .. "\n"
end

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("dialog", cmd_dialog)
    sampAddChatMessage("[HelperARP]: {FFFFFF}Скрипт загружен!", 0x5CBCFF)
    while true do
        wait(0)
        -- Блок выполняющийся бесконечно (пока самп активен)
        local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
        if valid and doesCharExist(ped) then
            local result, id = sampGetPlayerIdByCharHandle(ped)
            if result and isKeyJustPressed(VK_X) then
                playerid = id
                cmd_dialog(2)
            end
        end

        local result, button, list, input = sampHasDialogRespond(11) -- /dialog1 (InputBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                if list == 0 then
                    sampSendChat("/pay "..tostring(playerid)..' '..input)
                end
            end
        end

        local result, button, list, input = sampHasDialogRespond(12) -- /dialog2 (ListBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                -- list - переменная содержащая порядковый ид нажатой в диалоге кнопки (listbox), счёт начинается с 0.
                if list == 0 then -- если нажато "История ников"
                    sampSendChat("/history "..sampGetPlayerNickname(tonumber(playerid)))
                elseif list == 1 then -- "Добавить в записную книгу"
                    sampSendChat("/add "..tostring(playerid))
                elseif list == 2 then -- "Показать документы"
                    cmd_dialog(3)
                elseif list == 3 then -- "Действия"
                    cmd_dialog(4)
                elseif list == 4 then -- "Имущество"
                    cmd_dialog(5)
                end
            end
        end

        local result, button, list, input = sampHasDialogRespond(13) -- /dialog3 (ListBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                if list == 0 then -- Паспорт
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки паспорт")
                        wait(1000)
                        sampSendChat("/pass "..tostring(playerid))
                    end)
                elseif list == 1 then -- Лицензии
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки лицензии")
                        wait(1000)
                        sampSendChat("/lic "..tostring(playerid))
                    end)
                elseif list == 2 then -- Медкарта
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки медицинскую карту")
                        wait(1000)
                        sampSendChat("/me показывает медицинскую карту человеку напротив")
                        wait(1000)
                        sampSendChat("/med "..tostring(playerid))
                    end)
                elseif list == 3 then -- МедДиплом
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки медицинский диплом")
                        wait(1000)
                        sampSendChat("/me показывает медицинский диплом человеку напротив")
                    end)
                elseif list == 4 then -- Выписка из тира
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки выписку из тира")
                        wait(1000)
                        sampSendChat("/skill "..tostring(playerid))
                    end)
                elseif list == 5 then -- Трудовая книга
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки трудовую книгу")
                        wait(1000)
                        sampSendChat("/wbook "..tostring(playerid))
                    end)
                elseif list == 6 then -- Военный билет
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки военный билет")
                        wait(1000)
                        sampSendChat("/me показывает военный билет человеку напротив")
                    end)
                elseif list == 7 then -- Повестка в армию
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки повестку")
                        wait(1000)
                        sampSendChat("/me показывает повестку в армию человеку напротив")
                    end)
                elseif list == 8 then -- Отчёт о работе
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки отчёт о выполненой работе")
                        wait(1000)
                        sampSendChat("/team "..tostring(playerid))
                    end)
                end
            else -- если нажата вторая кнопка (Закрыть)
            end
        end

        local result, button, list, input = sampHasDialogRespond(14) -- /dialog3 (ListBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                if list == 0 then -- Дать денег
                    cmd_dialog(1)
                elseif list == 1 then -- Передать
                    sampSendChat("/give "..tostring(playerid))
                elseif list == 2 then -- Подарить цветы
                    lua_thread.create(function()
                        sampSendChat("В знак моего внимания к Вам,")
                        wait(1000)
                        sampSendChat("Прошу принять этот подарок")
                        wait(1000)
                        sampSendChat("/do Букет цветов в руках.")
                        wait(1000)
                        sampSendChat("/me передает букет в руки")
                        wait(1000)
                        sampSendChat("/present "..tostring(playerid))
                    end)
                elseif list == 3 then -- Жениться на
                    sampSendChat("/wedding "..tostring(playerid))
                elseif list == 4 then -- Предложить побег
                    sampSendChat("/jailbreak "..tostring(playerid))
                elseif list == 5 then -- Поселить к себе
                    sampSendChat("/live "..tostring(playerid))
                elseif list == 6 then -- Дать ключи от авто
                    sampSendChat("/allow "..tostring(playerid))
                end
            else -- если нажата вторая кнопка (Закрыть)
            end
        end

        local result, button, list, input = sampHasDialogRespond(15) -- /dialog3 (ListBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                if list == 0 then -- Продать авто
                    cmd_dialog(6)
                elseif list == 1 then -- Передать
                elseif list == 2 then -- Подарить цветы
                elseif list == 3 then -- Жениться на
                elseif list == 4 then -- Предложить побег
                elseif list == 5 then -- Поселить к себе
                end
            else -- если нажата вторая кнопка (Закрыть)
            end
        end

        local result, button, list, input = sampHasDialogRespond(16) -- /dialog1 (InputBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                if list == 0 then
                    sampSendChat("/sellmycar "..tostring(playerid).." "..input)
                end
            end
        end

        local result, button, list, input = sampHasDialogRespond(17) -- /dialog1 (InputBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                if list == 0 then
                    sampSendChat("/sellmyhome "..tostring(playerid).." "..input)
                end
            end
        end
    end
end

function cmd_dialog(arg)
    if tonumber(arg) == 1 then
        sampShowDialog(11, "{00ff00}Дать денег", "", "Дать", "Не дать", 1)
    elseif tonumber(arg) == 2 then
        sampShowDialog(12, "{00ff00}Меню взаимодействия с игроком", dialogStr, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 3 then
        sampShowDialog(13, "{00ff00}Показать документы", dialogStra, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 4 then
        sampShowDialog(14, "{00ff00}Действия", dialogStras, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 5 then
        sampShowDialog(15, "{00ff00}Имущество", dialogStrasa, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 6 then
        sampShowDialog(16, "{00ff00}Продать авто", "Введите цену машины.", "Выбрать", "Закрыть", 1)   
    elseif tonumber(arg) == 7 then
        sampShowDialog(17, "{00ff00}Продать дом", "Введите цену дома.", "Выбрать", "Закрыть", 1)   
    end
end
 

madrasso

Потрачен
883
324
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Помогите поставить нормально эти гребанные енды
gg:
require "lib.moonloader" -- подключение библиотеки
local color_dialog = 0xDEB887

-- Для диалога с ID 12
local dialogArr = {"История ников", "Добавить в записную книгу", "Показать документы", "Действия", "Имущество"};
local dialogStr = ""

for _, str in ipairs(dialogArr) do
    dialogStr = dialogStr .. str .. "\n"
end

-- Для диалога с ID 13
local dialogArra = {"Паспорт", "Лицензии", "Медкарта", "МедДиплом", "Выписка из тира", "Трудовая книга", "Военный билет", "Повестка в армию", "Отчёт о работе"}
local dialogStra = ""

for _, stra in ipairs(dialogArra) do
    dialogStra = dialogStra .. stra .. "\n"
end

-- Для диалога с ID 14
local dialogArras = {"Дать денег", "Передать металл / патроны / наркотики / маски / аптечки", "Подарить цветы", "Жениться", "Предложить побег", "Поселить к себе", "Дать ключи от авто"};
local dialogStras = ""

for _, stras in ipairs(dialogArras) do
    dialogStras = dialogStras .. stras .. "\n"
end

-- Для диалога с ID 15
local dialogArrasa = {"Продать машину", "Продать дом", "Продать бизнес", "Обмен авто", "Обмен домами", "Обмен бизнесами"};
local dialogStrasa = ""

for _, strasa in ipairs(dialogArrasa) do
    dialogStrasa = dialogStrasa .. strasa .. "\n"
end
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("dialog", cmd_dialog)
    sampAddChatMessage("[HelperARP]: {FFFFFF}Скрипт загружен!", 0x5CBCFF)
    while true do
        wait(0)
        -- Блок выполняющийся бесконечно (пока самп активен)
        local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
        if valid and doesCharExist(ped) then
            local result, id = sampGetPlayerIdByCharHandle(ped)
            if result and isKeyJustPressed(VK_X) then
                playerid = id
                cmd_dialog(2)
            end
        end

        local result, button, list, input = sampHasDialogRespond(11) -- /dialog1 (InputBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                if list == 0 then
                    sampSendChat("/pay "..tostring(playerid)..' '..input)
                end
            end
   
        local result, button, list, input = sampHasDialogRespond(12) -- /dialog2 (ListBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                -- list - переменная содержащая порядковый ид нажатой в диалоге кнопки (listbox), счёт начинается с 0.
                if list == 0 then -- если нажато "История ников"
                    sampSendChat("/history "..sampGetPlayerNickname(tonumber(playerid)))
                elseif list == 1 then -- "Добавить в записную книгу"
                    sampSendChat("/add "..tostring(playerid))
                elseif list == 2 then -- "Показать документы"
                    cmd_dialog(3)
                elseif list == 3 then -- "Действия"
                    cmd_dialog(4)
                elseif list == 4 then -- "Имущество"
                    cmd_dialog(5)
                end
            end

        local result, button, list, input = sampHasDialogRespond(13) -- /dialog3 (ListBox)
        if result then -- если диалог открыт
            if button == 1 then -- если нажата первая кнопка (Выбрать)
                if list == 0 then -- Паспорт
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки паспорт")
                        wait(1000)
                        sampSendChat("/pass "..tostring(playerid))
                        end)
                elseif list == 1 then -- Лицензии
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки лицензии")
                        wait(1000)
                        sampSendChat("/lic "..tostring(playerid))
                        end)
                elseif list == 2 then -- Медкарта
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки медицинскую карту")
                        wait(1000)
                        sampSendChat("/me показывает медицинскую карту человеку напротив")
                        wait(1000)
                        sampSendChat("/med "..tostring(playerid))
                        end)
                elseif list == 3 then -- МедДиплом
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки медицинский диплом")
                        wait(1000)
                        sampSendChat("/me показывает медицинский диплом человеку напротив")
                        end)
                elseif list == 4 then -- Выписка из тира
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки выписку из тира")
                        wait(1000)
                        sampSendChat("/skill "..tostring(playerid))
                        end)
                elseif list == 5 then -- Трудовая книга
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки трудовую книгу")
                        wait(1000)
                        sampSendChat("/wbook "..tostring(playerid))
                        end)
                elseif list == 6 then -- Военный билет
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки военный билет")
                        wait(1000)
                        sampSendChat("/me показывает военный билет человеку напротив")
                        end)
                elseif list == 7 then -- Повестка в армию
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки повестку")
                        wait(1000)
                        sampSendChat("/me показывает повестку в армию человеку напротив")
                        end)
                elseif list == 8 then -- Отчёт о работе
                    lua_thread.create(function()
                        sampSendChat("/do Папка с документами в руке.")
                        wait(1000)
                        sampSendChat("/me достает из папки отчёт о выполненой работе")
                        wait(1000)
                        sampSendChat("/team "..tostring(playerid))
                        end)
                end
            else -- если нажата вторая кнопка (Закрыть)
            end
        end

local result, button, list, input = sampHasDialogRespond(14) -- /dialog3 (ListBox)
if result then -- если диалог открыт
    if button == 1 then -- если нажата первая кнопка (Выбрать)
        if list == 0 then -- Дать денег
            cmd_dialog(1)
        elseif list == 1 then -- Передать
            sampSendChat("/give "..tostring(playerid))
        elseif list == 2 then -- Подарить цветы
            lua_thread.create(function()
                sampSendChat("В знак моего внимания к Вам,")
                wait(1000)
                sampSendChat("Прошу принять этот подарок")
                wait(1000)
                sampSendChat("/do Букет цветов в руках.")
                wait(1000)
                sampSendChat("/me передает букет в руки")
                wait(1000)
                sampSendChat("/present "..tostring(playerid))
                end)
        elseif list == 3 then -- Жениться на
           sampSendChat("/wedding "..tostring(playerid))
        elseif list == 4 then -- Предложить побег
            sampSendChat("/jailbreak "..tostring(playerid))
        elseif list == 5 then -- Поселить к себе
            sampSendChat("/live "..tostring(playerid))
        elseif list == 6 then -- Дать ключи от авто
            sampSendChat("/allow "..tostring(playerid))
        end
    else -- если нажата вторая кнопка (Закрыть)
    end
end

local result, button, list, input = sampHasDialogRespond(15) -- /dialog3 (ListBox)
if result then -- если диалог открыт
    if button == 1 then -- если нажата первая кнопка (Выбрать)
        if list == 0 then -- Продать авто
            cmd_dialog(6)
        elseif list == 1 then -- Передать
        elseif list == 2 then -- Подарить цветы
        elseif list == 3 then -- Жениться на
        elseif list == 4 then -- Предложить побег
        elseif list == 5 then -- Поселить к себе
        end
    else -- если нажата вторая кнопка (Закрыть)
    end
end


local result, button, list, input = sampHasDialogRespond(16) -- /dialog1 (InputBox)
if result then -- если диалог открыт
    if button == 1 then -- если нажата первая кнопка (Выбрать)
        if list == 0 then
            sampSendChat("/sellmycar "..tostring(playerid).." "..input)
        end
    end
end


local result, button, list, input = sampHasDialogRespond(17) -- /dialog1 (InputBox)
if result then -- если диалог открыт
    if button == 1 then -- если нажата первая кнопка (Выбрать)
        if list == 0 then
            sampSendChat("/sellmyhome "..tostring(playerid).." "..input)
            end
        end
    end
end

function cmd_dialog(arg)
    if tonumber(arg) == 1 then
        sampShowDialog(11, "{00ff00}Дать денег", "", "Дать", "Не дать", 1)
    elseif tonumber(arg) == 2 then
        sampShowDialog(12, "{00ff00}Меню взаимодействия с игроком", dialogStr, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 3 then
        sampShowDialog(13, "{00ff00}Показать документы", dialogStra, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 4 then
        sampShowDialog(14, "{00ff00}Действия", dialogStras, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 5 then
        sampShowDialog(15, "{00ff00}Имущество", dialogStrasa, "Выбрать", "Закрыть", 2)
    elseif tonumber(arg) == 6 then
        sampShowDialog(16, "{00ff00}Продать авто", "Введите цену машины.", "Выбрать", "Закрыть", 1)  
    elseif tonumber(arg) == 7 then
        sampShowDialog(17, "{00ff00}Продать дом", "Введите цену дома.", "Выбрать", "Закрыть", 1)  
        end
    end
Начни использовать https://www.blast.hk/threads/13380/page-2#post-160343, будет проще
 
  • Нравится
Реакции: abnomegd

MAHEKEH

Известный
1,989
494
как использовать XOR в луа? ( cleo - 0B12: 1@ = 1@ XOR 1 )
Точнее сказать переключать переменную с 0 на 1 и обратно

так же интересует как прибавлять, убавлять и сравнивать значения в переменных
например то же хп в клео
if or
0@ == 100 (( в переменную ноль условно записано хп актера ))
0@ >= 100

так же интересует как провернуть такую штуку
....
1@ += 1 (( к переменной 1 прибавляется 1 ))
if 1@ == 500 (( если 1 переменная равна 500 ))
then 1@ = 0 (( тогда устанавливает на неё 0 ))
 

Rain_Darkness

Участник
249
14
Как создается свечение на земле от амулета на арз?
Посмотреть вложение 113171
Посмотреть вложение 113172
Я нашел!!!! создает его вроде как silent patch а хранится он в particle под названиeм shad_exp

coronaringb.png
shad_exp.png
вооооот уададададдад

ап, помогите ему кто нибудь...
чекни я помог
 
  • Bug
Реакции: rvng

rvng

не вернусь назад
Модератор
10,769
5,987

madrasso

Потрачен
883
324
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
как использовать XOR в луа? ( cleo - 0B12: 1@ = 1@ XOR 1 )
Точнее сказать переключать переменную с 0 на 1 и обратно

так же интересует как прибавлять, убавлять и сравнивать значения в переменных
например то же хп в клео
if or
0@ == 100 (( в переменную ноль условно записано хп актера ))
0@ >= 100

так же интересует как провернуть такую штуку
....
1@ += 1 (( к переменной 1 прибавляется 1 ))
if 1@ == 500 (( если 1 переменная равна 500 ))
then 1@ = 0 (( тогда устанавливает на неё 0 ))

Lua:
-- 1@ = 1@ XOR 1
one = one or 1;


-- if or
-- 0@ == 100
-- 0@ >= 100
local hp = 99;
if (hp == 100 or hp >= 100) then
    -- если условие выполнено
end


-- 1@ += 1
one = one + one;


-- if 1@ == 500
-- then1@ = 0
if (one == 500) then
    one = 0;
end
 
  • Нравится
Реакции: MAHEKEH

MAHEKEH

Известный
1,989
494
Lua:
-- 1@ = 1@ XOR 1
one = one or 1;


-- if or
-- 0@ == 100
-- 0@ >= 100
local hp = 99;
if (hp == 100 or hp >= 100) then
    -- если условие выполнено
end


-- 1@ += 1
one = one + one;


-- if 1@ == 500
-- then1@ = 0
if (one == 500) then
    one = 0;
end

хз пробовал не вышло, в целом функция же не меняется, ладно, видимо где то проглядел.
Не знаешь как использовать gosub в луа?

//1@ = 1@ XOR 1
--one = one or 1

этот вариант чет не работает, на нуле стоит
 
Последнее редактирование:

Akionka

akionka.lua
Проверенный
742
500
хз пробовал не вышло, в целом функция же не меняется, ладно, видимо где то проглядел.
Не знаешь как использовать gosub в луа?

//1@ = 1@ XOR 1
--one = one or 1

этот вариант чет не работает, на нуле стоит
local variable = false
-- далее по коду
variable = not variable -- переключает булево значение между true и false
 

MAHEKEH

Известный
1,989
494
local variable = false
-- далее по коду
variable = not variable -- переключает булево значение между true и false
я долго думал
и ничего не понял)

мне нужно переключать значение командой

sampRegisterChatCommand("hi", MAHEKEH)


function MAHEKEH(arg)
null = null or 1 -- xor
if null == 1 then sampAddChatMessage("BLASTHACK " ..Passed , 0xFF0000) else sampAddChatMessage("BLASTHACK " ..not passed , 0xFF0000)
end
end
end

или

if null == 1 then ... passed
if null == 0 then ... not passed
без else то есть

что то там такое должно было быть..