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

|DEVIL|

Известный
359
273
Скрипт активирует только /lock и /key, на остальные нажатия не реагирует, что не так?
Код:
script_name('PiarHelp')
script_author('Marcus_Devil')
script_version('1.7')

require "lib.moonloader"
require "lib.sampfuncs"
local hook = require "lib.samp.events"
local wh = 0xFFFFFF
local tag = "{800080}[CONOR HELPER]: {FFFFFF}"

--Мейн
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampRegisterChatCommand("fh", findhos)
        sampRegisterChatCommand("fbiz", findbz)
    sampAddChatMessage(tag .. "Скрипт запущен!",wh)
    while true do
    wait (0)
        if isKeyJustPressed(VK_L) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then
        sampSendChat("/lock")
        end
        if isKeyJustPressed(VK_K) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then
        sampSendChat("/key")
                end
            if isKeyJustPressed(VK_RSHIFT) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsLoaded() then
                sampSendChat("/style")
            end
            if isKeyJustPressed(VK_RCONTROL) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsLoaded() then
                sampSendChat("/dl")
            end
    if isKeyJustPressed(VK_P) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsLoaded() then
        sampSendChat("/phone")
        wait(500)
        if isCursorActive() then
            setVirtualKeyDown(13, true)
            wait(100)
            setVirtualKeyDown(13, false)
        end
    end
    end
end

        function findhos(arg)
        if #arg == 0 then
        sampAddChatMessage(tag .. "{00bfff}/fh [ID Дома]",wh)
        else
        sampSendChat("/findihouse ".. arg)
        end
        end

        function findbz(arg)
        if #arg == 0 then
        sampAddChatMessage(tag .. "{00bfff}/fbiz [ID Бизнеса]",wh)
        else
        sampSendChat("/findibiz ".. arg)
        end
        end
 

Danila227

Новичок
16
0
vkkey подключи .с.

Если ты не знаешь как делать - не делай, там тебе скинули .sf там юзай все объяснили видосик там даже есть
да мне нужно чтобы перс бегал по координатам, хотябы по 2-3, если не сложно, чтобы я не мучался - напиши мне, буду очень благодарен, это много времени не займет
 

Danila227

Новичок
16
0
Там изи все сделает.
мне нужно чтобы по команде в ракботе перс бегал
 

|DEVIL|

Известный
359
273
vkkey подключи .с.

Если ты не знаешь как делать - не делай, там тебе скинули .sf там юзай все объяснили видосик там даже есть
Подключил, ничего не изменилось, сейчас скину как сделал
Код:
script_name('PiarHelp')
script_author('Marcus_Devil')
script_version('1.7')

require "lib.moonloader"
require "lib.sampfuncs"
require "vkeys"
local hook = require "lib.samp.events"
local wh = 0xFFFFFF
local tag = "{800080}[CONOR HELPER]: {FFFFFF}"

--Мейн
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampRegisterChatCommand("fh", findhos)
        sampRegisterChatCommand("fbiz", findbz)
    sampAddChatMessage(tag .. "Скрипт запущен!",wh)
    while true do
    wait (0)
        if isKeyJustPressed(VK_L) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then
        sampSendChat("/lock")
        end
        if isKeyJustPressed(VK_K) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then
        sampSendChat("/key")
                end
            if isKeyJustPressed(VK_RSHIFT) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsLoaded() then
                sampSendChat("/style")
            end
            if isKeyJustPressed(VK_RCONTROL) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsLoaded() then
                sampSendChat("/dl")
            end
    if isKeyJustPressed(VK_P) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsLoaded() then
        sampSendChat("/phone")
        wait(500)
        if isCursorActive() then
            setVirtualKeyDown(13, true)
            wait(100)
            setVirtualKeyDown(13, false)
        end
    end
    end
end

        function findhos(arg)
        if #arg == 0 then
        sampAddChatMessage(tag .. "{00bfff}/fh [ID Дома]",wh)
        else
        sampSendChat("/findihouse ".. arg)
        end
        end

        function findbz(arg)
        if #arg == 0 then
        sampAddChatMessage(tag .. "{00bfff}/fbiz [ID Бизнеса]",wh)
        else
        sampSendChat("/findibiz ".. arg)
        end
        end
 

Pheonixxx

