Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.37 KB | None | 0 0
  1. script_name('ImGui Scoreboard')
  2. script_description('ImGui SA:MP Scoreboard')
  3. script_dependencies('SAMPFUNCS', 'Dear ImGui')
  4. script_moonloader(025)
  5.  
  6. require 'moonloader'
  7. require 'SAMPFUNCS'
  8. local imgui = require 'imgui'
  9. local notf
  10. if doesFileExist(getWorkingDirectory() .. "\\imgui_notf.lua") then
  11. notf = import 'imgui_notf.lua'
  12. end
  13. local vkeys = require 'vkeys'
  14. local bitex = require 'bitex'
  15. local SE = require 'lib.samp.events'
  16. local memory = require 'memory'
  17. local encoding = require 'encoding'
  18. local inicfg = require 'inicfg'
  19. u8 = encoding.UTF8
  20. encoding.default = 'CP1251'
  21.  
  22. local russian_characters = {
  23. [168] = 'Ё', [184] = 'ё', [192] = 'А', [193] = 'Б', [194] = 'В', [195] = 'Г', [196] = 'Д', [197] = 'Е', [198] = 'Ж', [199] = 'З', [200] = 'И', [201] = 'Й', [202] = 'К', [203] = 'Л', [204] = 'М', [205] = 'Н', [206] = 'О', [207] = 'П', [208] = 'Р', [209] = 'С', [210] = 'Т', [211] = 'У', [212] = 'Ф', [213] = 'Х', [214] = 'Ц', [215] = 'Ч', [216] = 'Ш', [217] = 'Щ', [218] = 'Ъ', [219] = 'Ы', [220] = 'Ь', [221] = 'Э', [222] = 'Ю', [223] = 'Я', [224] = 'а', [225] = 'б', [226] = 'в', [227] = 'г', [228] = 'д', [229] = 'е', [230] = 'ж', [231] = 'з', [232] = 'и', [233] = 'й', [234] = 'к', [235] = 'л', [236] = 'м', [237] = 'н', [238] = 'о', [239] = 'п', [240] = 'р', [241] = 'с', [242] = 'т', [243] = 'у', [244] = 'ф', [245] = 'х', [246] = 'ц', [247] = 'ч', [248] = 'ш', [249] = 'щ', [250] = 'ъ', [251] = 'ы', [252] = 'ь', [253] = 'э', [254] = 'ю', [255] = 'я',
  24. }
  25. local quitReason = {
  26. "вылетел / краш",
  27. "вышел из игры",
  28. "кикнут / забанен"
  29. }
  30. local themsDir = getWorkingDirectory() .. "\\resource\\scoreboard"
  31. local allset = inicfg.load({
  32. set = {
  33. curTheme = "main",
  34. type = 1,
  35. titlebar = 0,
  36. streamcheck = false,
  37. npcshow = false,
  38. fontSize = 2,
  39. nickType = 0,
  40. list = 0
  41. },
  42. cheat = {
  43. clog = false
  44. }
  45. }, "scoreboard")
  46. local groups = inicfg.load({
  47. friend = {},
  48. admin = {},
  49. enemy = {}
  50. }, "playergroupscoreboard")
  51. if allset.set.fontSize < 0 or allset.set.fontSize > 4 then
  52. allset.set.fontSize = 2
  53. end
  54. local cfg = nil
  55. local copColor = {
  56. [12] = {11},
  57. [6] = {29},
  58. [3] = {5, 19},
  59. [8] = {15},
  60. [23] = {16},
  61. [24] = {17},
  62. [25] = {18}
  63. }
  64. local setTable = {
  65. ["Поле ввода / маркер"] = {
  66. [8] = "Без эффектов",
  67. [9] = "При наведении",
  68. [10] = "При нажатии"
  69. },
  70. ["Список"] = {
  71. [26] = "Без эффектов",
  72. [27] = "При наведении",
  73. [28] = "При нажатии"
  74. },
  75. ["Окно"] = {
  76. [12] = "Заголовок",
  77. [3] = "Фон окна",
  78. [6] = "Разделители",
  79. [1] = "Текст"
  80. },
  81. ["Кнопка"] = {
  82. [23] = "Без эффектов",
  83. [24] = "При наведении",
  84. [25] = "При нажатии"
  85. }
  86. }
  87. local sizesFont = {"12", "13", "14", "15", "16"}
  88. local sFont = {}
  89. local style = imgui.GetStyle()
  90. local colors = style.Colors
  91. local clr = imgui.Col
  92. local ImVec4 = imgui.ImVec4
  93. local background = nil
  94. local bgImage = imgui.ImBool(false)
  95.  
  96. function loadTheme(name)
  97. cfg = inicfg.load({
  98. colors = {
  99. [1] = imgui.ImColor(240, 240, 240, 240):GetU32(),
  100. [3] = imgui.ImColor(3, 3, 0, 230):GetU32(),
  101. [8] = imgui.ImColor(210, 210, 0, 100):GetU32(),
  102. [6] = imgui.ImColor(110, 110, 127, 127):GetU32(),
  103. [9] = imgui.ImColor(210, 210, 0, 140):GetU32(),
  104. [10] = imgui.ImColor(210, 210, 0, 70):GetU32(),
  105. [12] = imgui.ImColor(120, 120, 0, 232):GetU32(),
  106. [23] = imgui.ImColor(180, 180, 0, 163):GetU32(),
  107. [24] = imgui.ImColor(180, 180, 0, 100):GetU32(),
  108. [25] = imgui.ImColor(180, 180, 0, 100):GetU32(),
  109. [26] = imgui.ImColor(160, 160, 160, 60):GetU32(),
  110. [27] = imgui.ImColor(160, 160, 160, 60):GetU32(),
  111. [28] = imgui.ImColor(160, 160, 160, 30):GetU32()
  112. },
  113. set = {
  114. bgimg = false,
  115. imageColor = imgui.ImColor(255, 255, 255, 255):GetU32()
  116. }
  117. }, name and (themsDir .. "\\" .. name .. "\\data.ini") or ("moonloader\\resource\\scoreboard\\main\\data.ini"))
  118. bgImage.v = cfg.set.bgimg
  119. for k, v in pairs(cfg.colors) do
  120. colors[k] = imgui.ImColor(v):GetVec4()
  121. end
  122. for k, v in pairs(copColor) do
  123. for _, iv in ipairs(copColor[k]) do
  124. colors[iv] = colors[k]
  125. end
  126. end
  127. if doesFileExist(name and (themsDir .. "\\" .. name .. "\\scoreboard.png") or ("moonloader\\resource\\scoreboard\\main\\scoreboard.png")) then
  128. background = imgui.CreateTextureFromFile(name and (themsDir .. "\\" .. name .. "\\scoreboard.png") or ("moonloader\\resource\\scoreboard\\main\\scoreboard.png"))
  129. else
  130. background = nil
  131. end
  132. end
  133.  
  134. local ToScreen = convertGameScreenCoordsToWindowScreenCoords
  135. local show_main_window = imgui.ImBool(false)
  136. local show_set_window = imgui.ImBool(false)
  137. local searchBuf = imgui.ImBuffer(256)
  138. local createThemBuf = imgui.ImBuffer(32)
  139. local playerCount = 0
  140. local streamCheck = imgui.ImBool(allset.set.streamcheck)
  141. local cStyle = imgui.ImInt(0)
  142. local cType = imgui.ImInt(allset.set.type)
  143. local bTitlebar = imgui.ImInt(allset.set.titlebar)
  144. local cSize = imgui.ImInt(allset.set.fontSize)
  145. local cNType = imgui.ImInt(allset.set.nickType)
  146. local bNpcShow = imgui.ImBool(allset.set.npcshow)
  147. local bConnectLog = imgui.ImBool(allset.cheat.clog)
  148. local logConFilter = imgui.ImBuffer(128)
  149. local ScrollToButton = false
  150. local logConnect = {}
  151. local thems = {}
  152. local themsId = {}
  153. local notThems = false
  154. local focusId = -1
  155. local scrollToId = false
  156. local gameInit = false
  157. local pMarker = {}
  158. local bMarkPlayer = imgui.ImBool(false)
  159. local mColor = {}
  160. local cFilter = imgui.ImInt(allset.set.list)
  161. local cSetGroup = imgui.ImInt(0)
  162. loadTheme(allset.set.curTheme)
  163. bgImage.v = cfg.set.bgimg
  164. if not doesDirectoryExist("moonloader\\resource") then
  165. createDirectory("moonloader\\resource")
  166. end
  167. if not doesDirectoryExist("moonloader\\resource\\scoreboard") then
  168. createDirectory("moonloader\\resource\\scoreboard")
  169. end
  170. do
  171. function apply_custom_style()
  172. local style = imgui.GetStyle()
  173. local colors = style.Colors
  174. local clr = imgui.Col
  175. local ImVec4 = imgui.ImVec4
  176. style.WindowRounding = 1.5
  177. style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
  178. style.ChildWindowRounding = 1.5
  179. style.FrameRounding = 1.0
  180. style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
  181. style.ScrollbarSize = 13.0
  182. style.ScrollbarRounding = 0
  183. style.GrabMinSize = 8.0
  184. style.GrabRounding = 1.0
  185. -- style.Alpha =
  186. style.WindowPadding = imgui.ImVec2(0.0, 0.0)
  187. -- style.WindowMinSize =
  188. style.FramePadding = imgui.ImVec2(2.5, 3.5)
  189. -- style.ItemInnerSpacing =
  190. -- style.TouchExtraPadding =
  191. -- style.IndentSpacing =
  192. -- style.ColumnsMinSpacing = ?
  193. style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
  194. -- style.DisplayWindowPadding =
  195. -- style.DisplaySafeAreaPadding =
  196. -- style.AntiAliasedLines =
  197. -- style.AntiAliasedShapes =
  198. -- style.CurveTessellationTol =
  199. colors[clr.TextDisabled] = ImVec4(0.50, 0.50, 0.50, 1.00)
  200. colors[clr.ChildWindowBg] = ImVec4(1.00, 1.00, 1.00, 0.00)
  201. -- colors[clr.PopupBg] = ImVec4(0.04, 0.04, 0.04, 0.9)
  202. -- print(clr.ScrollbarGrab)
  203. -- print(clr.Header)
  204. colors[clr.ComboBg] = colors[clr.PopupBg]
  205. -- colors[clr.Border] = ImVec4(0.43, 0.43, 0.50, 0.50)
  206. colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
  207. colors[clr.TitleBgCollapsed] = ImVec4(0.05, 0.05, 0.05, 0.79)
  208. colors[clr.MenuBarBg] = ImVec4(0.14, 0.14, 0.14, 1.00)
  209. -- colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.53)
  210. -- colors[clr.ScrollbarGrab] = ImVec4(0.31, 0.31, 0.31, 1.00)
  211. -- colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.41, 0.41, 1.00)
  212. -- colors[clr.ScrollbarGrabActive] = ImVec4(0.51, 0.51, 0.51, 1.00)
  213. colors[clr.CheckMark] = ImVec4(1.00, 1.00, 1.00, 1.00)
  214. colors[clr.SliderGrab] = ImVec4(0.28, 0.28, 0.28, 1.00)
  215. colors[clr.SliderGrabActive] = ImVec4(0.35, 0.35, 0.35, 1.00)
  216. -- colors[clr.Header] = ImVec4(0.12, 0.12, 0.12, 0.94)
  217. -- colors[clr.HeaderHovered] = ImVec4(0.25, 0.25, 0.25, 0.2)
  218. -- colors[clr.HeaderActive] = ImVec4(0.16, 0.16, 0.16, 0.90)
  219. -- colors[clr.Separator] = colors[clr.Border]
  220. colors[clr.SeparatorHovered] = ImVec4(0.26, 0.59, 0.98, 0.78)
  221. colors[clr.SeparatorActive] = ImVec4(0.26, 0.59, 0.98, 1.00)
  222. colors[clr.ResizeGrip] = ImVec4(0.26, 0.59, 0.98, 0.25)
  223. colors[clr.ResizeGripHovered] = ImVec4(0.26, 0.59, 0.98, 0.67)
  224. colors[clr.ResizeGripActive] = ImVec4(0.26, 0.59, 0.98, 0.95)
  225. colors[clr.CloseButton] = ImVec4(0.41, 0.41, 0.41, 0.50)
  226. colors[clr.CloseButtonHovered] = ImVec4(0.98, 0.39, 0.36, 1.00)
  227. colors[clr.CloseButtonActive] = ImVec4(0.98, 0.39, 0.36, 1.00)
  228. colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00)
  229. colors[clr.PlotLinesHovered] = ImVec4(1.00, 0.43, 0.35, 1.00)
  230. colors[clr.PlotHistogram] = ImVec4(0.90, 0.70, 0.00, 1.00)
  231. colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
  232. colors[clr.TextSelectedBg] = ImVec4(0.26, 0.59, 0.98, 0.35)
  233. colors[clr.ModalWindowDarkening] = ImVec4(0.10, 0.10, 0.10, 0.35)
  234. -- colors[clr.WindowBg] = imgui.ImColor(3, 3, 0, 230):GetVec4()
  235. -- colors[clr.FrameBg] = imgui.ImColor(210, 210, 0, 100):GetVec4()
  236. -- colors[clr.FrameBgHovered] = imgui.ImColor(210, 210, 0, 140):GetVec4()
  237. -- colors[clr.FrameBgActive] = imgui.ImColor(210, 210, 0, 70):GetVec4()
  238. -- colors[clr.TitleBg] = imgui.ImColor(120, 120, 0, 232):GetVec4()
  239. -- colors[clr.TitleBgActive] = imgui.ImColor(120, 120, 0, 232):GetVec4()
  240. -- colors[clr.Button] = imgui.ImColor(180, 180, 0, 163):GetVec4()
  241. -- colors[clr.ButtonHovered] = imgui.ImColor(180, 180, 0, 100):GetVec4()
  242. -- colors[clr.ButtonActive] = imgui.ImColor(100, 100, 0, 100):GetVec4()
  243. end
  244. apply_custom_style()
  245. end
  246. function main()
  247. if not isSampfuncsLoaded() or not isSampLoaded() then return end
  248. while not isSampAvailable() do wait(0) end
  249.  
  250. local h, n = findFirstFile('moonloader\\resource\\scoreboard\\*')
  251. local i = 1
  252. while true do
  253. wait(0)
  254. if h then
  255. if n then
  256. if doesDirectoryExist("moonloader\\resource\\scoreboard\\" .. n) and n ~= "." and n ~= ".." then
  257. table.insert(thems, n)
  258. themsId[tostring(n)] = i
  259. if allset.set.curTheme == n then
  260. cStyle.v = i - 1
  261. end
  262. i = i + 1
  263. end
  264. n = findNextFile(h)
  265. else
  266. findClose(h)
  267. if #thems == 0 then
  268. thems[1] = "main"
  269. themsId["main"] = 1
  270. notThems = true
  271. loadTheme()
  272. end
  273. end
  274. end
  275. imgui.Process = show_main_window.v
  276. if wasKeyPressed(VK_TAB) and not isPauseMenuActive() then
  277. if not show_main_window.v then
  278. if not sampIsChatInputActive() then
  279. toggleScoreboard(true)
  280. end
  281. else
  282. toggleScoreboard(false)
  283. end
  284. end
  285. for k, v in pairs(pMarker) do
  286. local result, ped = sampGetCharHandleBySampPlayerId(k)
  287. if result then
  288. local color = sampGetPlayerColor(k)
  289. if doesBlipExist(pMarker[k]) then
  290. if mColor[v] ~= color then
  291. removeBlip(v)
  292. pMarker[k] = addBlipForChar(ped)
  293. mColor[pMarker[k]] = color
  294. changeBlipColour(pMarker[k], alpha255(color))
  295. changeBlipDisplay(pMarker[k], 3)
  296. setBlipAlwaysDisplayOnZoomedRadar(pMarker[k], true)
  297. end
  298. else
  299. pMarker[k] = addBlipForChar(ped)
  300. mColor[pMarker[k]] = color
  301. changeBlipColour(pMarker[k], alpha255(color))
  302. changeBlipDisplay(pMarker[k], 3)
  303. setBlipAlwaysDisplayOnZoomedRadar(pMarker[k], true)
  304. end
  305. end
  306. end
  307. end
  308. end
  309.  
  310. function toggleScoreboard(flag)
  311. if type(flag) == 'boolean' then
  312. show_main_window.v = flag
  313. else
  314. show_main_window.v = not show_main_window.v
  315. end
  316. if show_main_window.v then
  317. if focusId > -1 then
  318. scrollToId = true
  319. end
  320. if bConnectLog.v then
  321. ScrollToButton = true
  322. end
  323. end
  324. end
  325.  
  326. function getLocalPlayerId()
  327. local _, id = sampGetPlayerIdByCharHandle(playerPed)
  328. return id
  329. end
  330.  
  331. function onWindowMessage(msg, wparam, lparam)
  332. if(msg == 0x100 or msg == 0x101) then
  333. if wparam == VK_TAB then
  334. consumeWindowMessage(true, false)
  335. end
  336. if(wparam == VK_ESCAPE and show_main_window.v) and not isPauseMenuActive() then
  337. consumeWindowMessage(true, false)
  338. if(msg == 0x101)then
  339. toggleScoreboard(false)
  340. end
  341. end
  342. end
  343. end
  344.  
  345.  
  346. local glyph_ranges = nil
  347. function imgui.BeforeDrawFrame()
  348. if not fontChanged then
  349. fontChanged = true
  350. glyph_ranges = imgui.GetIO().Fonts:GetGlyphRangesCyrillic()
  351. imgui.GetIO().Fonts:Clear()
  352. imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\arialbd.ttf', 14, nil, glyph_ranges)
  353. for _, v in ipairs(sizesFont) do
  354. sFont[tonumber(v)] = imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\arialbd.ttf', tonumber(v), nil, glyph_ranges)
  355. end
  356. imgui.RebuildFonts()
  357. end
  358. end
  359. function imgui.OnDrawFrame()
  360. -- notf.onRenderNotification()
  361. if show_main_window.v then
  362. if show_set_window.v then
  363. local x, y = ToScreen(510, 30)
  364. local w, h = ToScreen(638, 175)
  365. imgui.PushStyleVar(imgui.StyleVar.WindowPadding, imgui.ImVec2(4.0, 4.0))
  366. imgui.SetNextWindowPos(imgui.ImVec2(w-220, y), imgui.Cond.FirstUseEver, imgui.ImVec2(0.0, 0.0))
  367. imgui.SetNextWindowSize(imgui.ImVec2(220, 270), imgui.Cond.FirstUseEver)
  368. imgui.Begin(u8'Настройки', show_set_window, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoScrollbar + imgui.WindowFlags.AlwaysAutoResize)
  369. imgui.Separator()
  370. imgui.AlignTextToFramePadding()
  371. imgui.Text(u8"Тема:")
  372. imgui.SameLine()
  373. imgui.PushItemWidth(113)
  374. local rThems = {}
  375. for k, v in ipairs(thems) do
  376. rThems[k] = u8(v)
  377. end
  378. if imgui.Combo("##thems", cStyle, rThems) and #thems > 0 then
  379. if notThems then
  380. inicfg.save(cfg, "..\\resource\\scoreboard\\main\\data.ini")
  381. notThems = false
  382. else
  383. inicfg.save(cfg, "..\\resource\\scoreboard\\" .. allset.set.curTheme .. "\\data.ini")
  384. end
  385. allset.set.curTheme = thems[cStyle.v + 1]
  386. inicfg.save(allset, "scoreboard")
  387. loadTheme(allset.set.curTheme)
  388. end
  389. imgui.PopItemWidth()
  390. imgui.SameLine()
  391. if imgui.Button(u8"Создать") then
  392. imgui.OpenPopup(u8"Создать тему")
  393. end
  394. if imgui.BeginPopupModal(u8"Создать тему", _, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove) then
  395. imgui.Text(u8"Введите назване:")
  396. imgui.InputText("##createThemBuf", createThemBuf, imgui.InputTextFlags.CharsNoBlank)
  397. if imgui.Button(u8"Продолжить", imgui.ImVec2(100, 0)) then
  398. imgui.CloseCurrentPopup()
  399. if createThemBuf.v:len() > 0 and themsId[tostring(u8:decode(createThemBuf.v))] == nil then
  400. createDirectory(themsDir .. "\\" .. u8:decode(createThemBuf.v))
  401. themsId[tostring(u8:decode(createThemBuf.v))] = #themsId
  402. thems[#thems+1] = u8:decode(createThemBuf.v)
  403. end
  404. end
  405. imgui.SameLine()
  406. if imgui.Button(u8"Закрыть", imgui.ImVec2(100, 0)) then
  407. imgui.CloseCurrentPopup()
  408. end
  409. imgui.EndPopup()
  410. end
  411. imgui.Separator()
  412. if imgui.CollapsingHeader(u8"Общие настройки") then
  413. imgui.AlignTextToFramePadding()
  414. imgui.Text(u8"Размер окна:")
  415. imgui.SameLine()
  416. imgui.PushItemWidth(127)
  417. if imgui.Combo("##type", cType, {u8"Маленький", u8"Средний", u8"Большой", u8"На весь экран"}) and #thems > 0 then
  418. allset.set.type = cType.v
  419. end
  420. imgui.Separator()
  421. imgui.AlignTextToFramePadding()
  422. imgui.Text(u8"Заголовок:")
  423. imgui.SameLine()
  424. imgui.PushItemWidth(139)
  425. if imgui.Combo("##header", bTitlebar, {u8"Стандарт", u8"Только текст", u8"Скрыть"}) then
  426. allset.set.titlebar = bTitlebar.v
  427. end
  428. imgui.Separator()
  429. imgui.AlignTextToFramePadding()
  430. imgui.Text(u8"Размер текста:")
  431. imgui.SameLine()
  432. imgui.PushItemWidth(116)
  433. if imgui.Combo("##size", cSize, sizesFont) then
  434. allset.set.fontSize = cSize.v
  435. end
  436. imgui.Separator()
  437. imgui.AlignTextToFramePadding()
  438. imgui.Text(u8"Ники игроков:")
  439. imgui.SameLine()
  440. imgui.PushItemWidth(120)
  441. if imgui.Combo("##ntype", cNType, {u8"Стандарт", u8"Цвет отдельно", u8"Без цвета"}) then
  442. allset.set.nickType = cNType.v
  443. end
  444. end
  445. imgui.Separator()
  446. if imgui.CollapsingHeader(u8"Изображение") then
  447. if imgui.Checkbox(u8"Показывать изображение", bgImage) then
  448. cfg.set.bgimg = bgImage.v
  449. end
  450. local color = imgui.ImFloat4(imgui.ImColor(cfg.set.imageColor):GetFloat4())
  451. imgui.AlignTextToFramePadding()
  452. if bgImage.v then imgui.Text(u8("Изображение")) else imgui.TextDisabled(u8"Изображение") end
  453. imgui.SameLine(195)
  454. if imgui.ColorEdit4("##imageColor", color, imgui.ColorEditFlags.NoInputs + imgui.ColorEditFlags.NoLabel + imgui.ColorEditFlags.AlphaBar) then
  455. cfg.set.imageColor = imgui.ImColor.FromFloat4(color.v[1], color.v[2], color.v[3], color.v[4]):GetU32()
  456. end
  457. end
  458. for k, v in pairs(setTable) do
  459. if imgui.CollapsingHeader(u8(k)) then
  460. for sk, sv in pairs(v) do
  461. -- local color = imgui.ImColor(cfg.colors[sk])
  462. local color = imgui.ImFloat4(imgui.ImColor(cfg.colors[sk]):GetFloat4())
  463. imgui.AlignTextToFramePadding()
  464. imgui.Text(u8(sv))
  465. imgui.SameLine(195)
  466. if imgui.ColorEdit4("##" .. sk, color, imgui.ColorEditFlags.NoInputs + imgui.ColorEditFlags.NoLabel + imgui.ColorEditFlags.AlphaBar) then
  467. local newColor = imgui.ImColor.FromFloat4(color.v[1], color.v[2], color.v[3], color.v[4]):GetVec4()
  468. cfg.colors[sk] = imgui.ImColor(newColor):GetU32()
  469. colors[sk] = newColor
  470. if copColor[sk] then
  471. for _, iv in ipairs(copColor[sk]) do
  472. colors[iv] = newColor
  473. end
  474. end
  475. end
  476. end
  477. end
  478. end
  479. imgui.Separator()
  480. if imgui.Checkbox(u8"Журнал подключений",) then
  481. allset.cheat.clog = bConnectLog.v
  482. end
  483. if imgui.Checkbox(u8"Показывать NPC", bNpcShow) then
  484. allset.set.npcshow = bNpcShow.v
  485. end
  486. imgui.Separator()
  487. if imgui.Button(u8"Сохранить изменения", imgui.ImVec2(212, 0)) then
  488. if notThems then
  489. inicfg.save(cfg, "..\\resource\\scoreboard\\main\\data.ini")
  490. notThems = false
  491. else
  492. inicfg.save(cfg, "..\\resource\\scoreboard\\" .. allset.set.curTheme .. "\\data.ini")
  493. end
  494. inicfg.save(allset, "scoreboard")
  495. if notf then
  496. notf.addNotification("Настройки успешно сохранены", 5)
  497. end
  498. end
  499. imgui.End()
  500. imgui.PopStyleVar()
  501. end
  502. playerCount = 0
  503. local xOffset = 0
  504. if bConnectLog.v then
  505. local x, y = ToScreen(0, 0)
  506. local w, h = ToScreen(180, 448)
  507. xOffset = w-x
  508. imgui.PushStyleVar(imgui.StyleVar.WindowPadding, imgui.ImVec2(4.0, 4.0))
  509. imgui.SetNextWindowPos(imgui.ImVec2(x, y), imgui.Cond.FirstUseEver)
  510. imgui.SetNextWindowSize(imgui.ImVec2(w-x, h), imgui.Cond.FirstUseEver)
  511. imgui.Begin(u8"##connectLogBar", _, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove + imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoScrollWithMouse + imgui.WindowFlags.NoScrollbar + imgui.WindowFlags.NoBringToFrontOnFocus)
  512. imgui.SetWindowFontScale(1.05)
  513. imgui.AlignTextToFramePadding()
  514. imgui.Text(u8"Журнал подключений:")
  515. imgui.SetWindowFontScale(1.0)
  516. imgui.SameLine(w-x-153)
  517. imgui.PushItemWidth(150)
  518. imgui.InputText("##logConFilter", logConFilter)
  519. if not imgui.IsItemActive() and logConFilter.v:len() == 0 then
  520. local r, g, b, a = imgui.ImColor(colors[1]):GetRGBA()
  521. imgui.SameLine(w-x-150)
  522. imgui.TextColored(imgui.ImColor(r, g, b, 180):GetVec4(), u8"Поиск по журналу")
  523. end
  524. imgui.PopItemWidth()
  525. imgui.Separator()
  526. local _, hb = ToScreen(_, 428)
  527. imgui.BeginChild("##connectLog", imgui.ImVec2(w-x-4, hb))
  528. imgui.PushStyleVar(imgui.StyleVar.ItemSpacing, imgui.ImVec2(1, 2))
  529. if #logConnect > 0 then
  530. local fCount = 0
  531. local viewLog = {}
  532. for k, v in ipairs(logConnect) do
  533. if logConFilter.v:len() > 0 then
  534. if string.find(string.rlower(v), string.rlower(u8:decode(logConFilter.v)), 1, true) then
  535. table.insert(viewLog, v)
  536. fCount = fCount + 1
  537. end
  538. else
  539. table.insert(viewLog, v)
  540. end
  541. end
  542. local clipper = imgui.ImGuiListClipper(#viewLog)
  543. while clipper:Step() do
  544. for i = clipper.DisplayStart + 1, clipper.DisplayEnd do
  545. imgui.Text(u8(viewLog[i]))
  546. if (imgui.IsItemClicked(0) or imgui.IsItemClicked(1)) and (logConFilter.v:len() == 0 or fCount > 0) then
  547. setClipboardText(viewLog[i])
  548. end
  549. end
  550. end
  551. if logConFilter.v:len() > 0 and fCount == 0 then
  552. imgui.Text(u8"Совпадения не найдены ...")
  553. end
  554. else
  555. imgui.Text(u8"Журнал пуст ...")
  556. end
  557. if ScrollToButton then
  558. imgui.SetScrollHere()
  559. ScrollToButton = false
  560. end
  561. imgui.PopStyleVar()
  562. imgui.EndChild()
  563. imgui.End()
  564. imgui.PopStyleVar()
  565. end
  566. if allset.set.type == 0 then
  567. x, y = ToScreen(160, 90)
  568. w, h = ToScreen(480, 358)
  569. if bConnectLog.v then
  570. x = x + xOffset / 2
  571. w = w + xOffset / 2
  572. end
  573. elseif allset.set.type == 1 then
  574. x, y = ToScreen(130, 60)
  575. w, h = ToScreen(510, 388)
  576. if bConnectLog.v then
  577. x = x + xOffset / 2
  578. w = w + xOffset / 2
  579. end
  580. elseif allset.set.type == 2 then
  581. x, y = ToScreen(100, 30)
  582. w, h = ToScreen(540, 418)
  583. if bConnectLog.v then
  584. x = x + xOffset / 2
  585. w = w + xOffset / 2
  586. end
  587. elseif allset.set.type == 3 then
  588. if bConnectLog.v then
  589. x, y = ToScreen(181, 0)
  590. w, h = ToScreen(640, 448)
  591. else
  592. x, y = ToScreen(0, 0)
  593. w, h = ToScreen(640, 448)
  594. end
  595. end
  596. imgui.SetNextWindowPos(imgui.ImVec2(x, y), _, imgui.ImVec2(0.0, 0.0))
  597. imgui.SetNextWindowSize(imgui.ImVec2(w-x , h-y))
  598. local servername = u8(sampGetCurrentServerName())
  599. imgui.PushFont(sFont[tonumber(sizesFont[allset.set.fontSize + 1])])
  600. imgui.Begin(servername, show_main_window, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove + imgui.WindowFlags.NoBringToFrontOnFocus + imgui.WindowFlags.NoScrollWithMouse + imgui.WindowFlags.NoScrollbar + (bTitlebar.v > 0 and imgui.WindowFlags.NoTitleBar or 0))
  601.  
  602. if background and bgImage.v then
  603. local size = imgui.GetWindowSize()
  604. local bColor = cfg.set.imageColor
  605. imgui.Image(background, imgui.ImVec2(size.x , size.y-(bTitlebar.v == 0 and 21 or 0)), imgui.ImVec2(0, 0), imgui.ImVec2(1, 1), imgui.ImColor(bColor):GetVec4())
  606. end
  607. local snSize
  608. if bTitlebar.v == 1 then
  609. snSize = imgui.CalcTextSize(servername)
  610. end
  611. imgui.SetCursorPos(imgui.ImVec2(bTitlebar.v == 1 and ((w-x) / 2) - (snSize.x / 2) or 6, bTitlebar.v == 0 and 24 or 3))
  612. if bTitlebar.v == 1 then
  613. imgui.Text(servername)
  614. imgui.Separator()
  615. end
  616. imgui.AlignTextToFramePadding()
  617. imgui.Indent(4); imgui.Text(u8('Всего: ' .. sampGetPlayerCount(false) .. ' | Рядом: ' .. sampGetPlayerCount(true)-1))
  618. local bText = u8"Настройки"
  619. local sText = u8"Поиск игроков"
  620. local stText = u8"В зоне стрима"
  621. local bSize = imgui.CalcTextSize(bText)
  622. local sSize = imgui.CalcTextSize(sText)
  623. local stSize = imgui.CalcTextSize(stText)
  624. local cColumns = 4
  625. if streamCheck.v then
  626. cColumns = cColumns + 2
  627. end
  628. if cNType.v == 1 then
  629. cColumns = cColumns + 1
  630. end
  631. if cFilter.v > 0 then
  632. cColumns = cColumns + 1
  633. end
  634. -- Search
  635. imgui.SameLine(w-x-155)
  636. imgui.PushItemWidth(150)
  637. imgui.PushAllowKeyboardFocus(false)
  638. imgui.InputText("##search", searchBuf, imgui.InputTextFlags.EnterReturnsTrue + imgui.InputTextFlags.CharsNoBlank)
  639. local iSize = imgui.GetItemRectSize()
  640. imgui.PopAllowKeyboardFocus()
  641. imgui.PopItemWidth()
  642. if not imgui.IsItemActive() and #searchBuf.v == 0 then
  643. local r, g, b, a = imgui.ImColor(colors[1]):GetRGBA()
  644. imgui.SameLine(w-x-153)
  645. imgui.PushStyleColor(imgui.Col.Text, imgui.ImColor(r, g, b, 180):GetVec4())
  646. imgui.Text(sText)
  647. imgui.PopStyleColor()
  648. end
  649. -- Button
  650. imgui.SameLine(w-x-(bSize.x + 155 + 9))
  651. if imgui.Button(bText) then
  652. show_set_window.v = not show_set_window.v
  653. end
  654. -- Combo
  655. imgui.SameLine(w-x-(bSize.x + 155 + 115 + 9))
  656. imgui.PushItemWidth(110)
  657. if imgui.Combo("##PlayerListFilter", cFilter, {u8"Без групп", u8"Все игроки", u8"Друзья", u8"Админы", u8"Враги", u8"С маркером"}) then
  658. allset.set.list = cFilter.v
  659. end
  660. imgui.PopItemWidth()
  661. -- Checkbox
  662. imgui.SameLine(w-x-(stSize.x + bSize.x + 155 + 115 + 9 + 30))
  663. if imgui.Checkbox(stText, streamCheck) then
  664. allset.set.streamcheck = streamCheck.v
  665. end
  666.  
  667. imgui.Columns(cColumns)
  668. imgui.Separator()
  669. imgui.NewLine()
  670. imgui.SameLine(2)
  671. imgui.SetColumnWidth(-1, 32); imgui.Text('ID'); imgui.NextColumn()
  672. imgui.SetColumnWidth(-1, w-x-(streamCheck.v and 280 or 160)-(cFilter.v > 0 and 70 or 0)-(cNType.v == 1 and 90 or 0)); imgui.Text(u8'Никнейм'); imgui.NextColumn()
  673. if cFilter.v > 0 then
  674. imgui.SetColumnWidth(-1, 70); imgui.Text(u8'Группа'); imgui.NextColumn()
  675. end
  676. if streamCheck.v then
  677. imgui.SetColumnWidth(-1, 40); imgui.Text(u8'Афк'); imgui.NextColumn()
  678. imgui.SetColumnWidth(-1, 80); imgui.Text(u8'Дистанция'); imgui.NextColumn()
  679. end
  680. if cNType.v == 1 then
  681. imgui.SetColumnWidth(-1, 90); imgui.Text(u8'Цвет'); imgui.NextColumn()
  682. end
  683. imgui.SetColumnWidth(-1, 70); imgui.Text(u8'Счет'); imgui.NextColumn()
  684. imgui.SetColumnWidth(-1, 70); imgui.Text(u8'Пинг'); imgui.NextColumn()
  685. imgui.Columns(1)
  686. imgui.Separator()
  687. imgui.BeginChild("##scroll", imgui.ImVec2(0, 0), false)
  688. imgui.Columns(cColumns)
  689. imgui.SetColumnWidth(-1, 32);imgui.NextColumn()
  690. imgui.SetColumnWidth(-1, w-x-(streamCheck.v and 280 or 160)-(cFilter.v > 0 and 70 or 0)-(cNType.v == 1 and 70 or 0)); imgui.NextColumn()
  691. if cFilter.v > 0 then
  692. imgui.SetColumnWidth(-1, 70); imgui.NextColumn()
  693. end
  694. if streamCheck.v then
  695. imgui.SetColumnWidth(-1, 40); imgui.NextColumn()
  696. imgui.SetColumnWidth(-1, 80); imgui.NextColumn()
  697. end
  698. if cNType.v == 1 then
  699. imgui.SetColumnWidth(-1, 90); imgui.NextColumn()
  700. end
  701. imgui.SetColumnWidth(-1, 70);imgui.NextColumn()
  702. imgui.SetColumnWidth(-1, 70); imgui.NextColumn()
  703. local local_player_id = getLocalPlayerId()
  704. if(#searchBuf.v < 1 and not streamCheck.v and cFilter.v < 2) then
  705. drawScoreboardPlayer(local_player_id)
  706. else
  707. if (string.find(sampGetPlayerNickname(local_player_id):lower(), searchBuf.v:lower(), 1, true) or local_player_id == tonumber(searchBuf.v)) and not streamCheck.v and cFilter.v < 2 then
  708. drawScoreboardPlayer(local_player_id)
  709. end
  710. end
  711. local viewPlayers = {}
  712. for i = 0, sampGetMaxPlayerId(false) do
  713. if local_player_id ~= i and sampIsPlayerConnected(i) and (not bNpcShow.v and not sampIsPlayerNpc(i) or bNpcShow.v) then
  714. local isInStream = sampGetCharHandleBySampPlayerId(i)
  715. if(#searchBuf.v > 0) then
  716. if(string.find(sampGetPlayerNickname(i):lower(), searchBuf.v:lower(), 1, true) or i == tonumber(searchBuf.v))then
  717. if not streamCheck.v or (streamCheck.v and isInStream) then
  718. local nickname = encoding.UTF8(sampGetPlayerNickname(i))
  719. local group, gId = getPlayerSGroup(nickname)
  720. if not ((cFilter.v > 1 and cFilter.v < 5 and gId ~= cFilter.v - 1) or (cFilter.v == 5 and pMarker[i] == nil)) then
  721. table.insert(viewPlayers, i)
  722. end
  723. end
  724. end
  725. else
  726. if not streamCheck.v or (streamCheck.v and isInStream) then
  727. local nickname = encoding.UTF8(sampGetPlayerNickname(i))
  728. local group, gId = getPlayerSGroup(nickname)
  729. if not ((cFilter.v > 1 and cFilter.v < 5 and gId ~= cFilter.v - 1) or (cFilter.v == 5 and pMarker[i] == nil)) then
  730. table.insert(viewPlayers, i)
  731. end
  732. end
  733. end
  734. end
  735. end
  736. if #viewPlayers > 0 then
  737. local clipper = imgui.ImGuiListClipper(#viewPlayers)
  738. while clipper:Step() do
  739. for i = clipper.DisplayStart + 1, clipper.DisplayEnd do
  740. drawScoreboardPlayer(viewPlayers[i])
  741. end
  742. end
  743. end
  744.  
  745. imgui.Columns(1)
  746. if(playerCount == 0)then
  747. imgui.SameLine(5.0); imgui.Text(u8"Список пуст ...")
  748. end
  749. imgui.Separator()
  750. imgui.EndChild()
  751.  
  752. imgui.End()
  753. imgui.PopFont()
  754. end
  755. end
  756.  
  757. function getPlayerSGroup(name)
  758. local name = tostring(name)
  759. if #name < 1 then
  760. return nil
  761. end
  762. local group, groupId = nil, 0
  763. if groups.friend[name] then
  764. group = "Друг"
  765. groupId = 1
  766. elseif groups.admin[name] then
  767. group = "Админ"
  768. groupId = 2
  769. elseif groups.enemy[name] then
  770. group = "Враг"
  771. groupId = 3
  772. end
  773. return group, groupId
  774. end
  775.  
  776. function getDistanceToPlayer(playerId)
  777. if sampIsPlayerConnected(playerId) then
  778. local result, ped = sampGetCharHandleBySampPlayerId(playerId)
  779. if result and doesCharExist(ped) then
  780. local myX, myY, myZ = getCharCoordinates(playerPed)
  781. local playerX, playerY, playerZ = getCharCoordinates(ped)
  782. return getDistanceBetweenCoords3d(myX, myY, myZ, playerX, playerY, playerZ)
  783. end
  784. end
  785. return nil
  786. end
  787.  
  788. function drawScoreboardPlayer(id)
  789. local pop
  790. local playerInStream, ped = sampGetCharHandleBySampPlayerId(id)
  791. local nickname = encoding.UTF8(sampGetPlayerNickname(id))
  792. local group, gId = getPlayerSGroup(nickname)
  793. local score = sampGetPlayerScore(id)
  794. local ping = sampGetPlayerPing(id)
  795. local color = sampGetPlayerColor(id)
  796. local health = playerInStream and tostring(sampGetPlayerHealth(id)) or "-"
  797. local armor = playerInStream and tostring(sampGetPlayerArmor(id)) or "-"
  798. local model = playerInStream and tostring(getCharModel(ped)) or "-"
  799. local speed = playerInStream and tostring(math.floor(getCharSpeed(ped))) or "-"
  800. local distance = getDistanceToPlayer(id)
  801. local r, g, b = bitex.bextract(color, 16, 8), bitex.bextract(color, 8, 8), bitex.bextract(color, 0, 8)
  802. local imgui_RGBA = imgui.ImVec4(r / 255.0, g / 255.0, b / 255.0, 1)
  803. playerCount = playerCount + 1
  804. imgui.NewLine()
  805. imgui.SameLine(2)
  806. if imgui.Selectable(tostring(id), id == focusId, imgui.SelectableFlags.SpanAllColumns + imgui.SelectableFlags.AllowDoubleClick) then
  807. if imgui.IsMouseDoubleClicked(0) then
  808. sampSendClickPlayer(id, 0)
  809. lua_thread.create(function ()
  810. wait(150)
  811. toggleScoreboard(false)
  812. end)
  813. else
  814. focusId = focusId == id and -1 or id
  815. end
  816. end
  817.  
  818. imgui.PushStyleVar(imgui.StyleVar.WindowPadding, imgui.ImVec2(4.0, 3.0))
  819. if id ~= getLocalPlayerId() and imgui.BeginPopupContextItem() then
  820. imgui.BeginChild("##pMenu", imgui.ImVec2(150, 138))
  821. pop = true
  822. imgui.TextColored(imgui_RGBA, nickname .. "[" .. id .. "]")
  823. local btnSize = imgui.ImVec2(-0.001, 0.0)
  824. imgui.Separator()
  825. if id ~= getLocalPlayerId() then
  826. bMarkPlayer.v = pMarker[id] and true or false
  827. if imgui.Checkbox(u8"Показать маркер", bMarkPlayer) then
  828. if pMarker[id] then
  829. if doesBlipExist(pMarker[id]) then
  830. removeBlip(pMarker[id])
  831. end
  832. mColor[pMarker[id]] = nil
  833. pMarker[id] = nil
  834. if notf then
  835. notf.addNotification("Маркер игрока " .. nickname .. " удален", 5)
  836. end
  837. elseif playerInStream then
  838. pMarker[id] = addBlipForChar(ped)
  839. local mCol = alpha255(color)
  840. changeBlipColour(pMarker[id], mCol)
  841. mColor[pMarker[id]] = color
  842. changeBlipDisplay(pMarker[id], 3)
  843. setBlipAlwaysDisplayOnZoomedRadar(pMarker[id], true)
  844. if notf then
  845. notf.addNotification("Маркер игрока " .. nickname .. " установлен", 5)
  846. end
  847. else
  848. pMarker[id] = -1
  849. if notf then
  850. notf.addNotification("Игрока " .. nickname .. " сейчас нет рядом. Маркер будет установлен при поялении игрока в зоне стрима.", 5)
  851. end
  852. end
  853. imgui.CloseCurrentPopup()
  854. end
  855. if imgui.Button(u8'Написать сообщение', btnSize) then
  856. imgui.CloseCurrentPopup()
  857. toggleScoreboard(false)
  858. sampSetChatInputText("/sms " .. id .. " ")
  859. sampSetChatInputEnabled(true)
  860. end
  861. end
  862. if imgui.Button(u8'Копировать никнейм', btnSize) then
  863. setClipboardText(nickname)
  864. imgui.CloseCurrentPopup()
  865. end
  866. imgui.Text(u8"Группа игрока:")
  867. imgui.PushItemWidth(-0.001)
  868. _, cSetGroup.v = getPlayerSGroup(nickname)
  869. if imgui.Combo("##cSetGroup", cSetGroup, {u8"Без группы", u8"Друг", u8"Админ", u8"Враг"}) then
  870. if cSetGroup.v == 0 then
  871. groups.friend[tostring(nickname)] = nil
  872. groups.admin[tostring(nickname)] = nil
  873. groups.enemy[tostring(nickname)] = nil
  874. elseif cSetGroup.v == 1 then
  875. groups.friend[tostring(nickname)] = true
  876. groups.admin[tostring(nickname)] = nil
  877. groups.enemy[tostring(nickname)] = nil
  878. elseif cSetGroup.v == 2 then
  879. groups.friend[tostring(nickname)] = nil
  880. groups.admin[tostring(nickname)] = true
  881. groups.enemy[tostring(nickname)] = nil
  882. elseif cSetGroup.v == 3 then
  883. groups.friend[tostring(nickname)] = nil
  884. groups.admin[tostring(nickname)] = nil
  885. groups.enemy[tostring(nickname)] = true
  886. end
  887. imgui.CloseCurrentPopup()
  888. end
  889. imgui.PopItemWidth()
  890. imgui.EndChild()
  891. imgui.EndPopup()
  892. else
  893. pop = false
  894. end
  895. imgui.PopStyleVar()
  896. if imgui.IsItemHovered() and not pop and id ~= getLocalPlayerId() then
  897. imgui.BeginTooltip();
  898. imgui.PushStyleVar(imgui.StyleVar.WindowPadding, imgui.ImVec2(4.0, 3.0))
  899. imgui.PushStyleVar(imgui.StyleVar.ItemSpacing, imgui.ImVec2(4.0, 2.0))
  900. imgui.BeginChild("##Test", imgui.ImVec2(157, (tonumber(sizesFont[allset.set.fontSize + 1]) + 2) * 7 + 7), true)
  901. imgui.Text(nickname .. "[" .. id .. "]")
  902. imgui.Separator()
  903. imgui.Text(u8(string.format("В зоне стрима: %s", playerInStream and "Да" or "Нет")))
  904. imgui.Text(u8(string.format("Афк: %s", playerInStream and (sampIsPlayerPaused(id) and "Да" or "Нет") or "-")))
  905. imgui.Text(u8(string.format("Жизни: %s", health)))
  906. imgui.Text(u8(string.format("Броня: %s", armor)))
  907. imgui.Text(u8(string.format("Скин: %s", model)))
  908. imgui.Text(u8(string.format("Скорость: %s", speed)))
  909. imgui.EndChild()
  910. imgui.Separator()
  911. imgui.PopStyleVar(2)
  912. imgui.EndTooltip();
  913. end
  914.  
  915. imgui.NextColumn()
  916.  
  917. if cNType.v == 0 then
  918. imgui.TextColored(imgui_RGBA, nickname)
  919. else
  920. imgui.Text(nickname)
  921. end
  922. imgui.NextColumn()
  923. if allset.set.list > 0 then
  924. if gId == 0 then
  925. imgui.Text(u8("-"))
  926. else
  927. local color
  928. if gId == 1 then
  929. color = imgui.ImColor(10, 140, 10, 255):GetVec4()
  930. elseif gId == 2 then
  931. color = imgui.ImColor(230, 230, 10, 255):GetVec4()
  932. elseif gId == 3 then
  933. color = imgui.ImColor(180, 10, 10, 255):GetVec4()
  934. end
  935. imgui.TextColored(color, u8(group))
  936. end
  937. imgui.NextColumn()
  938. end
  939. if streamCheck.v then
  940. imgui.Text(sampIsPlayerPaused(id) and u8"Да" or u8"Нет"); imgui.NextColumn()
  941. imgui.Text(string.format("%0.1f", distance)); imgui.NextColumn()
  942. end
  943. if cNType.v == 1 then
  944. imgui.TextColored(imgui_RGBA, "0x" .. string.upper(string.format("%0.8s", bit.tohex(color)))); imgui.NextColumn()
  945. end
  946. imgui.Text(tostring(score)); imgui.NextColumn()
  947. imgui.Text(tostring(ping)); imgui.NextColumn()
  948.  
  949. if scrollToId and focusId > -1 and focusId == id then
  950. scrollToId = false
  951. imgui.SetScrollHere(0.43)
  952. end
  953. end
  954.  
  955. function onScriptTerminate(script, quitGame)
  956. if script == thisScript() then
  957. for k, v in pairs(pMarker) do
  958. if doesBlipExist(v) then
  959. removeBlip(v)
  960. end
  961. end
  962. if not doesDirectoryExist("moonloader\\config") then
  963. createDirectory("moonloader\\config")
  964. end
  965. if notThems then
  966. inicfg.save(cfg, "..\\resource\\scoreboard\\main\\data.ini")
  967. notThems = false
  968. else
  969. inicfg.save(cfg, "..\\resource\\scoreboard\\" .. allset.set.curTheme .. "\\data.ini")
  970. end
  971. inicfg.save(allset, "scoreboard")
  972. inicfg.save(groups, "playergroupscoreboard")
  973. end
  974. end
  975.  
  976. function string.rlower(s)
  977. s = s:lower()
  978. local strlen = s:len()
  979. if strlen == 0 then return s end
  980. s = s:lower()
  981. local output = ''
  982. for i = 1, strlen do
  983. local ch = s:byte(i)
  984. if ch >= 192 and ch <= 223 then -- upper russian characters
  985. output = output .. russian_characters[ch + 32]
  986. elseif ch == 168 then -- Ё
  987. output = output .. russian_characters[184]
  988. else
  989. output = output .. string.char(ch)
  990. end
  991. end
  992. return output
  993. end
  994. function string.rupper(s)
  995. s = s:upper()
  996. local strlen = s:len()
  997. if strlen == 0 then return s end
  998. s = s:upper()
  999. local output = ''
  1000. for i = 1, strlen do
  1001. local ch = s:byte(i)
  1002. if ch >= 224 and ch <= 255 then -- lower russian characters
  1003. output = output .. russian_characters[ch - 32]
  1004. elseif ch == 184 then -- ё
  1005. output = output .. russian_characters[168]
  1006. else
  1007. output = output .. string.char(ch)
  1008. end
  1009. end
  1010. return output
  1011. end
  1012. function SE.onPlayerJoin(id, color, isNpc, nickname)
  1013. if gameInit then
  1014. addConLog(string.format("%s[%d] подключился", nickname, id))
  1015. end
  1016. end
  1017. function SE.onPlayerQuit(id, reason)
  1018. if gameInit then
  1019. addConLog(string.format("%s[%d] %s", sampGetPlayerNickname(id), id, quitReason[reason+1]))
  1020. end
  1021. end
  1022. function SE.onRequestClassResponse()
  1023. gameInit = true
  1024. end
  1025. function SE.onShowDialog()
  1026. gameInit = true
  1027. end
  1028. function SE.onServerMessage()
  1029. gameInit = true
  1030. end
  1031. function addConLog(string)
  1032. logConnect[#logConnect+1] = string.format("[%s] %s", os.date("%H:%M:%S"), string)
  1033. end
  1034. function explode_color(color)
  1035. local a = bit.band(bit.rshift(color, 24), 0xFF)
  1036. local r = bit.band(bit.rshift(color, 16), 0xFF)
  1037. local g = bit.band(bit.rshift(color, 8), 0xFF)
  1038. local b = bit.band(color, 0xFF)
  1039. return a, r, g, b
  1040. end
  1041.  
  1042. function join_color(a, r, g, b)
  1043. local color = b -- b
  1044. color = bit.bor(color, bit.lshift(g, 8)) -- g
  1045. color = bit.bor(color, bit.lshift(r, 16)) -- r
  1046. color = bit.bor(color, bit.lshift(a, 24)) -- a
  1047. return color
  1048. end
  1049.  
  1050. function convertARGBToRGBA(color)
  1051. local color = tonumber(color)
  1052. local a, r, g, b = explode_color(color)
  1053. return join_color(r, g, b, a)
  1054. end
  1055.  
  1056. function convertRGBAToARGB(color)
  1057. local color = tonumber(color)
  1058. local r, g, b, a = explode_color(color)
  1059. return join_color(a, r, g, b)
  1060. end
  1061. function alpha255(color)
  1062. local color = tonumber(color)
  1063. local a, r, g, b = explode_color(color)
  1064. return join_color(r, g, b, 255)
  1065. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement