local imgui = require("imgui")
local sampeb = require('lib.samp.events')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local window = imgui.ImBool(false)
local onall = imgui.ImBool(false)
local rendtall = imgui.ImBool(false)
local triggers = {}
for i = 1, 20 do
triggers[i] = {
text = imgui.ImBuffer(u8'', 256),
render = imgui.ImBool(false),
tracer = imgui.ImBool(false)
}
end
local font = renderCreateFont("Arial", 10, 14)
local inicfg = require 'inicfg'
function main()
while not isSampAvailable() do wait(200) end
sampRegisterChatCommand('3drend', cmd)
imgui.Process = false
window.v = false
while true do
wait(0)
for id = 0, 2048 do
local result = sampIs3dTextDefined(id)
if result then
local text, color, posX, posY, posZ, distance, ignoreWalls, playerId, vehicleId = sampGet3dTextInfoById(id)
if onall.v then
renderText(text, posX, posY, posZ)
else
for i = 1, 20 do
if text:find(u8:decode(triggers[i].text.v)) and triggers[i].render.v then
renderText(text, posX, posY, posZ)
end
end
end
if rendtall.v then
renderTracer(posX, posY, posZ)
else
for i = 1, 20 do
if text:find(u8:decode(triggers[i].text.v)) and triggers[i].tracer.v then
renderTracer(posX, posY, posZ)
end
end
end
end
end
imgui.Process = window.v
end
end
function renderText(text, posX, posY, posZ)
local wposX, wposY = convert3DCoordsToScreen(posX, posY, posZ)
local resX, resY = getScreenResolution()
if wposX < resX and wposY < resY and isPointOnScreen(posX, posY, posZ, 1) then
renderFontDrawText(font, text, wposX, wposY, -1)
end
end
function renderTracer(posX, posY, posZ)
if isPointOnScreen(posX, posY, posZ, 1) then
local wposX, wposY = convert3DCoordsToScreen(posX, posY, posZ)
local x2, y2, z2 = getCharCoordinates(PLAYER_PED)
local x10, y10 = convert3DCoordsToScreen(x2, y2, z2)
renderDrawLine(x10, y10, wposX, wposY, 2.0, 0xFFD00000)
end
end
function imgui.OnDrawFrame()
if window.v then
imgui.SetNextWindowPos(imgui.ImVec2(430.0, 250.0), imgui.Cond.FirstUseEver)
imgui.SetNextWindowSize(imgui.ImVec2(280.0, 300.0), imgui.Cond.FirstUseEver)
imgui.Begin(u8'Рендер на 3д тексты', window)
if imgui.Button(u8'Триггеры') then
tab1 = true
tab2 = false
tab3 = false
end
imgui.SameLine(96, 0)
if imgui.Button(u8'Трейсеры') then
tab2 = true
tab1 = false
tab3 = false
end
imgui.Separator()
if tab1 then
if imgui.Checkbox(u8'Срабатывать на все', onall) then end
if not onall.v then
for i = 1, 20 do
imgui.NewInputText('##' .. i, triggers[i].text, 210, u8'Вводите триггер сюда', 2)
imgui.SameLine(232, 0)
imgui.Checkbox('##' .. i .. 'chck', triggers[i].render)
end
end
end
if tab2 then
imgui.Checkbox(u8'Трейсер на всё', rendtall)
for i = 1, 20 do
local triggerText = triggers[i].text.v == '' and u8('Трейсер на триггер ' .. i) or (u8'Трейсер на ' .. triggers[i].text.v)
imgui.Checkbox(triggerText, triggers[i].tracer)
end
end
imgui.End()
end
end
function cmd()
window.v = not window.v
end
function imgui.NewInputText(label, val, width, hint, hintpos)
local hint = hint or ''
local hintpos = tonumber(hintpos) or 1
local cPos = imgui.GetCursorPos()
imgui.PushItemWidth(width)
local result = imgui.InputText(label, val)
if #val.v == 0 then
local hintSize = imgui.CalcTextSize(hint)
if hintpos == 2 then
imgui.SameLine(cPos.x + (width - hintSize.x) / 2)
elseif hintpos == 3 then
imgui.SameLine(cPos.x + (width - hintSize.x - 5))
else
imgui.SameLine(cPos.x + 5)
end
imgui.TextColored(imgui.ImVec4(1.00, 1.00, 1.00, 0.40), tostring(hint))
end
imgui.PopItemWidth()
return result
end
function cmd()
window.v = not window.v
end
function imgui.NewInputText(lable, val, width, hint, hintpos)
local hint = hint and hint or ''
local hintpos = tonumber(hintpos) and tonumber(hintpos) or 1
local cPos = imgui.GetCursorPos()
imgui.PushItemWidth(width)
local result = imgui.InputText(lable, val)
if #val.v == 0 then
local hintSize = imgui.CalcTextSize(hint)
if hintpos == 2 then imgui.SameLine(cPos.x + (width - hintSize.x) / 2)
elseif hintpos == 3 then imgui.SameLine(cPos.x + (width - hintSize.x - 5))
else imgui.SameLine(cPos.x + 5) end
imgui.TextColored(imgui.ImVec4(1.00, 1.00, 1.00, 0.40), tostring(hint))
end
imgui.PopItemWidth()
return result
end
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
style.WindowPadding = ImVec2(15, 15)
style.WindowRounding = 5.0
style.FramePadding = ImVec2(5, 5)
style.FrameRounding = 4.0
style.ItemSpacing = ImVec2(12, 8)
style.ItemInnerSpacing = ImVec2(8, 6)
style.IndentSpacing = 25.0
style.ScrollbarSize = 15.0
style.ScrollbarRounding = 9.0
style.GrabMinSize = 5.0
style.GrabRounding = 3.0
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.00)
colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
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()