Потрачен
263
46
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Крашит и выдает ошибку
Lua:
script_author('Cody_Flex / Subaru_Flex')
script_version('1.4.0')
script_name('SMI++ | By Cody_Flex / Subaru_Flex')
--[[
    Написал код Cody_Flex / Subaru_Flex
    vk : https://vk.com/nikitakukosh
    Тескт предоставил Carl_Flex
    vk: https://vk.com/jesusholyshit   
    © Cody_Flex 2019
]]


--// librares/библиотеки //
local imgui        = require 'imgui'
local key          = require 'vkeys'
local inicfg       = require 'inicfg'
local encoding     = require 'encoding'
--local fa           = require 'fAwesome5'
local hook         = require 'lib.samp.events'
--imgui.BufferingBar = require('imgui_addons').BufferingBar
                     require "lib.moonloader"
                    
--// smi.ini //
local directini    = "moonloader\\smi.ini"
local mainini      = inicfg.load(nil, directini)

--// encoding / Кодировка //
encoding.default = 'cp1251'
u8               = encoding.UTF8


--?? menu setting / настройки меню ??
local main_window     = imgui.ImBool(false)
local leaders_window  = imgui.ImBool(false)
local btn_size        = imgui.ImVec2(110,47) --размер кнопки
local selectable_size = imgui.ImVec2(147,40)
local btnlives_size   = imgui.ImVec2(100,40)
local btnadw_size     = imgui.ImVec2(90,60)
local adws_btn        = imgui.ImVec2(273,40)
local btn_size        = imgui.ImVec2(110,47)
--????? панель лидера ?????

--// Прочая хуета / Other //
local aboutscr = u8[[
=========================================
| Написал код Cody_Flex / Subaru_Flex             
| vk : https://vk.com/nikitakukosh     
| Текст предоставил Carl_Flex
| vk: https://vk.com/jesusholyshit       
|  © Cody_Flex 2019 / SMI++ Helper     
=========================================

Скрипт находится еще в разработке,по поводу багов писать в вк
]]


