Advertisement
imring

Untitled

Dec 24th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.06 KB | None | 0 0
  1. script_name('order-this_cold')
  2. script_author('imring')
  3.  
  4. local https = require 'ssl.https'
  5. local imgui = require 'imgui'
  6. local encoding = require 'encoding'
  7. encoding.default = 'CP1251'
  8. local u8 = encoding.UTF8
  9.  
  10. local cID = -1
  11. local cCode = {}
  12. local x, y = getScreenResolution()
  13.  
  14. local requestWanted = imgui.ImBool(false)
  15.  
  16. local function apply_custom_style()
  17.     imgui.SwitchContext()
  18.     local style = imgui.GetStyle()
  19.     local colors = style.Colors
  20.     local clr = imgui.Col
  21.     local ImVec4 = imgui.ImVec4
  22.  
  23.     style.WindowRounding = 2.0
  24.     style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
  25.     style.ChildWindowRounding = 2.0
  26.     style.FrameRounding = 2.0
  27.     style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
  28.     style.ScrollbarSize = 13.0
  29.     style.ScrollbarRounding = 0
  30.     style.GrabMinSize = 8.0
  31.     style.GrabRounding = 1.0
  32.  
  33.     colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
  34.     colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
  35.     colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
  36.     colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
  37.     colors[clr.TitleBgActive]          = ImVec4(0.16, 0.29, 0.48, 1.00)
  38.     colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
  39.     colors[clr.CheckMark]              = ImVec4(0.26, 0.59, 0.98, 1.00)
  40.     colors[clr.SliderGrab]             = ImVec4(0.24, 0.52, 0.88, 1.00)
  41.     colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.59, 0.98, 1.00)
  42.     colors[clr.Button]                 = ImVec4(0.26, 0.59, 0.98, 0.40)
  43.     colors[clr.ButtonHovered]          = ImVec4(0.26, 0.59, 0.98, 1.00)
  44.     colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
  45.     colors[clr.Header]                 = ImVec4(0.26, 0.59, 0.98, 0.31)
  46.     colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
  47.     colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
  48.     colors[clr.Separator]              = colors[clr.Border]
  49.     colors[clr.SeparatorHovered]       = ImVec4(0.26, 0.59, 0.98, 0.78)
  50.     colors[clr.SeparatorActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
  51.     colors[clr.ResizeGrip]             = ImVec4(0.26, 0.59, 0.98, 0.25)
  52.     colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.59, 0.98, 0.67)
  53.     colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.59, 0.98, 0.95)
  54.     colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
  55.     colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
  56.     colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 1.00)
  57.     colors[clr.WindowBg]               = ImVec4(0.06, 0.06, 0.06, 0.94)
  58.     colors[clr.ChildWindowBg]          = ImVec4(1.00, 1.00, 1.00, 0.00)
  59.     colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
  60.     colors[clr.ComboBg]                = colors[clr.PopupBg]
  61.     colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
  62.     colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
  63.     colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
  64.     colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
  65.     colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
  66.     colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
  67.     colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 1.00)
  68.     colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 0.50)
  69.     colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 1.00)
  70.     colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 1.00)
  71.     colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
  72.     colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
  73.     colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
  74.     colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
  75.     colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
  76. end
  77.  
  78. function main()
  79.     while not isSampAvailable() do wait(0) end
  80.     while sampGetGamestate() ~= 3 do wait(0) end
  81.     local ip, port = sampGetCurrentServerAddress()
  82.     if ip .. ':' .. port ~= '176.32.37.62:7777' then script.this:unload() end
  83.     local ccode = https.request('https://pastebin.com/raw/iHnuYRXb')
  84.     ccode = u8:decode(ccode)
  85.     for w in ccode:gmatch('[^\r\n]+') do
  86.         if w:find('^Часть') then
  87.             cCode[#cCode + 1] = { name = w }
  88.         elseif w:find('^Статья') then
  89.             local c = cCode[#cCode]
  90.             c[#c + 1] = w
  91.         end
  92.     end
  93.     sampRegisterChatCommand('su', function(id)
  94.         id = tonumber(id)
  95.         if not id or not sampIsPlayerConnected(id) then return end
  96.         cID = id
  97.         imgui.Process = not imgui.Process
  98.     end)
  99.     wait(-1)
  100. end
  101.  
  102. function imgui.BeforeDrawFrame()
  103.     if not fontChanged then
  104.         fontChanged = true
  105.         local glyph_ranges = imgui.GetIO().Fonts:GetGlyphRangesCyrillic()
  106.         imgui.GetIO().Fonts:Clear()
  107.         imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\arialbd.ttf', 12, nil, glyph_ranges)
  108.         imgui.RebuildFonts()
  109.     end
  110. end
  111.  
  112. apply_custom_style()
  113. function imgui.OnDrawFrame()
  114.     imgui.SetNextWindowPos(imgui.ImVec2(x / 2, y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
  115.     imgui.SetNextWindowSize(imgui.ImVec2(800, 480), imgui.Cond.FirstUseEver)
  116.     imgui.Begin(u8('Умная выдача розыска'))
  117.     for i = 1, #cCode do
  118.         local c = cCode[i]
  119.         if imgui.CollapsingHeader(u8(c.name)) then
  120.             for j = 1, #c do
  121.                 if imgui.Selectable(u8(c[j])) then
  122.                     local wanted = c[j]:match('%| (%d+)$')
  123.                     local article = c[j]:match('^Статья (%d+%.%d+)')
  124.                     if requestWanted.v then sampSendChat('/r Объявите в розыск человека по номеру '..cID..', статья '..article..' '..wanted..' уровень розыска.')
  125.                     else sampSendChat('/su '..cID..' '..wanted..' '..article) end
  126.                     imgui.Process = false
  127.                     cID = -1
  128.                 end
  129.             end
  130.         end
  131.     end
  132.     imgui.End()
  133.  
  134.     imgui.SetNextWindowPos(imgui.ImVec2(x / 1.25, y / 5), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
  135.     imgui.SetNextWindowSize(imgui.ImVec2(270, 25), imgui.Cond.FirstUseEver)
  136.     imgui.Begin(u8('Умная выдача розыска1'), nil, imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoResize)
  137.     imgui.Checkbox(u8('Запрашивать выдачу розыска через рацию'), requestWanted)
  138.     imgui.End()
  139. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement