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

yeahbitch

Потрачен
28
5
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Привет всем, проблема с inicfg. Вылетает ошибка attempt to index local 'ini' (a nil value). Код:
code:
script_name('Imgui Script Icons') -- название скрипта
script_author('FORMYS') -- автор скрипта
script_description('Imgui') -- описание скрипта

require "lib.moonloader" -- подключение библиотеки
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
local sampev   = require 'lib.samp.events'
local inicfg   = require 'inicfg'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local directIni = "PrisonHelper\\PrHelper.ini"

local ini = inicfg.load(def, directIni)

local vkladki = {
    false,
        false,
        false,
        false,
}

local def = {
    settings = {
        vkladka = 1
}}

vkladki[ini.settings.vkladka] = true

local fa = require 'faIcons'
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })

main_window_state = imgui.ImBool(false)
arrSelectable = {false, false}

function imgui.BeforeDrawFrame()
    if fa_font == nil then
        local font_config = imgui.ImFontConfig() -- to use 'imgui.ImFontConfig.new()' on error
        font_config.MergeMode = true
        fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fontawesome-webfont.ttf', 14.0, font_config, fa_glyph_ranges)
    end
end


function imgui.TextColoredRGB(text, render_text)
    local max_float = imgui.GetWindowWidth()
    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

            local length = imgui.CalcTextSize(w)
            if render_text == 2 then
                imgui.NewLine()
                imgui.SameLine(max_float / 2 - ( length.x / 2 ))
            elseif render_text == 3 then
                imgui.NewLine()
                imgui.SameLine(max_float - length.x - 5 )
            end
            if text[0] then
                for i = 0, #text do
                    imgui.TextColored(colors_[i] or colors[1], text[i])
                    imgui.SameLine(nil, 0)
                end
                imgui.NewLine()
            else imgui.Text(w) end


        end
    end

    render_text(text)
end

function SetStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.ChildWindowRounding = 4.0
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    colors[clr.Button]                 = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.29, 0.48, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 0.50)-- (0.1, 0.9, 0.1, 1.0)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 1.00)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.Header]                 = ImVec4(0.26, 0.59, 0.98, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.52, 0.88, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.59, 0.98, 1.00)
end

SetStyle()

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

    sampRegisterChatCommand("icons", cmd_icons)

    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)

    imgui.Process = false

    while true do
        wait(0)
    end
end

function cmd_icons(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function imgui.OnDrawFrame()

    if not main_window_state.v then
        imgui.Process = false
    end

   if main_window_state.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(600, 300), imgui.Cond.FirstUseEver)

        imgui.Begin('Helper for Prison', main_window_state)

            imgui.BeginChild("ChildButtons", imgui.ImVec2(153, 265), true)
                if imgui.Button(u8"Информация "..fa.ICON_ADDRESS_BOOK_O, imgui.ImVec2(137, 35)) then
                    vkladki[1] = true
                    ini.settings.vkladka = 1
                    inicfg.save(def, directIni)
                end
                if imgui.Button(u8"Биндер "..fa.ICON_FILE_TEXT, imgui.ImVec2(137, 35))then
                    vkladki[2] = true
                    ini.settings.vkladka = 1
                    inicfg.save(def, directIni)
                end
                if imgui.Button(u8"О скрипте "..fa.ICON_USER, imgui.ImVec2(137, 35)) then
                    vkladki[3] = true
                    ini.settings.vkladka = 1
                    inicfg.save(def, directIni)
                end
                if imgui.Button(u8"Настройки "..fa.ICON_COGS, imgui.ImVec2(137, 35)) then
                    vkladki[4] = true
                    ini.settings.vkladka = 1
                    inicfg.save(def, directIni)
                end
            imgui.EndChild()

            imgui.SameLine()

            imgui.BeginChild("ChildWindow2", imgui.ImVec2(200, 150), true)

                imgui.Columns(3, "Columns", true) -- кол-во колонок, уникальное имя, граница

                imgui.Text("Text1")

                imgui.NextColumn()

                imgui.Text("Text2")

                imgui.NextColumn()

                imgui.Text("Text3")

                imgui.Separator()

                imgui.NextColumn()

                imgui.Text("Text4")

                imgui.NextColumn()

                --imgui.Text("Text5")

                if imgui.Selectable(u8"Нажми1", arrSelectable[1], imgui.SelectableFlags.AllowDoubleClick) then
                    if (imgui.IsMouseDoubleClicked(0)) then
                        arrSelectable[1] = not arrSelectable[1]
                        sampAddChatMessage("Нажали1", -1)
                    end
                end

                imgui.NextColumn()

                --imgui.Text("Text6")

                if imgui.Selectable(u8"Нажми2", arrSelectable[2]) then
                    arrSelectable[2] = not arrSelectable[2]
                    sampAddChatMessage("Нажали2", -1)
                end

                imgui.Columns(1)

                imgui.Separator()

                imgui.Button("button")

                

                

            imgui.EndChild()

        imgui.End()
    end
end
 

paulohardy

вы еще постите говно? тогда я иду к вам
Всефорумный модератор
1,891
1,254
Привет всем, проблема с inicfg. Вылетает ошибка attempt to index local 'ini' (a nil value). Код:
code:
script_name('Imgui Script Icons') -- название скрипта
script_author('FORMYS') -- автор скрипта
script_description('Imgui') -- описание скрипта

require "lib.moonloader" -- подключение библиотеки
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
local sampev   = require 'lib.samp.events'
local inicfg   = require 'inicfg'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local directIni = "PrisonHelper\\PrHelper.ini"

local ini = inicfg.load(def, directIni)

local vkladki = {
    false,
        false,
        false,
        false,
}

local def = {
    settings = {
        vkladka = 1
}}

vkladki[ini.settings.vkladka] = true

local fa = require 'faIcons'
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })

main_window_state = imgui.ImBool(false)
arrSelectable = {false, false}

function imgui.BeforeDrawFrame()
    if fa_font == nil then
        local font_config = imgui.ImFontConfig() -- to use 'imgui.ImFontConfig.new()' on error
        font_config.MergeMode = true
        fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fontawesome-webfont.ttf', 14.0, font_config, fa_glyph_ranges)
    end
end


function imgui.TextColoredRGB(text, render_text)
    local max_float = imgui.GetWindowWidth()
    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

            local length = imgui.CalcTextSize(w)
            if render_text == 2 then
                imgui.NewLine()
                imgui.SameLine(max_float / 2 - ( length.x / 2 ))
            elseif render_text == 3 then
                imgui.NewLine()
                imgui.SameLine(max_float - length.x - 5 )
            end
            if text[0] then
                for i = 0, #text do
                    imgui.TextColored(colors_[i] or colors[1], text[i])
                    imgui.SameLine(nil, 0)
                end
                imgui.NewLine()
            else imgui.Text(w) end


        end
    end

    render_text(text)
end

function SetStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.ChildWindowRounding = 4.0
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    colors[clr.Button]                 = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.29, 0.48, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 0.50)-- (0.1, 0.9, 0.1, 1.0)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 1.00)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.Header]                 = ImVec4(0.26, 0.59, 0.98, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.52, 0.88, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.59, 0.98, 1.00)
end

SetStyle()

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

    sampRegisterChatCommand("icons", cmd_icons)

    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)

    imgui.Process = false

    while true do
        wait(0)
    end
end

function cmd_icons(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function imgui.OnDrawFrame()

    if not main_window_state.v then
        imgui.Process = false
    end

   if main_window_state.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(600, 300), imgui.Cond.FirstUseEver)

        imgui.Begin('Helper for Prison', main_window_state)

            imgui.BeginChild("ChildButtons", imgui.ImVec2(153, 265), true)
                if imgui.Button(u8"Информация "..fa.ICON_ADDRESS_BOOK_O, imgui.ImVec2(137, 35)) then
                    vkladki[1] = true
                    ini.settings.vkladka = 1
                    inicfg.save(def, directIni)
                end
                if imgui.Button(u8"Биндер "..fa.ICON_FILE_TEXT, imgui.ImVec2(137, 35))then
                    vkladki[2] = true
                    ini.settings.vkladka = 1
                    inicfg.save(def, directIni)
                end
                if imgui.Button(u8"О скрипте "..fa.ICON_USER, imgui.ImVec2(137, 35)) then
                    vkladki[3] = true
                    ini.settings.vkladka = 1
                    inicfg.save(def, directIni)
                end
                if imgui.Button(u8"Настройки "..fa.ICON_COGS, imgui.ImVec2(137, 35)) then
                    vkladki[4] = true
                    ini.settings.vkladka = 1
                    inicfg.save(def, directIni)
                end
            imgui.EndChild()

            imgui.SameLine()

            imgui.BeginChild("ChildWindow2", imgui.ImVec2(200, 150), true)

                imgui.Columns(3, "Columns", true) -- кол-во колонок, уникальное имя, граница

                imgui.Text("Text1")

                imgui.NextColumn()

                imgui.Text("Text2")

                imgui.NextColumn()

                imgui.Text("Text3")

                imgui.Separator()

                imgui.NextColumn()

                imgui.Text("Text4")

                imgui.NextColumn()

                --imgui.Text("Text5")

                if imgui.Selectable(u8"Нажми1", arrSelectable[1], imgui.SelectableFlags.AllowDoubleClick) then
                    if (imgui.IsMouseDoubleClicked(0)) then
                        arrSelectable[1] = not arrSelectable[1]
                        sampAddChatMessage("Нажали1", -1)
                    end
                end

                imgui.NextColumn()

                --imgui.Text("Text6")

                if imgui.Selectable(u8"Нажми2", arrSelectable[2]) then
                    arrSelectable[2] = not arrSelectable[2]
                    sampAddChatMessage("Нажали2", -1)
                end

                imgui.Columns(1)

                imgui.Separator()

                imgui.Button("button")

               

               

            imgui.EndChild()

        imgui.End()
    end