--// main window/само меню //
function imgui.OnDrawFrame()
    if main_window.v then
        imgui.SetNextWindowSize(imgui.ImVec2(740,500))
        imgui.Begin(u8'SMI++ | By Cody_Flex / Subaru_Flex', main_window,imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.AlwaysAutoResize)
            imgui.BeginChild('left', imgui.ImVec2(155, 470), true) --Навигация по меню от "Эфиров" до "О скрипте"
                if not selected then selected = 1 end
                    if imgui.Button(u8' Эфиры',selectable_size) then selected = 1 end --Эфиры fa.ICON_BULLHORN..
                imgui.Separator()
                    if imgui.Button(u8' Реклама',selectable_size) then selected = 2 end --Реклама fa.ICON_AUDIO_DESCRIPTION..
                imgui.Separator()
                    if imgui.Button(u8' Шпора устава',selectable_size) then selected = 3 end --Экзамен и прочее fa.ICON_ATLAS..
                imgui.Separator()
                    if imgui.Button(u8' Объявления',selectable_size) then selected = 4 end -- Объявления fa.ICON_ADDRESS_CARD..
                imgui.Separator()
                    if imgui.Button(u8' О скрипте',selectable_size) then selected = 5 end -- О скрипте fa.ICON_FILE_CODE..
            imgui.EndChild() --конец навигации
            imgui.SameLine()
            imgui.BeginChild('right', imgui.ImVec2(570, 470), true)
                if selected == 1 then --// Эфиры //
                    imgui.BeginChild('up', imgui.ImVec2(560, 48), true)
                     if not selectedd then selectedd = 1 end
                        if imgui.Button(u8'Математика',btnlives_size) then selectedd = 1 end -- Математика
                            imgui.SameLine()
                        if imgui.Button(u8'Столицы',btnlives_size) then selectedd = 2 end -- Столицы
                            imgui.SameLine()
                        if imgui.Button(u8'Интервью',btnlives_size) then selectedd = 3 end -- Интервью
                            imgui.SameLine()
                        if imgui.Button(u8'Хим.элементы',btnlives_size) then selectedd = 4 end --126
                    imgui.EndChild()
                    imgui.BeginChild('down', imgui.ImVec2(560, 410), true) --действия эфиров
                        if selectedd == 1 then
                            if imgui.Button(u8'Начало',btnlives_size) then
                                lua_thread.create(function()
                                    for lines in io.lines('moonloader/MassMedia++/lives/matematika/begin.txt') do
                                        sampSendChat(u8:decode(lines))
                                        wait(mainini.config.waitlive) -- задержка между биндами 2 сек, чтобы было 5 то поставить 5000
                                    end
                                end)
                            end
                             imgui.SameLine()
                            if imgui.Button(u8'След.пример',btnlives_size) then
                                sampSetChatInputText('/news [Математика] Следующий пример: ')
                                sampSetChatInputEnabled(true)
                            end
                            if imgui.Button(u8'Конец',btnlives_size) then
                                lua_thread.create(function()
                                    for lines in io.lines('moonloader/MassMedia++/lives/matematika/end.txt') do
                                        sampSendChat(u8:decode(lines))
                                        wait(mainini.config.waitlive) -- задержка между биндами 2 сек, чтобы было 5 то поставить 5000
                                    end
                                end)
                            end
                            imgui.SameLine()
                            if imgui.Button(u8'Стоп!',btnlives_size) then
                                lua_thread.create(function()
                                    sampSendChat('/news [Математика] Стоп!')
                                    wait(2000)
                                    sampSetChatInputText('/news [Математика] Первым был .. и у него .. балла')
                                    sampSetChatInputEnabled(true)
                                end)
                            end
                        end
                        if selectedd == 2 then -------------------------------------|| СТОЛИЦЫ || -----------------------------------------------------------------------
                            if imgui.Button(u8'Начало',btnlives_size) then
                                lua_thread.create(function()
                                    for lines in io.lines('moonloader/MassMedia++/lives/stolicy/begin.txt') do
                                        sampSendChat(u8:decode(lines))
                                        wait(mainini.config.waitlive) -- задержка между биндами 2 сек, чтобы было 5 то поставить 5000
                                    end
                                end)
                            end
                             imgui.SameLine()
                            if imgui.Button(u8'След.страна',btnlives_size) then
                                sampSetChatInputText('/news [Столицы] Следующая страна: ')
                                sampSetChatInputEnabled(true)
                            end
                            if imgui.Button(u8'Конец',btnlives_size) then
                                lua_thread.create(function()
                                    for lines in io.lines('moonloader/MassMedia++/lives/stolicy/end.txt') do
                                        sampSendChat(u8:decode(lines))
                                        wait(mainini.config.waitlive) -- задержка между биндами 2 сек, чтобы было 5 то поставить 5000
                                    end
                                end)
                            end
                            imgui.SameLine()
                            if imgui.Button(u8'Стоп!',btnlives_size) then
                                lua_thread.create(function()
                                    sampSendChat('/news [Столицы] Стоп!')
                                    wait(2000)
                                    sampSetChatInputText('/news [Столицы] Первым был .. и у него .. балла')
                                    sampSetChatInputEnabled(true)
                                end)
                            end
                        end
                     end
                        imgui.End()
    end
end



--// icons/иконки fyp //
--[[local fa_font = nil
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
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/fa-solid-900.ttf', 13.0, font_config, fa_glyph_ranges)
    end
end ]]



--// загрузка скрипта //
function main()
    sampRegisterChatCommand('ms',call_window)
    sampRegisterChatCommand('ld',call_ldwindow)
    --sampRegisterChatCommand('rl',function() local scr = thisScript() scr:reload()  end)
    while true do
      wait(0)
      if wasKeyPressed(key.VK_INSERT)  then
      main_window.v = not main_window.v
      end
      if wasKeyPressed(key.VK_F1) then
      main_window.v = not main_window.v
      end     
      imgui.Process = main_window.v or leaders_window.v
    end
end

--// call-windows //
function call_window()
    main_window.v = not main_window.v 
    imgui.Process = main_window.v
end

--// call-ldwindows //
function call_ldwindow()
    leaders_window.v = not leaders_window.v
    imgui.Process = leaders_window.v
end

function getClosestPlayerId()
    local minDist = 2
    local closestId = -1
    local x, y, z = getCharCoordinates(PLAYER_PED)
    for i = 0, 999 do
        local streamed, pedID = sampGetCharHandleBySampPlayerId(i)
        if streamed then
            local xi, yi, zi = getCharCoordinates(pedID)
            local dist = math.sqrt( (xi - x) ^ 2 + (yi - y) ^ 2 + (zi - z) ^ 2 )
            if dist < minDist then
                minDist = dist
                closestId = i
            end
        end
    end
    return closestId
end



