Вопросы по 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
 
Последнее редактирование:

AnWu

Guardian of Order
Всефорумный модератор
4,688
5,186
Кто-то хотяб приблизительно знает как устроен плагин, который прокладывает маршруты на миникарте? Любая информация будет полезна. Может есть какой-то пул с их коордами и тд.
у слонобойки в гитхабе вроде gps был

то есть формат не правильный.
 

no3jour

Участник
55
0
Хотел сделать два окна imgui но не вышло ничего, гайд не помог
PHP:
script_name("FpsControl")
script_author("no3jour")
script_description("Command")
script_version('0.1')

requests = require('requests')
require "lib.moonloader"
local imgui = require 'imgui'
local cfg = require("inicfg")
local hook = require("lib.samp.events")
local key = require 'vkeys'
local encoding = require 'encoding' -- загружаем библиотеку
encoding.default = 'CP1251' -- указываем кодировку по умолчанию, она должна совпадать с кодировкой файла. CP1251 - это Windows-1251
u8 = encoding.UTF8 -- и создаём короткий псевдоним для кодировщика UTF-8

local test_text_buffer = imgui.ImBuffer(256)
local other = {
    color = 'ffff00'
}
local mainWindow = imgui.ImBool()
local extraWindow = imgui.ImBool()
local buf = imgui.ImBuffer(2056)

local INFO = {
    nil,
    nil,
    nil,
    nil,
    nil,
    nil
}

local other1 = {
    color = 'ffffff'
}
local other2 = {
    color = 'ff4500'
}
local function commandsReg()
---------------------------------- help ----------------
    sampRegisterChatCommand("phelp", cmd_help)
    sampRegisterChatCommand("dedit", dialogeditor)
--------------------------------------------- [SMS] -----------------------
    sampRegisterChatCommand("pstext", cmd_pstext)
    sampRegisterChatCommand("pstext2", cmd_pstext2)
    sampRegisterChatCommand("psnick", cmd_psnick)
    -----------------------------------[CHAT]-------------------------------------
    sampRegisterChatCommand("pctext", cmd_pctext)
    sampRegisterChatCommand("pctext2", cmd_pctext2)
    sampRegisterChatCommand("pcnick", cmd_pcnick)
    -----------------------------------[A-CHAT]-------------------------------------
    sampRegisterChatCommand("patext", cmd_patext)
    sampRegisterChatCommand("patext2", cmd_patext2)
    sampRegisterChatCommand("panick", cmd_panick)
    sampRegisterChatCommand("pref", cmd_pref)
    -----------------------------------[report]-------------------------------------
    sampRegisterChatCommand("prtext", cmd_prtext)
    sampRegisterChatCommand("prnick", cmd_prnick)
    sampRegisterChatCommand("pc", cmd_clear)
    ------------------------------------[FAKE BAN] ---------------------------------
    sampRegisterChatCommand("pban", cmd_prnick)
    sampRegisterChatCommand("pbnick", cmd_pbnick)
    sampRegisterChatCommand("pbtext", cmd_pbtext)
end

local script_patch_config = 'podstava'
local scriptConfig = cfg.load({
    inputs = {
        pstext = '';
        pstext2 = '';
        psnick = '';
        pctext = '';
        pctext2 = '';
        patext = '';
        pcnick = '';
        patext2 = '';
        panick = '';
        pref = '';
        prtext = '';
        prnick = '';
        pbtext = '';
        pbnick = '';
        cmd = '';
        pban = '';
    }
}, script_patch_config)


local pstext = imgui.ImBuffer(''..scriptConfig.inputs.pstext, 256)
local pstext2 = imgui.ImBuffer(''..scriptConfig.inputs.pstext2, 256)
local psnick = imgui.ImBuffer(''..scriptConfig.inputs.psnick, 256)
local pctext = imgui.ImBuffer(''..scriptConfig.inputs.pctext, 256)
local pctext2 = imgui.ImBuffer(''..scriptConfig.inputs.pctext2, 256)
local pcnick = imgui.ImBuffer(''..scriptConfig.inputs.pcnick, 256)
local patext = imgui.ImBuffer(''..scriptConfig.inputs.patext, 256)
local patext2 = imgui.ImBuffer(''..scriptConfig.inputs.patext2, 256)
local panick = imgui.ImBuffer(''..scriptConfig.inputs.panick, 256)
local pref = imgui.ImBuffer(''..scriptConfig.inputs.pref, 256)
local prtext = imgui.ImBuffer(''..scriptConfig.inputs.prtext, 256)
local prnick = imgui.ImBuffer(''..scriptConfig.inputs.prnick, 256)
local pbtext = imgui.ImBuffer(''..scriptConfig.inputs.pbtext, 256)
local pbnick = imgui.ImBuffer(''..scriptConfig.inputs.pbnick, 256)
local pban = imgui.ImBuffer(''..scriptConfig.inputs.pban, 256) --

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

    while not sampIsLocalPlayerSpawned() do wait(100) end
    while true do
        wait(0)
        if wasKeyPressed(VK_Z) then mainWindow.v = not mainWindow.v end
        if wasKeyPressed(VK_X) then extraWindow.v = not extraWindow.v end
        if wasKeyPressed(VK_NUMPAD3) then
           cmd_blat()
        end
        if wasKeyPressed(VK_NUMPAD5) then
           cmd_chat()
        end
        if wasKeyPressed(VK_NUMPAD8) then
           cmd_apodstava()
        end
        if wasKeyPressed(VK_NUMPAD9) then
           cmd_report()
        end
        if wasKeyPressed(VK_N) and wasKeyPressed(VK_M) then
           cmd_fakeban()
        end
        if wasKeyPressed(key.VK_X) then -- активация по нажатию клавиши X
        end                  
    end
end

-- a,b,c,d,e,f
function hook.onShowDialog(dialogId, style, title, button1, button2, text)
    INFO[1] = dialogId; INFO[3] = title; INFO[5] = button2;
    INFO[2] = style; INFO[4] = button1; INFO[6] = text
    buf.v = u8(text)
end

addEventHandler("onWindowMessage",
function(msg, p1, p2)
    if p1 == 13 and main_gui.v then
        consumeWindowMessage(true, false)
    end
end)

function dialogeditor()
    if not  main_gui.v then
        if sampIsDialogActive() then
            main_gui.v = true
        else
            sampAddChatMessage("Нету активных окон", -1)
        end
    else
        main_gui.v = false
    end
end

local function TextColoredRGB(text)
    local style = imgui.GetStyle()
    local colors = style.Colors
    local ImVec4 = imgui.ImVec4

    local explode_argb = function(argb)
        local a = bit.band(bit.rshift(argb, 24), 0xFF)
        local r = bit.band(bit.rshift(argb, 16), 0xFF)
        local g = bit.band(bit.rshift(argb, 8), 0xFF)
        local b = bit.band(argb, 0xFF)
        return a, r, g, b
    end

    local getcolor = function(color)
        if color:sub(1, 6):upper() == 'SSSSSS' then
            local r, g, b = colors[1].x, colors[1].y, colors[1].z
            local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
            return ImVec4(r, g, b, a / 255)
        end
        local color = type(color) == 'string' and tonumber(color, 16) or color
        if type(color) ~= 'number' then return end
        local r, g, b, a = explode_argb(color)
        return imgui.ImColor(r, g, b, a):GetVec4()
    end

    local render_text = function(text_)
        for w in text_:gmatch('[^\r\n]+') do
            local text, colors_, m = {}, {}, 1
            w = w:gsub('{(......)}', '{%1FF}')
            while w:find('{........}') do
                local n, k = w:find('{........}')
                local color = getcolor(w:sub(n + 1, k - 1))
                if color then
                    text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
                    colors_[#colors_ + 1] = color
                    m = n
                end
                w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
            end
            if text[0] then
                for i = 0, #text do
                    imgui.TextColored(colors_[i] or colors[1], u8(text[i]))
                    imgui.SameLine(nil, 0)
                end
                imgui.NewLine()
            else imgui.Text(u8(w)) end
        end
    end

    render_text(text)
end


local commands = [[
    {ffff00}-----------[SMS]-----------
    {ffff00}/psnick - {FFFFFF}указать ник для подставы SMS
    {ffff00}/pstext - {FFFFFF}текст для подставы SMS 1
    {ffff00}/pstext2 - {FFFFFF}текст для подставы SMS 2
    {ffff00}Num3 - {FFFFFF}для вывода смс
    {ffffff}-----------[CHAT]-----------
    {ffffff}/pcnick - {FFFFFF}указать ник для подставы Chat
    {ffffff}/pctext - {FFFFFF}текст для подставы Chat 1
    {ffffff}/pctext2 - {FFFFFF}текст для подставы Chat 2
    {ffffff}Num5 - {FFFFFF}для вывода чат
    {ff0000}-----------[A-CHAT]-----------
    {ff0000}/pref - {FFFFFF}цвет и префкс пример [FF0000](Основатель),(скобки изогнутые)
    {ff0000}/panick - {FFFFFF}указать ник для подставы Admin
    {ff0000}/patext - {FFFFFF}текст для подставы Admin
    {ff0000}Num8 - {FFFFFF}для вывода а-чат
    {ff0000}-----------[report]-----------
    {ffff00}/prnick - {FFFFFF}указать ник для подставы report
    {ffff00}/prtext - {FFFFFF}текст для подставы report
    {ffff00}Num9 - {FFFFFF}для вывода репорта
    {ffff00}/pc - {FFFFFF}очистить чат
    {ff0000}-----------[FAKEBAN]-----------
    {ffff00}/pbnick - {FFFFFF}Ник и ид администратора и жервы(указывать через пробел)(второй ник без id)
    {ffff00}/pbtext - {FFFFFF}причина бана')
    {ffff00}N+M - {FFFFFF}для вывода блокировки
]]


function imgui.OnDrawFrame()
    if mainWindow.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver)
        imgui.Begin(u8"Author: babulya   |   Идея KirikRus299", mainWindow.v, imgui.WindowFlags.NoCollapse)
        if imgui.InputTextMultiline(u8'', buf, imgui.ImVec2(485, 460)) then
            sampShowDialog(INFO[1],INFO[3],u8:decode(buf.v),INFO[4],INFO[5],INFO[2])
            sampSetDialogClientside(false)
        end
        imgui.End()
    end
    if extraWindow.v then
    local btnSize = imgui.ImVec2(120, 0)
   -- imgui.SetNextWindowSize(imgui.ImVec2(600, 700))
    imgui.Begin(u8'Панель подставы', extraWindow.v, imgui.WindowFlags.AlwaysAutoResize)
    if imgui.Button(u8'Команды', btnSize) then selected = 1 end; imgui.SameLine()
    if imgui.Button(u8'Настройки', btnSize) then selected = 2 end; imgui.SameLine()
    if imgui.Button(u8'Результат', btnSize) then selected = 3 end;
    imgui.Separator()
    if selected == 1 then
        TextColoredRGB(commands)
    elseif selected == 2 then
        if imgui.InputText(u8'Выбираем фракцию', pctext, imgui.ImVec2(200, 0)) then end
    end
    imgui.End()
    end
end
--------------------------------------- SMS ----------------------------
function cmd_blat(arg)
    sampAddChatMessage("{ffff00}Входящее: "..pstext.." Отправитель: "..psnick.."", (type and '0x'..other.color or 0xf50575))
    wait(7000)
    sampAddChatMessage("{ffff00}Входящее: "..pstext2.." Отправитель: "..psnick.."", (type and '0x'..other.color or 0xf50575))
end

function cmd_psnick(arg)
    sampAddChatMessage('{ffffff}Пример ника для подставы: Stas_Belkin[23]', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}Ник и ид для подставы: {ffff00}'..arg..'.', (type and '0x'..other1.color or 0xf50575))
    psnick = arg
end

function cmd_pstext(arg)
    sampAddChatMessage('{ffffff}Текст для подставы: {ff0000}'..arg..'. {ffff00}Обязательно введите ТЕКСТ 2 /pstext2', (type and '0x'..other.color or 0xf50575))
    pstext = arg
end

function cmd_pstext2(arg)
    sampAddChatMessage('{ffffff}Текст для подставы: {ff0000}'..arg..'. {ffff00}Обязательно введите ТЕКСТ 1 /pstext', (type and '0x'..other.color or 0xf50575))
    pstext2 = arg
end
--------------------------------------------- CHAT ------------------------------------
function cmd_chat(arg)
    sampAddChatMessage("{FFFFFF}- "..pctext.." "..pcnick.."", (type and '0x'..other1.color or 0xf50575))
    wait(6000)
    sampAddChatMessage("{FFFFFF}- "..pctext2.." "..pcnick.."", (type and '0x'..other1.color or 0xf50575))
end

function cmd_pcnick(arg)
    sampAddChatMessage('{ffffff}Пример ника для подставы: (Stas_Belkin)[23]', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}Ник и ид для подставы: {ffff00}'..arg..'.', (type and '0x'..other1.color or 0xf50575))
    pcnick = arg
end
function cmd_clear(arg)
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}   ', (type and '0x'..other1.color or 0xf50575))
end


function cmd_pctext(arg)
    sampAddChatMessage('{ffffff}Текст для подставы: {ff0000}'..arg..'. {ffff00}Обязательно введите ТЕКСТ 2 /pctext2', (type and '0x'..other.color or 0xf50575))
    pctext = arg
end

function cmd_pctext2(arg)
    sampAddChatMessage('{ffffff}Текст для подставы: {ff0000}'..arg..'. {ffff00}Обязательно введите ТЕКСТ 1 /pctext', (type and '0x'..other.color or 0xf50575))
    pctext2 = arg
end

------------------------------------------------ A-CHAT -------------------------------------------------------s
function cmd_panick(arg)
    sampAddChatMessage('{ffffff}Пример ника для подставы: Stas_Belkin[23]', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}Ник и ид для подставы: {ffff00}'..arg..'.', (type and '0x'..other1.color or 0xf50575))
    panick = arg
end

function cmd_patext(arg)
    sampAddChatMessage('{ffffff}Текст для подставы: {ff0000}'..arg..'. {ffff00}', (type and '0x'..other.color or 0xf50575))
    patext = arg
end
function cmd_apodstava(arg)
    sampAddChatMessage("{ffffff}"..pref.."{FFFFFF} "..panick..": "..patext.."", (type and '0x'..other1.color or 0xf50575))
end
function cmd_pref(arg)
    sampAddChatMessage('{ffffff}Префикс для подставы: {ff0000}'..arg..'. {ffff00}Пример: [FF0000]{FF0000}(Основатель),{ffff00}(скобки изогнутые)', (type and '0x'..other.color or 0xf50575))
    pref = arg
end
---------------------------------------------- REPORT -------------------------------------------------------
function cmd_report(arg)
    sampAddChatMessage("{ff4500}[/arep] "..prnick..": {ffd700}"..prtext.."", (type and '0x'..other2.color or 0xf50575))
end

function cmd_prnick(arg)
    sampAddChatMessage('{ffffff}Пример ника для подставы: (Stas_Belkin)[23]', (type and '0x'..other1.color or 0xf50575))
    sampAddChatMessage('{ffffff}Ник и ид для подставы: {ffff00}'..arg..'.', (type and '0x'..other1.color or 0xf50575))
    prnick = arg
end

function cmd_prtext(arg)
    sampAddChatMessage('{ffffff}Текст для подставы: {ff0000}'..arg..'. {ffff00}Обязательно введите ТЕКСТ 2 /pctext2', (type and '0x'..other.color or 0xf50575))
    prtext = arg
end

------------------------------------------------------- [FAKE BAN] ---------------------------------------------------------------------
function cmd_fakeban(arg)
    sampAddChatMessage("{ff5030}Администратор "..pbnick1.." заблокировал "..pbnick2.." на 14 дней. Причина: "..pbtext.."", (type and '0x'..other2.color or 0xf50575))
end

function cmd_pbnick(arg)
    var1, var2 = string.match(arg, "(.+) (.+)")
    if var1 == nil or var1 == "" then
        sampAddChatMessage('{ffffff}Введите два параметра пример: /pbnick John_Barrison[12] Dwayne_Joker', (type and '0x'..other1.color or 0xf50575))
    else
        sampAddChatMessage('{ffffff}Ник администратора {ffff00}'..var1..'.', (type and '0x'..other1.color or 0xf50575))
        sampAddChatMessage('{ffffff}Ник игрока {ffff00}'..var2..'.', (type and '0x'..other1.color or 0xf50575))
        pbnick1 = var1
        pbnick2 = var2
    end
end

function cmd_pbtext(arg)
    sampAddChatMessage('{ffffff}Текст для подставы бана: {ff0000}'..arg..'. {ffff00}Обязательно введите ТЕКСТ 2 /pctext2', (type and '0x'..other.color or 0xf50575))
    pbtext = arg
end
--------------------------------------------------- HELP -----------------------------------------------------
function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    local ImVec2 = imgui.ImVec2

    colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
    colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.40)
    colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 0.40)
    colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
    colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
    colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
    colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
    colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
    colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
    colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
    colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
    colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
    colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
    colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
    colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
    colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
end
apply_custom_style()
-------------------------------------------------------- END ----------------------------------------------------------------------
 

[SA ARZ]

Известный
390
8

в чём тут проблема?

code:
local gos1              = imgui.ImBuffer(u8(settings.gnews.gos1),256)
local gos2              = imgui.ImBuffer(u8(settings.gnews.gos2),256)
local gos3              = imgui.ImBuffer(u8(settings.gnews.gos3),256)
local gos4              = imgui.ImBuffer(u8(settings.gnews.gos4),256)
local gos5              = imgui.ImBuffer(u8(settings.gnews.gos5),256)
local ActionGos1        = imgui.ImBuffer(u8(settings.gnews.ActionGos1),256)
local ActionGos2        = imgui.ImBuffer(u8(settings.gnews.ActionGos2),256)
local ActionGos3        = imgui.ImBuffer(u8(settings.gnews.ActionGos3),256)
local ActionGos4        = imgui.ImBuffer(u8(settings.gnews.ActionGos4),256)
local ActionGos5        = imgui.ImBuffer(u8(settings.gnews.ActionGos5),256)
local MyGos1            = imgui.ImBuffer(u8(settings.gnews.MyGos1),256)
local MyGos2            = imgui.ImBuffer(u8(settings.gnews.MyGos2),256)
local MyGos3            = imgui.ImBuffer(u8(settings.gnews.MyGos3),256)
local MyGos4            = imgui.ImBuffer(u8(settings.gnews.MyGos4),256)
local MyGos5            = imgui.ImBuffer(u8(settings.gnews.MyGos5),256)
local MyGos6            = imgui.ImBuffer(u8(settings.gnews.MyGos6),256)
local MyGos7            = imgui.ImBuffer(u8(settings.gnews.MyGos7),256)
local MyGos8            = imgui.ImBuffer(u8(settings.gnews.MyGos8),256)
local MyGos9            = imgui.ImBuffer(u8(settings.gnews.MyGos9),256)
local MyGos10           = imgui.ImBuffer(u8(settings.gnews.MyGos10),256)
local MyGos11           = imgui.ImBuffer(u8(settings.gnews.MyGos11),256)
local MyGos12           = imgui.ImBuffer(u8(settings.gnews.MyGos12),256)
local MyGos13           = imgui.ImBuffer(u8(settings.gnews.MyGos13),256)
local MyGos14           = imgui.ImBuffer(u8(settings.gnews.MyGos14),256)
local MyGos15           = imgui.ImBuffer(u8(settings.gnews.MyGos15),256)
local gnewstag          = imgui.ImBuffer(u8(settings.gnews.gnewstag),256)
local mtag              = imgui.ImBuffer(u8(settings.options.mtag),256)
local timefix           = imgui.ImInt(settings.options.timefix)
local soundSMS          = imgui.ImInt(settings.options.soundSMS)
local comboStyle        = imgui.ImInt(settings.options.iStyle)
local phoneModel        = imgui.ImBuffer(u8(settings.options.phoneModel),256)
local actionmoney       = imgui.ImBuffer(u8(settings.gnews.actionmoney),256)
local googlekeyText     = imgui.ImBuffer(u8(settings.options.googlekeyText), 256)
local AutoPassText      = imgui.ImBuffer(u8(settings.options.AutoPassText), 256)
local clocktext         = imgui.ImBuffer(u8(settings.options.clocktext), 256)
local priceNotFrac      = imgui.ImBuffer(u8(settings.options.priceNotFrac), 10)
local priceSex          = imgui.ImBuffer(u8(settings.options.priceSex), 10)
local priceOper1        = imgui.ImBuffer(u8(settings.options.priceOper1), 10)
local priceOper2        = imgui.ImBuffer(u8(settings.options.priceOper2), 10)
local priceOper3        = imgui.ImBuffer(u8(settings.options.priceOper3), 10)
local priceOper4        = imgui.ImBuffer(u8(settings.options.priceOper4), 10)
local priceVagos        = imgui.ImBuffer(u8(settings.options.priceVagos), 10)
local priceBallas       = imgui.ImBuffer(u8(settings.options.priceBallas), 10)
local priceRifa         = imgui.ImBuffer(u8(settings.options.priceRifa), 10)
local priceActek        = imgui.ImBuffer(u8(settings.options.priceActek), 10)
local priceGroove       = imgui.ImBuffer(u8(settings.options.priceGroove), 10)
local priceRM           = imgui.ImBuffer(u8(settings.options.priceRM), 10)
local priceLCN          = imgui.ImBuffer(u8(settings.options.priceLCN), 10)
local priceYak          = imgui.ImBuffer(u8(settings.options.priceYak), 10)
local priceGOV          = imgui.ImBuffer(u8(settings.options.priceGOV), 10)
local priceMZ           = imgui.ImBuffer(u8(settings.options.priceMZ), 10)
local priceMVD          = imgui.ImBuffer(u8(settings.options.priceMVD), 10)
local priceMO           = imgui.ImBuffer(u8(settings.options.priceMO), 10)
local priceMM           = imgui.ImBuffer(u8(settings.options.priceMM), 10)
local MedicCols         = imgui.ImBuffer(u8(settings.options.MedicCols), 10)
local OperCols          = imgui.ImBuffer(u8(settings.options.OperCols), 10)
local arrayFunc = {
    AutoFindRP        = imgui.ImBool(settings.options.enableFind),
    AutoGoogle        = imgui.ImBool(settings.options.AutoGoogle),
    ChatInfo          = imgui.ImBool(settings.options.ChatInfo),
    AutoPass          = imgui.ImBool(settings.options.AutoPass),
    fastbuy           = imgui.ImBool(settings.options.fastbuy),
    funcClock         = imgui.ImBool(settings.options.funcClock),
    infobar           = imgui.ImBool(settings.options.infobar),
    welcomeScript     = imgui.ImBool(settings.options.welcomeScript),
    infCity           = imgui.ImBool(settings.options.infCity),
    infTime           = imgui.ImBool(settings.options.infTime),
    infKv             = imgui.ImBool(settings.options.infKv),
    infRajon          = imgui.ImBool(settings.options.infRajon),
    infHP             = imgui.ImBool(settings.options.infHP),
    infHideNick       = imgui.ImBool(settings.options.infHideNick),
    doSMS             = imgui.ImBool(settings.options.doSMS),
    doClock           = imgui.ImBool(settings.options.doClock),
    smssound          = imgui.ImBool(settings.options.smssound),
    AutoCalls         = imgui.ImBool(settings.options.AutoCalls),
    casinoBlock       = imgui.ImBool(settings.options.casinoBlock),
    HideAdbyCMN       = imgui.ImBool(settings.options.HideAdbyCMN),
    HideReclame       = imgui.ImBool(settings.options.HideReclame),
    AudioCalls        = imgui.ImBool(settings.options.AudioCalls),
    AutoAD            = imgui.ImBool(settings.options.AutoAD),
    AutoADUP          = imgui.ImBool(settings.options.AutoADUP),
    ConfrimFunc       = imgui.ImBool(settings.options.ConfrimFunc),
    systemMedHelp     = imgui.ImBool(settings.options.systemMedHelp),
    newHudSAMP        = imgui.ImBool(settings.options.newHudSAMP),
    marker            = imgui.ImBool(settings.options.marker)
}
local textAdv           = imgui.ImBuffer(u8(settings.options.textAdv), 255)
local MedPassword       = imgui.ImBuffer(256)
local RPMedHelper       = imgui.ImBuffer(65536)
local RPGGtext          = imgui.ImBuffer(65536)
local SearchBase2       = imgui.ImBuffer(u8(settings.options.SearchBase2), 256)
local NameBase          = imgui.ImBuffer(u8(settings.options.NameBase), 256)
local ReasonUvalBase    = imgui.ImBuffer(u8(settings.options.ReasonUvalBase), 256)
local logTextSMSIN      = {}
local logTextSMSTO      = {}
local baseVigLogs       = {}
local baseBlackLogs     = {}
local baseVigovorInfo   = {}
local baseRangsAll      = {}
local tLastKeys         = {}
 

Angr

Известный
291
97
в чём тут проблема?

code:
local gos1              = imgui.ImBuffer(u8(settings.gnews.gos1),256)
local gos2              = imgui.ImBuffer(u8(settings.gnews.gos2),256)
local gos3              = imgui.ImBuffer(u8(settings.gnews.gos3),256)
local gos4              = imgui.ImBuffer(u8(settings.gnews.gos4),256)
local gos5              = imgui.ImBuffer(u8(settings.gnews.gos5),256)
local ActionGos1        = imgui.ImBuffer(u8(settings.gnews.ActionGos1),256)
local ActionGos2        = imgui.ImBuffer(u8(settings.gnews.ActionGos2),256)
local ActionGos3        = imgui.ImBuffer(u8(settings.gnews.ActionGos3),256)
local ActionGos4        = imgui.ImBuffer(u8(settings.gnews.ActionGos4),256)
local ActionGos5        = imgui.ImBuffer(u8(settings.gnews.ActionGos5),256)
local MyGos1            = imgui.ImBuffer(u8(settings.gnews.MyGos1),256)
local MyGos2            = imgui.ImBuffer(u8(settings.gnews.MyGos2),256)
local MyGos3            = imgui.ImBuffer(u8(settings.gnews.MyGos3),256)
local MyGos4            = imgui.ImBuffer(u8(settings.gnews.MyGos4),256)
local MyGos5            = imgui.ImBuffer(u8(settings.gnews.MyGos5),256)
local MyGos6            = imgui.ImBuffer(u8(settings.gnews.MyGos6),256)
local MyGos7            = imgui.ImBuffer(u8(settings.gnews.MyGos7),256)
local MyGos8            = imgui.ImBuffer(u8(settings.gnews.MyGos8),256)
local MyGos9            = imgui.ImBuffer(u8(settings.gnews.MyGos9),256)
local MyGos10           = imgui.ImBuffer(u8(settings.gnews.MyGos10),256)
local MyGos11           = imgui.ImBuffer(u8(settings.gnews.MyGos11),256)
local MyGos12           = imgui.ImBuffer(u8(settings.gnews.MyGos12),256)
local MyGos13           = imgui.ImBuffer(u8(settings.gnews.MyGos13),256)
local MyGos14           = imgui.ImBuffer(u8(settings.gnews.MyGos14),256)
local MyGos15           = imgui.ImBuffer(u8(settings.gnews.MyGos15),256)
local gnewstag          = imgui.ImBuffer(u8(settings.gnews.gnewstag),256)
local mtag              = imgui.ImBuffer(u8(settings.options.mtag),256)
local timefix           = imgui.ImInt(settings.options.timefix)
local soundSMS          = imgui.ImInt(settings.options.soundSMS)
local comboStyle        = imgui.ImInt(settings.options.iStyle)
local phoneModel        = imgui.ImBuffer(u8(settings.options.phoneModel),256)
local actionmoney       = imgui.ImBuffer(u8(settings.gnews.actionmoney),256)
local googlekeyText     = imgui.ImBuffer(u8(settings.options.googlekeyText), 256)
local AutoPassText      = imgui.ImBuffer(u8(settings.options.AutoPassText), 256)
local clocktext         = imgui.ImBuffer(u8(settings.options.clocktext), 256)
local priceNotFrac      = imgui.ImBuffer(u8(settings.options.priceNotFrac), 10)
local priceSex          = imgui.ImBuffer(u8(settings.options.priceSex), 10)
local priceOper1        = imgui.ImBuffer(u8(settings.options.priceOper1), 10)
local priceOper2        = imgui.ImBuffer(u8(settings.options.priceOper2), 10)
local priceOper3        = imgui.ImBuffer(u8(settings.options.priceOper3), 10)
local priceOper4        = imgui.ImBuffer(u8(settings.options.priceOper4), 10)
local priceVagos        = imgui.ImBuffer(u8(settings.options.priceVagos), 10)
local priceBallas       = imgui.ImBuffer(u8(settings.options.priceBallas), 10)
local priceRifa         = imgui.ImBuffer(u8(settings.options.priceRifa), 10)
local priceActek        = imgui.ImBuffer(u8(settings.options.priceActek), 10)
local priceGroove       = imgui.ImBuffer(u8(settings.options.priceGroove), 10)
local priceRM           = imgui.ImBuffer(u8(settings.options.priceRM), 10)
local priceLCN          = imgui.ImBuffer(u8(settings.options.priceLCN), 10)
local priceYak          = imgui.ImBuffer(u8(settings.options.priceYak), 10)
local priceGOV          = imgui.ImBuffer(u8(settings.options.priceGOV), 10)
local priceMZ           = imgui.ImBuffer(u8(settings.options.priceMZ), 10)
local priceMVD          = imgui.ImBuffer(u8(settings.options.priceMVD), 10)
local priceMO           = imgui.ImBuffer(u8(settings.options.priceMO), 10)
local priceMM           = imgui.ImBuffer(u8(settings.options.priceMM), 10)
local MedicCols         = imgui.ImBuffer(u8(settings.options.MedicCols), 10)
local OperCols          = imgui.ImBuffer(u8(settings.options.OperCols), 10)
local arrayFunc = {
    AutoFindRP        = imgui.ImBool(settings.options.enableFind),
    AutoGoogle        = imgui.ImBool(settings.options.AutoGoogle),
    ChatInfo          = imgui.ImBool(settings.options.ChatInfo),
    AutoPass          = imgui.ImBool(settings.options.AutoPass),
    fastbuy           = imgui.ImBool(settings.options.fastbuy),
    funcClock         = imgui.ImBool(settings.options.funcClock),
    infobar           = imgui.ImBool(settings.options.infobar),
    welcomeScript     = imgui.ImBool(settings.options.welcomeScript),
    infCity           = imgui.ImBool(settings.options.infCity),
    infTime           = imgui.ImBool(settings.options.infTime),
    infKv             = imgui.ImBool(settings.options.infKv),
    infRajon          = imgui.ImBool(settings.options.infRajon),
    infHP             = imgui.ImBool(settings.options.infHP),
    infHideNick       = imgui.ImBool(settings.options.infHideNick),
    doSMS             = imgui.ImBool(settings.options.doSMS),
    doClock           = imgui.ImBool(settings.options.doClock),
    smssound          = imgui.ImBool(settings.options.smssound),
    AutoCalls         = imgui.ImBool(settings.options.AutoCalls),
    casinoBlock       = imgui.ImBool(settings.options.casinoBlock),
    HideAdbyCMN       = imgui.ImBool(settings.options.HideAdbyCMN),
    HideReclame       = imgui.ImBool(settings.options.HideReclame),
    AudioCalls        = imgui.ImBool(settings.options.AudioCalls),
    AutoAD            = imgui.ImBool(settings.options.AutoAD),
    AutoADUP          = imgui.ImBool(settings.options.AutoADUP),
    ConfrimFunc       = imgui.ImBool(settings.options.ConfrimFunc),
    systemMedHelp     = imgui.ImBool(settings.options.systemMedHelp),
    newHudSAMP        = imgui.ImBool(settings.options.newHudSAMP),
    marker            = imgui.ImBool(settings.options.marker)
}
local textAdv           = imgui.ImBuffer(u8(settings.options.textAdv), 255)
local MedPassword       = imgui.ImBuffer(256)
local RPMedHelper       = imgui.ImBuffer(65536)
local RPGGtext          = imgui.ImBuffer(65536)
local SearchBase2       = imgui.ImBuffer(u8(settings.options.SearchBase2), 256)
local NameBase          = imgui.ImBuffer(u8(settings.options.NameBase), 256)
local ReasonUvalBase    = imgui.ImBuffer(u8(settings.options.ReasonUvalBase), 256)
local logTextSMSIN      = {}
local logTextSMSTO      = {}
local baseVigLogs       = {}
local baseBlackLogs     = {}
local baseVigovorInfo   = {}
local baseRangsAll      = {}
local tLastKeys         = {}
В твоем вопросе, где у тебя работа с json идет.. скинь
 

