- 396
- 130
- Версия MoonLoader
- Другое
Lua:
---=== Загрузка библиотек ===---
require "lib.moonloader"
local imgui = require 'mimgui'
local sampev = require 'lib.samp.events'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
---=== Параметры Mimgui
local new = imgui.new
local renderWindow = new.bool()
---=== Переменные ===---
local dialog_settings = {
to_chat = new.bool(), -- 1
show_id = new.bool(), -- 2
show_title = new.bool(), -- 3
show_text = new.bool(), -- 4
show_style = new.bool(), -- 5
show_button1 = new.bool(), -- 6
show_button2 = new.bool() -- 7
}
--[[local to_chat = new.bool()
local show_id = new.bool()
local show_title = new.bool()
local show_text = new.bool()
local show_style = new.bool()
local show_button1 = new.bool()
local show_button2 = new.bool()]]--
local show_td = new.bool()
local ipServer, portServer = sampGetCurrentServerAddress()
local nameServer = sampGetCurrentServerName()
---=== Визуальная часть ===---
imgui.OnInitialize(function()
imgui.GetIO().IniFilename = nil
imgui.DarkTheme()
end)
local newFrame = imgui.OnFrame(
function() return renderWindow[0] end,
function(player)
local resX, resY = getScreenResolution()
local sizeX, sizeY = 500, 300
imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
imgui.Begin('Debug Menu', renderWindow)
imgui.TextWrapped(u8'Debug Menu - полезный инструмент для разработки в сфере SA:MP')
imgui.Separator()
if imgui.CollapsingHeader(u8'Анимации') then
local idAnim = sampGetPlayerAnimationId(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED)))
local fileAnim, nameAnim = sampGetAnimationNameAndFile(idAnim)
imgui.TextWrapped(u8'ID текущей анимации: ' ..idAnim)
imgui.TextWrapped(u8'File текущей анимации: ' ..fileAnim)
imgui.TextWrapped(u8'Название текущей анимации: ' ..nameAnim)
end
if imgui.CollapsingHeader(u8'Информация о сервере') then
imgui.TextWrapped(u8'IP сервера: ' ..ipServer.. ':' ..portServer)
imgui.TextWrapped(nameServer)
if imgui.Button(u8'Отключиться от сервера', imgui.ImVec2(475, 30)) then
CloseConnect()
end
end
if imgui.CollapsingHeader(u8'Телепорты') then
imgui.TextWrapped(u8'Телепорт к игроку по ID: /warpto ID')
if imgui.Button(u8'Телепорт на метку', imgui.ImVec2(475, 30)) then
local result, x, y, z = getTargetBlipCoordinates()
if result then
setCharCoordinates(playerPed, x, y, z)
sampAddChatMessage('Успешно телепортировались!', -1)
else
sampAddChatMessage('Метка не найдена! Поставьте метку на карте!', -1)
end
end
if imgui.Button(u8'Телепорт к ближайшей машине', imgui.ImVec2(475, 30)) then
for k,v in ipairs(getAllVehicles()) do
local x, y, z = getCarCoordinates(v)
setCharCoordinates(playerPed, x, y, z)
break
end
end
end
if imgui.CollapsingHeader(u8'Координаты') then
imgui.TextWrapped(u8'Ваши координаты: x:' ..string.format("%.2f", select(1, getCharCoordinates(playerPed)))..' y: '..string.format("%.2f", select(2, getCharCoordinates(playerPed)))..' z: '..string.format("%.2f", select(3, getCharCoordinates(playerPed))))
if imgui.Button(u8'Копировать координаты', imgui.ImVec2(475, 30)) then
sampAddChatMessage('x = '..string.format("%.2f", select(1, getCharCoordinates(playerPed)))..'; y = '..string.format("%.2f", select(2, getCharCoordinates(playerPed)))..'; z = '..string.format("%.2f", select(3, getCharCoordinates(playerPed))), -1)
sampAddChatMessage('Координаты скопированы!', -1)
local x, y, z = getCharCoordinates(playerPed)
setClipboardText(x.." "..y.." "..z)
end
end
if imgui.CollapsingHeader(u8'Диалоги') then
imgui.Checkbox(u8'Отправлять информацию о диалогах в чат', dialog_settings[1])
imgui.Checkbox(u8'Показывать ID диалогов', dialog_settings[2])
imgui.Checkbox(u8'Показывать название диалога', dialog_settings[3])
imgui.Checkbox(u8'Показывать содержимое диалога', dialog_settings[4])
imgui.Checkbox(u8'Показывать стиль диалога', dialog_settings[5])
imgui.Checkbox(u8'Показывать информацию о 1 кнопке', dialog_settings[6])
imgui.Checkbox(u8'Показывать информацию о 2 кнопке', dialog_settings[7])
end
if imgui.CollapsingHeader(u8'Текстдравы') then
imgui.Checkbox(u8'Показывать ID текстдравов', show_td)
end
if imgui.CollapsingHeader(u8'Дополнительные функции') then
if imgui.Button(u8'Умереть', imgui.ImVec2(475, 50)) then
setCharHealth(playerPed, 0)
sampSendSpawn()
end
if imgui.Button(u8'JetPack', imgui.ImVec2(475, 50)) then
taskJetpack(PLAYER_PED)
end
end
imgui.End()
end
)
---=== Скриптовая часть ===---
function main()
while not isSampAvailable() do wait(0) end
sampRegisterChatCommand('mdebug', function()
renderWindow[0] = not renderWindow[0]
end)
sampRegisterChatCommand("warpto", cmdWarp)
local td_font = renderCreateFont("Arial", 8, 5)
while true do
wait(0)
if show_td[0] then
for a = 0, 2304 do
if sampTextdrawIsExists(a) then
x, y = sampTextdrawGetPos(a)
x1, y1 = convertGameScreenCoordsToWindowScreenCoords(x, y)
renderFontDrawText(td_font, a, x1, y1, 0xFFBEBEBE)
end
end
end
end
end
function sampev.onSendPlayerSync(data)
if isPlayerUsingJetpack(0) then
data.specialAction = 0
end
end
function CloseConnect()
raknetEmulPacketReceiveBitStream(PACKET_DISCONNECTION_NOTIFICATION, raknetNewBitStream())
raknetDeleteBitStream(raknetNewBitStream())
end
function cmdWarp(p)
if #p > 0 then
local id = tonumber(p)
if sampIsPlayerConnected(id) then
local result, posX, posY, posZ = sampGetStreamedOutPlayerPos(id)
if result then
teleportToPlayer(id, posX + 1.0, posY + 1.0, posZ)
else
local result, handle = sampGetCharHandleBySampPlayerId(id)
if result and doesCharExist(handle) then
local posX, posY, posZ = getCharCoordinates(handle)
teleportToPlayer(id, posX + 1.0, posY + 1.0, posZ - 1.0)
else
sampAddChatMessage(string.format("Player %s(%d) position is unknown.", sampGetPlayerNickname(id), id), 0xCC0000)
end
end
else
sampAddChatMessage(string.format("Player %d is not connected.", id), 0xCC0000)
end
end
end
function teleportToPlayer(id, x, y, z)
setCharCoordinates(playerPed, x, y, z)
sampAddChatMessage(string.format("Teleported to %s (%d). Position %.2f %.2f %.2f", sampGetPlayerNickname(id), id, x, y, z), 0xAAAAAA)
end
function sampev.onShowDialog(id, style, title, button1, button2, text)
if title:find('{') then
title = title:gsub('{', '[')
title = title:gsub('}', ']')
end
if text:find('{') then
text = text:gsub('{', '[')
text = text:gsub('}', ']')
end
if button1:find('{') then
button1 = button1:gsub('{', '[')
button1 = button1:gsub('}', ']')
end
if button2:find('{') then
button2 = button2:gsub('{', '[')
button2 = button2:gsub('}', ']')
end
print('\n \n {FF8C00}Dialog shown!' .. '\n{FF8C00}[DialogInfo]: Dialog ID: {ffffff}' .. id .. '\n{FF8C00}[DialogInfo]: Dialog Title: {ffffff}' .. title .. '\n{FF8C00}[DialogInfo]: Dialog text: {ffffff}' .. text .. '\n{FF8C00}[DialogInfo]: Dialog Style: {ffffff}' .. style .. '\n{FF8C00}[DialogInfo]: Dialog Button1: {ffffff}' .. button1 .. '\n{FF8C00}[DialogInfo]: Dialog Button2: {ffffff}' .. button2)
if dialog_settings[1] then
if dialog_settings[1] then sampAddChatMessage('Диалог найден!', -1) end
if dialog_settings[2] then sampAddChatMessage('\n{FF8C00}[DialogInfo]: {c17e84}Dialog ID: {ffffff}' .. id, -1) end
if dialog_settings[3] then sampAddChatMessage('\n{FF8C00}[DialogInfo]: {c17e84}Dialog Title: {ffffff}' .. title, -1) end
if dialog_settings[4] then sampAddChatMessage('\n{FF8C00}[DialogInfo]: {c17e84}Dialog text: {ffffff}' .. text, -1) end
if dialog_settings[5] then sampAddChatMessage('\n{FF8C00}[DialogInfo]: {c17e84}Dialog Style: {ffffff}' .. style, -1) end
if dialog_settings[6] then sampAddChatMessage('\n{FF8C00}[DialogInfo]: {c17e84}Dialog Button1: {ffffff}' .. button1, -1)end
if dialog_settings[7] then sampAddChatMessage('\n{FF8C00}[DialogInfo]: {c17e84}Dialog Button2: {ffffff}' .. button2, -1) end
end
return true
end
---=== Темная тема Mimgui ===---
function imgui.DarkTheme()
imgui.SwitchContext()
--==[ STYLE ]==--
imgui.GetStyle().WindowPadding = imgui.ImVec2(10, 5)
imgui.GetStyle().FramePadding = imgui.ImVec2(5, 5)
imgui.GetStyle().ItemSpacing = imgui.ImVec2(5, 5)
imgui.GetStyle().ItemInnerSpacing = imgui.ImVec2(2, 2)
imgui.GetStyle().TouchExtraPadding = imgui.ImVec2(0, 0)
imgui.GetStyle().IndentSpacing = 0
imgui.GetStyle().ScrollbarSize = 10
imgui.GetStyle().GrabMinSize = 10
--==[ BORDER ]==--
imgui.GetStyle().WindowBorderSize = 1
imgui.GetStyle().ChildBorderSize = 1
imgui.GetStyle().PopupBorderSize = 1
imgui.GetStyle().FrameBorderSize = 1
imgui.GetStyle().TabBorderSize = 1
--==[ ROUNDING ]==--
imgui.GetStyle().WindowRounding = 10
imgui.GetStyle().ChildRounding = 5
imgui.GetStyle().FrameRounding = 5
imgui.GetStyle().PopupRounding = 5
imgui.GetStyle().ScrollbarRounding = 5
imgui.GetStyle().GrabRounding = 5
imgui.GetStyle().TabRounding = 5
--==[ ALIGN ]==--
imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
imgui.GetStyle().ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
imgui.GetStyle().SelectableTextAlign = imgui.ImVec2(0.5, 0.5)
--==[ COLORS ]==--
imgui.GetStyle().Colors[imgui.Col.Text] = imgui.ImVec4(1.00, 1.00, 1.00, 1.00)
imgui.GetStyle().Colors[imgui.Col.TextDisabled] = imgui.ImVec4(0.50, 0.50, 0.50, 1.00)
imgui.GetStyle().Colors[imgui.Col.WindowBg] = imgui.ImVec4(0.07, 0.07, 0.07, 1.00)
imgui.GetStyle().Colors[imgui.Col.ChildBg] = imgui.ImVec4(0.07, 0.07, 0.07, 1.00)
imgui.GetStyle().Colors[imgui.Col.PopupBg] = imgui.ImVec4(0.07, 0.07, 0.07, 1.00)
imgui.GetStyle().Colors[imgui.Col.Border] = imgui.ImVec4(0.25, 0.25, 0.26, 0.54)
imgui.GetStyle().Colors[imgui.Col.BorderShadow] = imgui.ImVec4(0.00, 0.00, 0.00, 0.00)
imgui.GetStyle().Colors[imgui.Col.FrameBg] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
imgui.GetStyle().Colors[imgui.Col.FrameBgHovered] = imgui.ImVec4(0.25, 0.25, 0.26, 1.00)
imgui.GetStyle().Colors[imgui.Col.FrameBgActive] = imgui.ImVec4(0.25, 0.25, 0.26, 1.00)
imgui.GetStyle().Colors[imgui.Col.TitleBg] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
imgui.GetStyle().Colors[imgui.Col.TitleBgActive] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
imgui.GetStyle().Colors[imgui.Col.TitleBgCollapsed] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
imgui.GetStyle().Colors[imgui.Col.MenuBarBg] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
imgui.GetStyle().Colors[imgui.Col.ScrollbarBg] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
imgui.GetStyle().Colors[imgui.Col.ScrollbarGrab] = imgui.ImVec4(0.00, 0.00, 0.00, 1.00)
imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabHovered] = imgui.ImVec4(0.41, 0.41, 0.41, 1.00)
imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabActive] = imgui.ImVec4(0.51, 0.51, 0.51, 1.00)
imgui.GetStyle().Colors[imgui.Col.CheckMark] = imgui.ImVec4(1.00, 1.00, 1.00, 1.00)
imgui.GetStyle().Colors[imgui.Col.SliderGrab] = imgui.ImVec4(0.21, 0.20, 0.20, 1.00)
imgui.GetStyle().Colors[imgui.Col.SliderGrabActive] = imgui.ImVec4(0.21, 0.20, 0.20, 1.00)
imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
imgui.GetStyle().Colors[imgui.Col.ButtonHovered] = imgui.ImVec4(0.21, 0.20, 0.20, 1.00)
imgui.GetStyle().Colors[imgui.Col.ButtonActive] = imgui.ImVec4(0.41, 0.41, 0.41, 1.00)
imgui.GetStyle().Colors[imgui.Col.Header] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
imgui.GetStyle().Colors[imgui.Col.HeaderHovered] = imgui.ImVec4(0.20, 0.20, 0.20, 1.00)
imgui.GetStyle().Colors[imgui.Col.HeaderActive] = imgui.ImVec4(0.47, 0.47, 0.47, 1.00)
imgui.GetStyle().Colors[imgui.Col.Separator] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
imgui.GetStyle().Colors[imgui.Col.SeparatorHovered] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
imgui.GetStyle().Colors[imgui.Col.SeparatorActive] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
imgui.GetStyle().Colors[imgui.Col.ResizeGrip] = imgui.ImVec4(1.00, 1.00, 1.00, 0.25)
imgui.GetStyle().Colors[imgui.Col.ResizeGripHovered] = imgui.ImVec4(1.00, 1.00, 1.00, 0.67)
imgui.GetStyle().Colors[imgui.Col.ResizeGripActive] = imgui.ImVec4(1.00, 1.00, 1.00, 0.95)
imgui.GetStyle().Colors[imgui.Col.Tab] = imgui.ImVec4(0.12, 0.12, 0.12, 1.00)
imgui.GetStyle().Colors[imgui.Col.TabHovered] = imgui.ImVec4(0.28, 0.28, 0.28, 1.00)
imgui.GetStyle().Colors[imgui.Col.TabActive] = imgui.ImVec4(0.30, 0.30, 0.30, 1.00)
imgui.GetStyle().Colors[imgui.Col.TabUnfocused] = imgui.ImVec4(0.07, 0.10, 0.15, 0.97)
imgui.GetStyle().Colors[imgui.Col.TabUnfocusedActive] = imgui.ImVec4(0.14, 0.26, 0.42, 1.00)
imgui.GetStyle().Colors[imgui.Col.PlotLines] = imgui.ImVec4(0.61, 0.61, 0.61, 1.00)
imgui.GetStyle().Colors[imgui.Col.PlotLinesHovered] = imgui.ImVec4(1.00, 0.43, 0.35, 1.00)
imgui.GetStyle().Colors[imgui.Col.PlotHistogram] = imgui.ImVec4(0.90, 0.70, 0.00, 1.00)
imgui.GetStyle().Colors[imgui.Col.PlotHistogramHovered] = imgui.ImVec4(1.00, 0.60, 0.00, 1.00)
imgui.GetStyle().Colors[imgui.Col.TextSelectedBg] = imgui.ImVec4(1.00, 0.00, 0.00, 0.35)
imgui.GetStyle().Colors[imgui.Col.DragDropTarget] = imgui.ImVec4(1.00, 1.00, 0.00, 0.90)
imgui.GetStyle().Colors[imgui.Col.NavHighlight] = imgui.ImVec4(0.26, 0.59, 0.98, 1.00)
imgui.GetStyle().Colors[imgui.Col.NavWindowingHighlight] = imgui.ImVec4(1.00, 1.00, 1.00, 0.70)
imgui.GetStyle().Colors[imgui.Col.NavWindowingDimBg] = imgui.ImVec4(0.80, 0.80, 0.80, 0.20)
imgui.GetStyle().Colors[imgui.Col.ModalWindowDimBg] = imgui.ImVec4(0.00, 0.00, 0.00, 0.70)
end
В общем хотел заменить кучу переменных на таблицу, но когда открываю вкладку связанную с таблицами, то игра карашется