--// стиль меню //
function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 0.5
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 0.5
    style.Alpha = 1
    style.WindowPadding = imgui.ImVec2(4.0, 4.0)
    -- style.WindowMinSize =
    style.FramePadding = imgui.ImVec2(3.5, 3.5)
    -- style.ItemInnerSpacing =
    -- style.TouchExtraPadding =
    -- style.IndentSpacing =
    -- style.ColumnsMinSpacing = ?
    -- style.DisplayWindowPadding =
    -- style.DisplaySafeAreaPadding =
    -- style.AntiAliasedLines =
    -- style.AntiAliasedShapes =
    -- style.CurveTessellationTol =
    colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.WindowBg]               = ImVec4(0.06, 0.06, 0.06, 0.95) --ImVec4(0.06, 0.06, 0.06, 0.91)
    colors[clr.ChildWindowBg]          = ImVec4(1.00, 1.00, 1.00, 0.00)
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50) --0.43, 0.43, 0.50, 0.50
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]                = ImVec4(0.12, 0.12, 0.12, 0.94)
    colors[clr.FrameBgHovered]         = ImVec4(0.45, 0.45, 0.45, 0.85)
    colors[clr.FrameBgActive]          = ImVec4(0.63, 0.63, 0.63, 0.63)
    colors[clr.TitleBg]                = ImVec4(0.13, 0.13, 0.13, 0.99)
    colors[clr.TitleBgActive]          = ImVec4(0.13, 0.13, 0.13, 0.99)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.05, 0.05, 0.05, 0.79)
    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(1.00, 1.00, 1.00, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.28, 0.28, 0.28, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.35, 0.35, 0.35, 1.00)
    colors[clr.Button]                 = ImVec4(0.12, 0.12, 0.12, 0.94)
    colors[clr.ButtonHovered]          = ImVec4(0.34, 0.34, 0.35, 0.89)
    colors[clr.ButtonActive]           = ImVec4(0.21, 0.21, 0.21, 0.81)
    colors[clr.Header]                 = ImVec4(0.12, 0.12, 0.12, 0.94)
    colors[clr.HeaderHovered]          = ImVec4(0.12, 0.12, 0.12, 0.94)
    colors[clr.HeaderActive]           = ImVec4(0.16, 0.16, 0.16, 0.90)
    colors[clr.Separator]              = colors[clr.Border]
    colors[clr.SeparatorHovered]       = ImVec4(0.26, 0.59, 0.98, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.26, 0.59, 0.98, 0.25)
    colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.59, 0.98, 0.95)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 0.50)
    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.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
    colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
    end
    apply_custom_style()



    --[[
        imgui.Text(u8'Куплю дом в любой точке штата.Бюджет:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end
                    imgui.Text(u8'Куплю скидочные талоны.Бюджет:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end
                    imgui.Text(u8'Куплю а/м "марка".Бюджет:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end
                    imgui.Text(u8'Куплю а/с "такой то".Бюджет:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end
                    imgui.Text(u8'Куплю "такие то" медали.Бюджет:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end
                    imgui.Text(u8'Куплю цевье/компенсатор/приклад на игрушечное "оружие". Бюджет:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end

                    imgui.Text(u8'Продам дом в г.*город*.Цена:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end
                    imgui.Text(u8'Продам дом в опасном районе.Цена:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end
                    imgui.Text(u8'Продам скидочные талоны.Цена:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end
                    imgui.Text(u8'Продам подарки для детей.Цена:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end
                    imgui.Text(u8'Продам "такие то" медали.Цена:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end
                    imgui.Text(u8'Продам а/с "такой то".Цена:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end
                    imgui.Text(u8'Продам особняк на г.ВайнВуд.Цена:')
                        imgui.SameLine()   
                      if imgui.Button(u8'*клик*') then end
                    imgui.Text(u8'Продам а/м "марка".Цена:')
                        imgui.SameLine()
                      if imgui.Button(u8'*клик*') then end
    ]]
 

|DEVIL|

Известный
359
273
local keys = require 'vkeys'
Что написать на луа?
Да ёмаё, как ни старался всеровно не выходит ничего).
Код:
script_name('PiarHelp')
script_author('Marcus_Devil')
script_version('1.7')

require "lib.moonloader"
require "lib.sampfuncs"
local vkeys = require 'vkeys'
local hook = require "lib.samp.events"
local wh = 0xFFFFFF
local tag = "{800080}[CONOR HELPER]: {FFFFFF}"

--Мейн
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampRegisterChatCommand("fh", findhos)
        sampRegisterChatCommand("fbiz", findbz)
    sampAddChatMessage(tag .. "Скрипт запущен!",wh)
    while true do
    wait (0)
        if isKeyJustPressed(vkeys.VK_L) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then
        sampSendChat("/lock")
        end
        if isKeyJustPressed(vkeys.VK_K) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsConsoleActive() then
        sampSendChat("/key")
                end
            if isKeyJustPressed(vkeys.VK_RSHIFT) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsLoaded() then
                sampSendChat("/style")
            end
            if isKeyJustPressed(vkeys.VK_RCTRL) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsLoaded() then
                sampSendChat("/dl")
            end
    if isKeyJustPressed(vkeys.VK_P) and not sampIsChatInputActive() and not sampIsDialogActive() and not isPauseMenuActive() and not isSampfuncsLoaded() then
        sampSendChat("/phone")
        wait(500)
        if isCursorActive() then
            setVirtualKeyDown(13, true)
            wait(100)
            setVirtualKeyDown(13, false)
        end
    end
    end
end

        function findhos(arg)
        if #arg == 0 then
        sampAddChatMessage(tag .. "{00bfff}/fh [ID Дома]",wh)
        else
        sampSendChat("/findihouse ".. arg)
        end
        end

        function findbz(arg)
        if #arg == 0 then
        sampAddChatMessage(tag .. "{00bfff}/fbiz [ID Бизнеса]",wh)
        else
        sampSendChat("/findibiz ".. arg)
        end
        end
 

Dmitriy Makarov

25.05.2021
Проверенный
2,478
1,113
как нажать на F8, чтобы в игре скрин сделать? там с памятью вроде нужно было сделать
 

lemonager

;)
Всефорумный модератор
809
1,701
как нажать на F8, чтобы в игре скрин сделать? там с памятью вроде нужно было сделать
 
  • Нравится
Реакции: Dmitriy Makarov

sanders

Потрачен
253
126
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
мб есть у кого код нормально курда?
 

OG Buda

Активный
149
34
Как сделать чтобы мой персонаж телепортировался на определенные координаты в рандомном промежутку от 60 до 100 хп?
 

D3AMWYT

Участник
72
12
Как сделать чтобы мой персонаж телепортировался на определенные координаты в рандомном промежутку от 60 до 100 хп?

#Топ скриптеры
p.s -
Ты спросил как, я ответил, ты же не просил кодом
Получи количество ХП и введите if heal >= 60 and heal<= 100 then дальше найти функцию чтобы телепортировала.
 

D3AMWYT

Участник
72
12
Как сделать чтобы мой персонаж телепортировался на определенные координаты в рандомном промежутку от 60 до 100 хп?
А можно было ответит и просто

Lua:
local teleport = false      
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(0) end
        sampRegisterChatCommand("telep", function() teleport = not teleport end)
    while true do
        wait(0)
            if teleport then -- проверят включен
                healme = getCharHealth(playerPed) -- узнаем хп
                if healme >= 60 and healme<= 100 then -- проверка на то что пока хп не будет в этом диапазоне 
                    sampAddChatMessage(''..healme, -1) -- тут команда телепорта
                    teleport = not teleport -- как только сработает, выключит и что бы еще раз сработало нужно опять прописать команду
                end
            end
        end
    end
P.S И не нужно писать там потом что то по типу да ты не лучше написал нужно было так или так, я может и говно написал но как пример сгодится!
 
Последнее редактирование:

D3AMWYT

Участник
72
12
Проблема не решена выручайте

Записать в хуке function samp.onServerMessage(color, text)
player_nick, player_id, pl_other = text:match('Жалоба от (%w+_?%w+)[(%d+)]: %(.*)%')
После чего вывести вне хука в функции ImGui но оно не выводиться, что делать? Оно пишет либо nil text:match если это в ImGui установленно, а если в хуке то пишет что player_nick или player_id либо pl_other = nil, выручайте
Можно скрин любой жб?
 

KhanWarden

Участник
42
3
Какой код на ImGui, чтобы вот в окне ИмГуи было окошечко, куда нужно нажать комбинацию. Ну типо:
----------
|Alt + F | - /taxilist
----------
И вот получается когда нажимаешь другую комбинацию, то эта комбинация менялась в этом окне