SlonPvpru

[For All] Invisible MrCreepTon v0.3.4

Jun 4th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.95 KB | None | 0 0
  1. -- https://vk.com/haclourred
  2.  
  3. local event = require('lib.samp.events')
  4. local imgui = require('imgui')
  5. local inicfg = require('inicfg')
  6.  
  7. local encoding = require 'encoding'
  8. encoding.default = 'CP1251'
  9. u8 = encoding.UTF8
  10.  
  11. local i_menu = imgui.ImBool(false)
  12. local i_allert = imgui.ImBool(true)
  13. local i_onfoot = imgui.ImBool(true)
  14. local i_incar = imgui.ImBool(true)
  15. local i_onfoot_glubina = imgui.ImInt(5.0)
  16. local i_incar_glubina = imgui.ImInt(5.0)
  17. local i_autovisota = imgui.ImBool(false)
  18. local i_litespusk = imgui.ImBool(false)
  19.  
  20. local invis_down = false
  21. local invis_state = false
  22. local invis_priv = true
  23.  
  24. function imgui.OnDrawFrame()
  25.     local xw, yw = getScreenResolution()
  26.     if i_menu.v then
  27.         imgui.SetNextWindowSize(imgui.ImVec2(600, 210), imgui.Cond.FirstUseEver)
  28.         imgui.SetNextWindowPos(imgui.ImVec2(xw/2 - 200, yw/2), imgui.Cond.FirstUseEver)
  29.         imgui.Begin(u8'Invisible v0.3.4 | by MrCreepTon', i_menu, imgui.WindowFlags.NoResize)
  30.         imgui.BeginChild('##bar', imgui.ImVec2(300, 175), true)
  31.         imgui.Checkbox(u8'Onfoot невидимка', i_onfoot)
  32.         if i_onfoot.v then
  33.             imgui.SliderInt(u8'Глубина##1', i_onfoot_glubina, 2, 150)
  34.         end
  35.         imgui.Checkbox(u8'Incar невидимка', i_incar)
  36.         if i_incar.v then
  37.             imgui.SliderInt(u8'Глубина##2', i_incar_glubina, 2, 150)
  38.         end
  39.         imgui.Separator()
  40.         if invis_priv == true then
  41.             imgui.TextColoredRGB('Статус привязки: {00DD00}Активировано')
  42.         else
  43.             imgui.TextColoredRGB('Статус привязки: {FF5656}Не активировано')
  44.         end
  45.         imgui.TextColoredRGB('Ваш код: {2CB6DD}'..getserial())
  46.         imgui.TextColoredRGB('ВК разработчика: {2CB6DD}vk.com/haclourred')
  47.         imgui.EndChild()
  48.         imgui.SameLine()
  49.         imgui.BeginChild('##settings', imgui.ImVec2(280, 175), true)
  50.         imgui.Checkbox(u8'Оповещения в чат', i_allert)
  51.         imgui.Checkbox(u8'Автоподбор высоты земли', i_autovisota)
  52.         imgui.Checkbox(u8'Плавный спуск', i_litespusk)
  53.         if invis_down then
  54.             imgui.TextColoredRGB('{FF5656}Внимание! Скрипт опускает вас под землю...')
  55.         else
  56.             imgui.Text(u8'')
  57.         end
  58.         if invis_state then
  59.             if imgui.Button(u8'Выключить инвиз', imgui.ImVec2(-0.1, 20)) then
  60.                 invis()
  61.             end
  62.         else
  63.             if imgui.Button(u8'Включить инвиз', imgui.ImVec2(-0.1, 20)) then
  64.                 invis()
  65.             end
  66.         end
  67.         if imgui.Button(u8'Сохранить настройки', imgui.ImVec2(-0.1, 20)) then
  68.             inicfg.save({
  69.                 settings =
  70.                 {
  71.                     onfoot = i_onfoot.v,
  72.                     incar = i_incar.v,
  73.                     onfoot_glubina = i_onfoot_glubina.v,
  74.                     incar_glubina = i_incar_glubina.v,
  75.                     allert = i_allert.v,
  76.                     autovisota = i_autovisota.v,
  77.                     litespusk = i_litespusk.v
  78.                 }
  79.             }, 'invisible0.3.4')
  80.         end
  81.         if imgui.Button(u8'Сбросить настройки', imgui.ImVec2(-0.1, 20)) then
  82.             inicfg.save({
  83.                 settings =
  84.                 {
  85.                     onfoot = true,
  86.                     incar = true,
  87.                     onfoot_glubina = 5,
  88.                     incar_glubina = 5,
  89.                     allert = true,
  90.                     autovisota = false,
  91.                     litespusk = false
  92.                 }
  93.             }, 'invisible0.3.4')
  94.             i_allert = imgui.ImBool(true)
  95.             i_onfoot = imgui.ImBool(true)
  96.             i_incar = imgui.ImBool(true)
  97.             i_onfoot_glubina = imgui.ImInt(5.0)
  98.             i_incar_glubina = imgui.ImInt(5.0)
  99.             i_autovisota = imgui.ImBool(false)
  100.             i_litespusk = imgui.ImBool(false)
  101.         end
  102.         imgui.EndChild()
  103.         imgui.End()
  104.     end
  105. end
  106.  
  107. function main()
  108.     repeat wait(0) until isSampAvailable()
  109.     repeat wait(0) until invis_priv == true
  110.     local inik = inicfg.load(nil, 'invisible0.3.4')
  111.     if inik == nil then
  112.         inicfg.save({
  113.             settings =
  114.             {
  115.                 onfoot = true,
  116.                 incar = true,
  117.                 onfoot_glubina = 5,
  118.                 incar_glubina = 5,
  119.                 allert = true,
  120.                 autovisota = false,
  121.                 litespusk = false
  122.             }
  123.         }, 'invisible0.3.4')
  124.         sampAddChatMessage('{2CB6DD}[Invisible]: {FFFFFF}INI файл не найден, он автоматически создан!', -1)
  125.     end
  126.     local inik = inicfg.load(nil, 'invisible0.3.4')
  127.     i_onfoot.v = inik.settings.onfoot
  128.     i_incar.v = inik.settings.incar
  129.     i_onfoot_glubina.v = inik.settings.onfoot_glubina
  130.     i_incar_glubina.v = inik.settings.incar_glubina
  131.     i_allert.v = inik.settings.allert
  132.     i_autovisota.v = inik.settings.autovisota
  133.     i_litespusk.v = inik.settings.litespusk
  134.     wait(2000)
  135.     sampRegisterChatCommand('invis', invis)
  136.     sampRegisterChatCommand('invismenu', menu)
  137.     if i_allert.v then
  138.         sampAddChatMessage('{2CB6DD}[Invisible]: {FFFFFF}Загружен!', -1)
  139.         sampAddChatMessage('{2CB6DD}[Invisible]: {FFFFFF}Автор: {2CB6DD}MrCreepTon', -1)
  140.     end
  141.     while true do
  142.         wait(0)
  143.         imgui.Process = i_menu.v
  144.     end
  145. end
  146.  
  147. function menu()
  148.     i_menu.v = not i_menu.v
  149. end
  150.  
  151. function invis()
  152.     if invis_state then
  153.         lua_thread.create(up)
  154.         invis_state = false
  155.     else
  156.         lua_thread.create(down)
  157.         invis_state = true
  158.     end
  159. end
  160.  
  161. function down()
  162.     if isCharOnFoot(PLAYER_PED) then
  163.         local X, Y, Z = getCharCoordinates(PLAYER_PED)
  164.         local Zt = Z - i_onfoot_glubina.v
  165.         local oZ = Z
  166.         invis_down = true
  167.         while Z > Zt do
  168.             Z = Z - 1
  169.             local data = samp_create_sync_data('player')
  170.             data.health = getCharHealth(PLAYER_PED)
  171.             data.armor = getCharArmour(PLAYER_PED)
  172.             data.weapon = getCurrentCharWeapon(PLAYER_PED)
  173.             data.position.x = X
  174.             data.position.y = Y
  175.             data.position.z = Z
  176.             data.send()
  177.             if i_litespusk.v then
  178.                 wait(10)
  179.             end
  180.         end
  181.         invis_down = false
  182.         if i_allert.v then
  183.             sampAddChatMessage('{2CB6DD}[Invisible]: {FFFFFF}Включен!', -1)
  184.         end
  185.     else
  186.         local veh = getCarCharIsUsing(PLAYER_PED)
  187.         local X, Y, Z = getCharCoordinates(PLAYER_PED)
  188.         local Zt = Z - i_incar_glubina.v
  189.         invis_down = true
  190.         while Z > Zt do
  191.             Z = Z - 1
  192.             local data = samp_create_sync_data('vehicle')
  193.             data.vehicleHealth = getCarHealth(veh)
  194.             data.playerHealth = getCharHealth(PLAYER_PED)
  195.             data.armor = getCharArmour(PLAYER_PED)
  196.             data.currentWeapon = getCurrentCharWeapon(PLAYER_PED)
  197.             data.position.x = X
  198.             data.position.y = Y
  199.             data.position.z = Z
  200.             data.send()
  201.             if i_litespusk.v then
  202.                 wait(10)
  203.             end
  204.         end
  205.         invis_down = false
  206.         if i_allert.v then
  207.             sampAddChatMessage('{2CB6DD}[Invisible]: {FFFFFF}Включен!', -1)
  208.         end
  209.     end
  210. end
  211.  
  212. function up()
  213.     if isCharOnFoot(PLAYER_PED) then
  214.         local X, Y, Z = getCharCoordinates(PLAYER_PED)
  215.         local Zt = Z - i_onfoot_glubina.v
  216.         invis_down = true
  217.         while Zt < Z do
  218.             Zt = Zt + 1
  219.             local data = samp_create_sync_data('player')
  220.             data.health = getCharHealth(PLAYER_PED)
  221.             data.armor = getCharArmour(PLAYER_PED)
  222.             data.weapon = getCurrentCharWeapon(PLAYER_PED)
  223.             data.position.x = X
  224.             data.position.y = Y
  225.             data.position.z = Zt
  226.             data.send()
  227.             if i_litespusk.v then
  228.                 wait(10)
  229.             end
  230.         end
  231.         invis_down = false
  232.         if i_allert.v then
  233.             sampAddChatMessage('{2CB6DD}[Invisible]: {FFFFFF}Выключен!', -1)
  234.         end
  235.     else
  236.         local veh = getCarCharIsUsing(PLAYER_PED)
  237.         local X, Y, Z = getCharCoordinates(PLAYER_PED)
  238.         local Zt = Z - i_incar_glubina.v
  239.         invis_down = true
  240.         while Zt < Z do
  241.             Zt = Zt + 1
  242.             local data = samp_create_sync_data('vehicle')
  243.             data.vehicleHealth = getCarHealth(veh)
  244.             data.playerHealth = getCharHealth(PLAYER_PED)
  245.             data.armor = getCharArmour(PLAYER_PED)
  246.             data.currentWeapon = getCurrentCharWeapon(PLAYER_PED)
  247.             data.position.x = X
  248.             data.position.y = Y
  249.             data.position.z = Zt
  250.             data.send()
  251.             if i_litespusk.v then
  252.                 wait(10)
  253.             end
  254.         end
  255.         invis_down = false
  256.         if i_allert.v then
  257.             sampAddChatMessage('{2CB6DD}[Invisible]: {FFFFFF}Выключен!', -1)
  258.         end
  259.     end
  260. end
  261.  
  262. function async_http_request(method, url, args, resolve, reject)
  263.     local request_lane = lanes.gen('*', {package = {path = package.path, cpath = package.cpath}}, function()
  264.         local requests = require 'requests'
  265.         local ok, result = pcall(requests.request, method, url, args)
  266.         if ok then
  267.             result.json, result.xml = nil, nil -- cannot be passed through a lane
  268.             return true, result
  269.         else
  270.             return false, result -- return error
  271.         end
  272.     end)
  273.     if not reject then reject = function() end end
  274.     lua_thread.create(function()
  275.         local lh = request_lane()
  276.         while true do
  277.             local status = lh.status
  278.             if status == 'done' then
  279.                 local ok, result = lh[1], lh[2]
  280.                 if ok then resolve(result) else reject(result) end
  281.                 return
  282.             elseif status == 'error' then
  283.                 return reject(lh[1])
  284.             elseif status == 'killed' or status == 'cancelled' then
  285.                 return reject(status)
  286.             end
  287.             wait(0)
  288.         end
  289.     end)
  290. end
  291.  
  292. function event.onSendPlayerSync(data)
  293.     if invis_down then
  294.         return false
  295.     elseif invis_state and i_onfoot.v then
  296.         local X, Y, Z = getCharCoordinates(PLAYER_PED)
  297.         if i_autovisota.v then
  298.             local Zt = getGroundZFor3dCoord(X, Y, Z + 100)
  299.             data.position.z = Zt - i_onfoot_glubina.v
  300.         else
  301.             data.position.z = Z - i_onfoot_glubina.v
  302.         end
  303.     end
  304. end
  305.  
  306. function event.onPassengerSync(data)
  307.     if invis_state and i_incar.v then
  308.         return false
  309.     end
  310. end
  311.  
  312. function event.onSendVehicleSync(data)
  313.     if invis_down then
  314.         return false
  315.     elseif invis_state and i_incar.v then
  316.         local X, Y, Z = getCharCoordinates(PLAYER_PED)
  317.         if i_autovisota.v then
  318.             local Zt = getGroundZFor3dCoord(X, Y, Z + 100)
  319.             data.position.z = Zt - i_incar_glubina.v
  320.         else
  321.             data.position.z = Z - i_incar_glubina.v
  322.         end
  323.     end
  324. end
  325.  
  326. function getserial()
  327.     local ffi = require("ffi")
  328.     ffi.cdef[[
  329.     int __stdcall GetVolumeInformationA(
  330.     const char* lpRootPathName,
  331.     char* lpVolumeNameBuffer,
  332.     uint32_t nVolumeNameSize,
  333.     uint32_t* lpVolumeSerialNumber,
  334.     uint32_t* lpMaximumComponentLength,
  335.     uint32_t* lpFileSystemFlags,
  336.     char* lpFileSystemNameBuffer,
  337.     uint32_t nFileSystemNameSize
  338.     );
  339.     ]]
  340.     local serial = ffi.new("unsigned long[1]", 0)
  341.     ffi.C.GetVolumeInformationA(nil, nil, 0, serial, nil, nil, nil, 0)
  342.     return serial[0]
  343. end
  344.  
  345. function apply_custom_style()
  346.     imgui.SwitchContext()
  347.     local style = imgui.GetStyle()
  348.     local colors = style.Colors
  349.     local clr = imgui.Col
  350.     local ImVec4 = imgui.ImVec4
  351.  
  352.     style.WindowRounding = 2.0
  353.     style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
  354.     style.ChildWindowRounding = 2.0
  355.     style.FrameRounding = 2.0
  356.     style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
  357.     style.ScrollbarSize = 13.0
  358.     style.ScrollbarRounding = 0
  359.     style.GrabMinSize = 8.0
  360.     style.GrabRounding = 1.0
  361.     -- style.Alpha =
  362.     -- style.WindowPadding =
  363.     -- style.WindowMinSize =
  364.     -- style.FramePadding =
  365.     -- style.ItemInnerSpacing =
  366.     -- style.TouchExtraPadding =
  367.     -- style.IndentSpacing =
  368.     -- style.ColumnsMinSpacing = ?
  369.     -- style.ButtonTextAlign =
  370.     -- style.DisplayWindowPadding =
  371.     -- style.DisplaySafeAreaPadding =
  372.     -- style.AntiAliasedLines =
  373.     -- style.AntiAliasedShapes =
  374.     -- style.CurveTessellationTol =
  375.  
  376.     colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
  377.     colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 1.00)
  378.     colors[clr.WindowBg]               = ImVec4(0.06, 0.06, 0.06, 0.94)
  379.     colors[clr.ChildWindowBg]          = ImVec4(1.00, 1.00, 1.00, 0.00)
  380.     colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
  381.     colors[clr.ComboBg]                = colors[clr.PopupBg]
  382.     colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
  383.     colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
  384.     colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
  385.     colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
  386.     colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
  387.     colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
  388.     colors[clr.TitleBgActive]          = ImVec4(0.16, 0.29, 0.48, 1.00)
  389.     colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
  390.     colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
  391.     colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
  392.     colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
  393.     colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
  394.     colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 1.00)
  395.     colors[clr.CheckMark]              = ImVec4(0.26, 0.59, 0.98, 1.00)
  396.     colors[clr.SliderGrab]             = ImVec4(0.24, 0.52, 0.88, 1.00)
  397.     colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.59, 0.98, 1.00)
  398.     colors[clr.Button]                 = ImVec4(0.26, 0.59, 0.98, 0.40)
  399.     colors[clr.ButtonHovered]          = ImVec4(0.26, 0.59, 0.98, 1.00)
  400.     colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
  401.     colors[clr.Header]                 = ImVec4(0.26, 0.59, 0.98, 0.31)
  402.     colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
  403.     colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
  404.     colors[clr.Separator]              = colors[clr.Border]
  405.     colors[clr.SeparatorHovered]       = ImVec4(0.26, 0.59, 0.98, 0.78)
  406.     colors[clr.SeparatorActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
  407.     colors[clr.ResizeGrip]             = ImVec4(0.26, 0.59, 0.98, 0.25)
  408.     colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.59, 0.98, 0.67)
  409.     colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.59, 0.98, 0.95)
  410.     colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 0.50)
  411.     colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 1.00)
  412.     colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 1.00)
  413.     colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
  414.     colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
  415.     colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
  416.     colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
  417.     colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
  418.     colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
  419. end
  420.  
  421. apply_custom_style()
  422.  
  423.  
  424. function samp_create_sync_data(sync_type, copy_from_player)
  425.     local ffi = require 'ffi'
  426.     local sampfuncs = require 'sampfuncs'
  427.     -- from SAMP.Lua
  428.     local raknet = require 'samp.raknet'
  429.  
  430.     copy_from_player = copy_from_player or true
  431.     local sync_traits = {
  432.         player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData},
  433.         vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData},
  434.         passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData},
  435.         aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData},
  436.         trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData},
  437.         unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil},
  438.         bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil},
  439.         spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil}
  440.     }
  441.     local sync_info = sync_traits[sync_type]
  442.     local data_type = 'struct ' .. sync_info[1]
  443.     local data = ffi.new(data_type, {})
  444.     local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data)))
  445.     -- copy player's sync data to the allocated memory
  446.     if copy_from_player then
  447.         local copy_func = sync_info[3]
  448.         if copy_func then
  449.             local _, player_id
  450.             if copy_from_player == true then
  451.                 _, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
  452.             else
  453.                 player_id = tonumber(copy_from_player)
  454.             end
  455.             copy_func(player_id, raw_data_ptr)
  456.         end
  457.     end
  458.     -- function to send packet
  459.     local func_send = function()
  460.         local bs = raknetNewBitStream()
  461.         raknetBitStreamWriteInt8(bs, sync_info[2])
  462.         raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data))
  463.         raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1)
  464.         raknetDeleteBitStream(bs)
  465.     end
  466.     -- metatable to access sync data and 'send' function
  467.     local mt = {
  468.         __index = function(t, index)
  469.             return data[index]
  470.         end,
  471.         __newindex = function(t, index, value)
  472.             data[index] = value
  473.         end
  474.     }
  475.     return setmetatable({send = func_send}, mt)
  476. end
  477.  
  478. function imgui.TextColoredRGB(text)
  479.     local style = imgui.GetStyle()
  480.     local colors = style.Colors
  481.     local ImVec4 = imgui.ImVec4
  482.  
  483.     local explode_argb = function(argb)
  484.         local a = bit.band(bit.rshift(argb, 24), 0xFF)
  485.         local r = bit.band(bit.rshift(argb, 16), 0xFF)
  486.         local g = bit.band(bit.rshift(argb, 8), 0xFF)
  487.         local b = bit.band(argb, 0xFF)
  488.         return a, r, g, b
  489.     end
  490.  
  491.     local getcolor = function(color)
  492.         if color:sub(1, 6):upper() == 'SSSSSS' then
  493.             local r, g, b = colors[1].x, colors[1].y, colors[1].z
  494.             local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
  495.             return ImVec4(r, g, b, a / 255)
  496.         end
  497.         local color = type(color) == 'string' and tonumber(color, 16) or color
  498.         if type(color) ~= 'number' then return end
  499.         local r, g, b, a = explode_argb(color)
  500.         return imgui.ImColor(r, g, b, a):GetVec4()
  501.     end
  502.  
  503.     local render_text = function(text_)
  504.         for w in text_:gmatch('[^\r\n]+') do
  505.             local text, colors_, m = {}, {}, 1
  506.             w = w:gsub('{(......)}', '{%1FF}')
  507.             while w:find('{........}') do
  508.                 local n, k = w:find('{........}')
  509.                 local color = getcolor(w:sub(n + 1, k - 1))
  510.                 if color then
  511.                     text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
  512.                     colors_[#colors_ + 1] = color
  513.                     m = n
  514.                 end
  515.                 w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
  516.             end
  517.             if text[0] then
  518.                 for i = 0, #text do
  519.                     imgui.TextColored(colors_[i] or colors[1], u8(text[i]))
  520.                     imgui.SameLine(nil, 0)
  521.                 end
  522.                 imgui.NewLine()
  523.             else imgui.Text(u8(w)) end
  524.         end
  525.     end
  526.  
  527.     render_text(text)
  528. end
Add Comment
Please, Sign In to add comment