Vespan

loneliness
Проверенный
2,105
1,633
Почему не работает
Lua:
function sampev.onServerMessage(color, text)
    if string.find(text, 'АФК') then
        local str = 'Вы стояли в АФК: 01:28'
        local time = str:match('Вы стояли в АФК: (.+)')
        sampAddChatMessage('AFK:'..time, -1)
    end
end
43773
 

Raymond

Известный
206
86
Почему не работает
Lua:
function sampev.onServerMessage(color, text)
    if string.find(text, 'АФК') then
        local str = 'Вы стояли в АФК: 01:28'
        local time = str:match('Вы стояли в АФК: (.+)')
        sampAddChatMessage('AFK:'..time, -1)
    end
end
Посмотреть вложение 43773
Lua:
function sampev.onServerMessage(color, text)
    if text:find('АФК') then
        local time = text:match('Вы стояли в АФК: (.+)')
        sampAddChatMessage('AFK:'..time, -1)
    end
end
 

Warflex

Участник
158
17
Lua:
function number()
  if text:find('Номер') then
    local number = text:match(".+%:%s+(%d+)")
    sampAddChatMessage('Номер'..number, -1)
end
end
Хелп есть предложение Номер Koloshek_Koloshek: 123123 так же может быть разные 6 или 5 цифр
мне в чат вывести надо вывести 123123 или допустим 12345 ну вобщем разные цифры могут быть

хелп плиз
 

trefa

Известный
Всефорумный модератор
2,097
1,231
Почему не работает
Lua:
function sampev.onServerMessage(color, text)
    if string.find(text, 'АФК') then
        local str = 'Вы стояли в АФК: 01:28'
        local time = str:match('Вы стояли в АФК: (.+)')
        sampAddChatMessage('AFK:'..time, -1)
    end
end
Посмотреть вложение 43781
Не работает потому что у тебя нет мозгов, ты проверяешь переменную которая не изменяется и ты спрашиваешь "а почему не работает".
 
  • Ха-ха
Реакции: AnWu и factor_cheater

Joni Scripts

Известный
535
374
Что делать?
Если было 99к, и сравниваю с числом 101к, то пишет что ошибка, т.е. 101к меньше 99к, это происходит из-за +1 символа к числу
if min < money then
 

trefa

Известный
Всефорумный модератор
2,097
1,231
Что делать?
Если было 99к, и сравниваю с числом 101к, то пишет что ошибка, т.е. 101к меньше 99к, это происходит из-за +1 символа к числу
if min < money then
мб лог скинешь, может ты сравниваешь вообще разные типы переменные.
 
  • Нравится
Реакции: Joni Scripts