script_name('[Absolute RP] SMI Helper')
script_author('Sanchez.')
script_description('SMI Helper for Absolute Role Play.')
require "lib.moonloader"
local encoding = require 'encoding'
local imgui = require 'imgui'
local sampev = require 'lib.samp.events'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local tag = "{1E90FF}SMI {FFFFFF}Helper: "
local selected = 1
local fa = require 'faIcons'
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()
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
local main_window_state = imgui.ImBool(false)
local sw, sh = getScreenResolution() -- получить разрешение экрана
local checked_radio = imgui.ImInt(1) -- Радио кнопка
function imgui.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
function imgui.TextQuestion(text)
imgui.SameLine()
imgui.TextDisabled('(?)')
if imgui.IsItemHovered() then
imgui.BeginTooltip()
imgui.PushTextWrapPos(450)
imgui.TextUnformatted(text)
imgui.PopTextWrapPos()
imgui.EndTooltip()
end
end
function style() -- стиль имгуи
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local ImVec2 = imgui.ImVec2
style.WindowPadding = ImVec2(10, 10)
style.WindowRounding = 10
style.ChildWindowRounding = 2
style.FramePadding = ImVec2(5, 4)
style.FrameRounding = 11
style.ItemSpacing = ImVec2(4, 4)
style.TouchExtraPadding = ImVec2(0, 0)
style.IndentSpacing = 21
style.ScrollbarSize = 16
style.ScrollbarRounding = 16
style.GrabMinSize = 11
style.GrabRounding = 16
style.WindowTitleAlign = ImVec2(0.5, 0.5)
style.ButtonTextAlign = ImVec2(0.5, 0.5)
colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.TextDisabled] = ImVec4(0.73, 0.75, 0.74, 1.00)
colors[clr.WindowBg] = ImVec4(0.09, 0.09, 0.09, 0.94)
colors[clr.ChildWindowBg] = ImVec4(10.00, 10.00, 10.00, 0.01)
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
colors[clr.Border] = ImVec4(0.20, 0.20, 0.20, 0.50)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.00, 0.39, 1.00, 0.65)
colors[clr.FrameBgHovered] = ImVec4(0.11, 0.40, 0.69, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.11, 0.40, 0.69, 1.00)
colors[clr.TitleBg] = ImVec4(0.00, 0.00, 0.00, 1.00)
colors[clr.TitleBgActive] = ImVec4(0.00, 0.24, 0.54, 1.00)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.22, 1.00, 0.67)
colors[clr.MenuBarBg] = ImVec4(0.08, 0.44, 1.00, 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.ComboBg] = ImVec4(0.20, 0.20, 0.20, 0.99)
colors[clr.CheckMark] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.SliderGrab] = ImVec4(0.34, 0.67, 1.00, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.84, 0.66, 0.66, 1.00)
colors[clr.Button] = ImVec4(0.00, 0.39, 1.00, 0.65)
colors[clr.ButtonHovered] = ImVec4(0.00, 0.64, 1.00, 0.65)
colors[clr.ButtonActive] = ImVec4(0.00, 0.53, 1.00, 0.50)
colors[clr.Header] = ImVec4(0.00, 0.62, 1.00, 0.54)
colors[clr.HeaderHovered] = ImVec4(0.00, 0.36, 1.00, 0.65)
colors[clr.HeaderActive] = ImVec4(0.00, 0.53, 1.00, 0.00)
colors[clr.Separator] = ImVec4(0.43, 0.43, 0.50, 0.50)
colors[clr.SeparatorHovered] = ImVec4(0.71, 0.39, 0.39, 0.54)
colors[clr.SeparatorActive] = ImVec4(0.71, 0.39, 0.39, 0.54)
colors[clr.ResizeGrip] = ImVec4(0.71, 0.39, 0.39, 0.54)
colors[clr.ResizeGripHovered] = ImVec4(0.84, 0.66, 0.66, 0.66)
colors[clr.ResizeGripActive] = ImVec4(0.84, 0.66, 0.66, 0.66)
colors[clr.CloseButton] = ImVec4(0.41, 0.41, 0.41, 1.00)
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
style()
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampAddChatMessage(tag .. "{FFFFFF}Скрипт для радиоцентра: включен! Автор: {1E90FF}Sanchez.", -1)
while true do
wait(0)
if sampGetCurrentDialogId() == 32 and sampIsDialogActive() then
main_window_state.v = true
imgui.Process = true
else
main_window_state.v = false
imgui.Process = false
end
end
imgui.Process = false
end
function imgui.OnDrawFrame()
imgui.SetNextWindowSize(imgui.ImVec2(420, 300), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw / 1.3), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
--imgui.WindowFlags.NoResize
imgui.Begin(fa.ICON_BULLHORN .. u8" Помощник для объявлений.", main_window_state, imgui.WindowFlags.NoCollapse)
--imgui.SameLine(150)
imgui.BeginChild("Select Gorod", imgui.ImVec2(135, 108), true)
imgui.Text(u8"Выберите город:") imgui.TextQuestion(u8"Вы должны выбрать тот город, в котором вы работаете. (ОБЯЗАТЕЛЬНО!)")
if imgui.Button(fa.ICON_GLOBE .. u8" LS", selected == 2) then selected = 1 end
if imgui.Button(fa.ICON_GLOBE .. u8" LV", selected == 3) then selected = 2 end
if imgui.Button(fa.ICON_GLOBE .. u8" SF", selected == 4) then selected = 3 end
-- if imgui.Button(u8"Куплю машину", imgui.ImVec2(175, 40)) then
-- sampSetCurrentDialogEditboxText('Куплю автомобиль марки "". Цена: ')
--end
imgui.EndChild()
imgui.SameLine()
imgui.BeginChild("Osnova", imgui.ImVec2(-1, -1), true)
if selected == 0 then
-- LS -----------------------
elseif selected == 1 then
imgui.SameLine(45) imgui.Text(u8"Выбрано:") imgui.SameLine() imgui.TextColoredRGB("{00FF00}LS (Los-Santos)")
if imgui.CollapsingHeader(fa.ICON_CAR .. u8" Покупка/продажа Т.С " .. fa.ICON_MOTORCYCLE) then
imgui.BeginChild("1", imgui.ImVec2(-1, 175), true)
imgui.SameLine(75) imgui.Text(fa.ICON_CAR .. u8" Машины:")
if imgui.Button(u8"Куплю машину. Цена в цифрах", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Куплю автомобиль марки " ". Цена: $')
end
if imgui.Button(u8"Куплю машину. Цена: договорн.", imgui.ImVec2(203, 22)) then
sampSetCurrentDialogEditboxText('LS | Куплю автомобиль марки " ". Цена: договорная')
end
imgui.Text("")
imgui.Separator()
imgui.Text("")
if imgui.Button(u8"Продам машину. Цена в цифрах", imgui.ImVec2(198, 22)) then
sampSetCurrentDialogEditboxText('LS | Продам автомобиль марки " ". Цена: $')
end
if imgui.Button(u8"Продам машину. Цена: договорн.", imgui.ImVec2(207, 22)) then
sampSetCurrentDialogEditboxText('LS | Продам автомобиль марки " ". Цена: договорная')
end
imgui.Separator()
imgui.Text("")
imgui.SameLine(70) imgui.Text(fa.ICON_MOTORCYCLE .. u8" Мотоциклы:")
if imgui.Button(u8"Куплю мото. Цена в цифрах", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Куплю мотоцикл марки " ". Цена: $')
end
if imgui.Button(u8"Куплю мото. Цена: договорн.", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Куплю мотоцикл марки " ". Цена: договорная')
end
imgui.Text("")
imgui.Separator()
imgui.Text("")
if imgui.Button(u8"Продам мото. Цена в цифрах", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Продам мотоцикл марки " ". Цена: $')
end
if imgui.Button(u8"Продам мото. Цена: договорн.", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Продам мотоцикл марки " ". Цена: договорная')
end
imgui.EndChild()
end
if imgui.CollapsingHeader(fa.ICON_HOME .. u8" Покупка/продажа домов " .. fa.ICON_HOME) then
imgui.BeginChild("11", imgui.ImVec2(-1, 500), true)
imgui.SameLine(45) imgui.Text(fa.ICON_HOME .. u8" Дома в г. Лос-Сантос:")
if imgui.Button(u8"Куплю дом. Цена в цифрах", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Куплю дом ?-го класса в г. Лос-Сантос. Цена: $')
end
if imgui.Button(u8"Куплю дом. Цена договорн.", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Куплю дом ?-го класса в г. Лос-Сантос. Цена: договорная')
end
imgui.Text("")
imgui.Separator() imgui.Text("")
if imgui.Button(u8"Продам дом. Цена в цифрах", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Продам дом ?-го класса в г. Лос-Сантос. Цена: $')
end
if imgui.Button(u8"Продам дом. Цена договорн.", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Продам дом ?-го класса в г. Лос-Сантос. Цена: договорная')
end
imgui.Text("")
imgui.Separator() imgui.Text("")
imgui.SameLine(40) imgui.Text(fa.ICON_HOME .. u8" Дома в г. Лас-Вентурас:")
if imgui.Button(u8"Куплю дом. Цена в цифрах", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Куплю дом ?-го класса в г. Лас-Вентурас. Цена: $')
end
if imgui.Button(u8"Куплю дом. Цена договорн.", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Куплю дом ?-го класса в г. Лас-Вентурас. Цена: договорная')
end
imgui.Text("")
imgui.Separator() imgui.Text("")
if imgui.Button(u8"Продам дом. Цена в цифрах", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Продам дом ?-го класса в г. Лас-Вентурас. Цена: $')
end
if imgui.Button(u8"Продам дом. Цена договорн.", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Продам дом ?-го класса в г. Лас-Вентурас. Цена: договорная')
end
imgui.Text("")
imgui.Separator()
imgui.Text("")
imgui.SameLine(40) imgui.Text(fa.ICON_HOME .. u8" Дома в г. Сан-Фиерро:")
if imgui.Button(u8"Куплю дом. Цена в цифрах", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Куплю дом ?-го класса в г. Сан-Фиерро. Цена: $')
end
if imgui.Button(u8"Куплю дом. Цена договорн.", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Куплю дом ?-го класса в г. Сан-Фиерро. Цена: договорная')
end
imgui.Text("")
imgui.Separator() imgui.Text("")
if imgui.Button(u8"Продам дом. Цена в цифрах", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Продам дом ?-го класса в г. Сан-Фиерро. Цена: $')
end
if imgui.Button(u8"Продам дом. Цена договорн.", imgui.ImVec2(190, 22)) then
sampSetCurrentDialogEditboxText('LS | Продам дом ?-го класса в г. Сан-Фиерро. Цена: договорная')
end
imgui.EndChild()
end
-- LS ------------------------------
-- LV ------------------------
elseif selected == 2 then
imgui.SameLine(45) imgui.Text(u8"Выбрано:") imgui.SameLine() imgui.TextColoredRGB("{00FF00}LV (Las-Venturas)")
if imgui.CollapsingHeader(fa.ICON_CAR .. u8" Покупка/продажа Т.С " .. fa.ICON_MOTORCYCLE) then -- не обращать внимания
imgui.BeginChild("2", imgui.ImVec2(-1, 100), true) -- то что будет в колапсе
imgui.Text(u8"ауе ауе")
imgui.EndChild()
end
if imgui.CollapsingHeader(fa.ICON_HOME .. u8" Покупка/продажа домов " .. fa.ICON_HOME) then -- не обращать внимания
imgui.BeginChild("22", imgui.ImVec2(-1, 100), true)
imgui.Text(u8"ауе ауе")
imgui.EndChild()
end
-- LV ---------------------------
-- SF -----------------------------
elseif selected == 3 then
imgui.SameLine(45) imgui.Text(u8"Выбрано:") imgui.SameLine() imgui.TextColoredRGB("{00FF00}SF (San-Fierro)")
if imgui.CollapsingHeader(fa.ICON_CAR .. u8" Покупка/продажа Т.С " .. fa.ICON_MOTORCYCLE) then -- не обращать внимания
imgui.BeginChild("3", imgui.ImVec2(-1, 100), true)
imgui.Text(u8"ауе ауе")
imgui.EndChild()
end
if imgui.CollapsingHeader(fa.ICON_HOME .. u8" Покупка/продажа домов " .. fa.ICON_HOME) then -- не обращать внимания
imgui.BeginChild("33", imgui.ImVec2(-1, 100), true)
imgui.Text(u8"ауе ауе")
imgui.EndChild()
end
end
-- SF ---------------------------
imgui.EndChild()
--imgui.SameLine()
--imgui.BeginChild("Gorod", imgui.ImVec2(185, 60), true)
--imgui.Text(u8"Выберите ваш город")
-- imgui.RadioButton("LS", checked_radio, 1)
-- imgui.RadioButton("LV", checked_radio, 2)
-- imgui.RadioButton("SF", checked_radio, 3)
-- imgui.EndChild()
imgui.End()
end