end
local directIni = "PrisonHelper\\PrHelper"
 
  • Нравится
Реакции: yeahbitch

yeahbitch

Потрачен
28
5
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
local directIni = "PrisonHelper\\PrHelper"
Код:
[ML] (error) Imgui Script Icons: ...ëîâëÿ\sjatoe govno junsqd\moonloader\imgui_lesson_12.lua:30: attempt to index local 'ini' (a nil value)
stack traceback:
    ...ëîâëÿ\sjatoe govno junsqd\moonloader\imgui_lesson_12.lua:30: in main chunk
[ML] (error) Imgui Script Icons: Script died due to an error. (0E365744)
Та же ошибка, код исправил, файл ini создан...
 

paulohardy

вы еще постите говно? тогда я иду к вам
Всефорумный модератор
1,891
1,254
Код:
[ML] (error) Imgui Script Icons: ...ëîâëÿ\sjatoe govno junsqd\moonloader\imgui_lesson_12.lua:30: attempt to index local 'ini' (a nil value)
stack traceback:
    ...ëîâëÿ\sjatoe govno junsqd\moonloader\imgui_lesson_12.lua:30: in main chunk
[ML] (error) Imgui Script Icons: Script died due to an error. (0E365744)
Та же ошибка, код исправил, файл ini создан...
попробуй так
local ini = inicfg.load(nil, directIni)
 
  • Нравится
Реакции: yeahbitch

skarzer999

Известный
24
2
Как получить ид и ник игрока на которого я целюсь? Всегда показывает игрока с идом 0
Додумался только что бы убрать нижнее подчеркивание через gsub
Lua:
local playername = sampGetPlayerNickname(id):gsub('_', ' ')
 

Akionka

akionka.lua
Проверенный
742
500
Как получить ид и ник игрока на которого я целюсь? Всегда показывает игрока с идом 0
Додумался только что бы убрать нижнее подчеркивание через gsub
Lua:
local playername = sampGetPlayerNickname(id):gsub('_', ' ')
 
  • Влюблен
Реакции: beshbarmak

Izvinisb

Известный
Проверенный
964
598
как узнать находиться ли игрок в зоне стрима(по id)?
Lua:
local _, ped = sampGetCharHandleBySampPlayerId(id)
    if not _ then
        sampAddChatMessage('Игрока с id-ом ' ..id.. ' нету в зоне стрима')
    end
end
UPD: а надо который в зоне стрима, тогда убери 'not'
 
  • Нравится
Реакции: neverlane

kizn

О КУ)))
Всефорумный модератор
2,405
2,058
если текстдрав "1" существует, то... (код)
если текстдрав "2" существует, то... (код)
нужна эта функция

и еще нужна функция на
если в чате найдено "{000000}ты попа", то... код
 

Izvinisb

Известный
Проверенный
964
598
если текстдрав "1" существует, то... (код)
если текстдрав "2" существует, то... (код)
нужна эта функция

и еще нужна функция на
если в чате найдено "{000000}ты попа", то... код
Код:
bool result = sampTextdrawIsExists(id) -- проверка текстдрава на существование
local hook = require'samp.events'

function hook.onServerMessage(color, text)
    if text:find('{FFFFFF}ты даун') then
        -- code
    end
end
 

MadVladdos

Новичок
2
0
Парни, подскажите, как сделать, что бы доставался предмет из инвентаря (/inv). Типо все одной командой.
Не шарю просто.
 

kizn

О КУ)))
Всефорумный модератор
2,405
2,058
при вводе команды "/popa" должна быть надпись "скрипт включен", но эта команда вместо одноразового сообщения флудит в чат. что я не так сделал?