· 5 years ago · Oct 08, 2020, 02:04 PM
1script_name('Company Pomogator')
2script_author("kreyN")
3
4require "lib.moonloader"
5require "lib.sampfuncs"
6local sampev = require "samp.events"
7local as_action = require('moonloader').audiostream_state
8local memory = require "memory"
9local imgui = require 'imgui'
10local vkeys = require 'vkeys'
11local inicfg = require 'inicfg'
12local encoding = require 'encoding'
13local fa = require 'faIcons'
14local effil = require 'effil'
15local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
16encoding.default = 'CP1251'
17u8 = encoding.UTF8
18
19
20local directIni = "settingscomp.ini"
21local mainIni = inicfg.load({
22 config =
23 {
24 NotfAboutAcceptingInCC = false,
25 NotfAboutAns = false,
26 themenumber = 1,
27 MinimalOrder = 0,
28 ProductTypeToDeliveryFirst = "",
29 ProductTypeToDeliverySecond = "",
30 ProductTypeToDeliveryThird = "",
31 ProductTypeToDeliveryFourth = "",
32 ProductTypeNumberToDeliveryFirst = 0,
33 ProductTypeNumberToDeliverySecond = 0,
34 ProductTypeNumberToDeliveryThird = 0,
35 ProductTypeNumberToDeliveryFourth = 0,
36 ifDeliveryToLS = false,
37 ifDeliveryToSF = false,
38 ifDeliveryToLV = false,
39 FirstNumberOfStorage = 0,
40 SecondNumberOfStorage = 0,
41 MinimalAmountToAccept = 0,
42 AcceptedNumber = 0,
43 AcceptedDeliveries = 0,
44 MoneyFromSells = 0,
45 NotfAboutAnsVK = false,
46 NotfAboutMovingVK = false,
47 NotfAboutLostConnection = false,
48 PPose = false,
49 PlayerVKID = 0
50 },
51 acceptedlog = {}
52 }, directIni
53)
54-------- Загрузка ини
55if not doesFileExist(directIni) then
56 inicfg.save(mainIni, directIni)
57end
58
59
60--------
61------ Все переменные
62local site = "https://raw.githubusercontent.com/Vailinskiy/checkingcompanysamp/main/somename"
63local notfanssound = loadAudioStream('https://raw.githubusercontent.com/Vailinskiy/checkingcompanysamp/main/notfhint.wav')
64local NotfAboutAcceptingInCompanyChat = imgui.ImBool(mainIni.config.NotfAboutAcceptingInCC)
65local NotfAns = imgui.ImBool(mainIni.config.NotfAboutAns)
66local NotfAnsVK = imgui.ImBool(mainIni.config.NotfAboutAnsVK)
67local NotfMoveVK = imgui.ImBool(mainIni.config.NotfAboutMovingVK)
68local otherPos = imgui.ImBool(mainIni.config.PPose)
69local NotfLostConn = imgui.ImBool(mainIni.config.NotfAboutLostConnection)
70local PVKID = imgui.ImInt(mainIni.config.PlayerVKID)
71local main_window_state = imgui.ImBool(false)
72local radio_theme = imgui.ImInt(mainIni.config.themenumber)
73local productintostorage_comboselect1 = imgui.ImInt(mainIni.config.ProductTypeNumberToDeliveryFirst)
74local productintostorage_comboselect2 = imgui.ImInt(mainIni.config.ProductTypeNumberToDeliverySecond)
75local productintostorage_comboselect3 = imgui.ImInt(mainIni.config.ProductTypeNumberToDeliveryThird)
76local productintostorage_comboselect4 = imgui.ImInt(mainIni.config.ProductTypeNumberToDeliveryFourth)
77local fnumberofstorage = imgui.ImInt(mainIni.config.FirstNumberOfStorage)
78local snumberofstorage = imgui.ImInt(mainIni.config.SecondNumberOfStorage)
79local amountofacceptedorders = imgui.ImInt(mainIni.config.AcceptedNumber)
80local amountofaccepteddeliveries = imgui.ImInt(mainIni.config.AcceptedDeliveries)
81local amountofmoneyfromsells = imgui.ImInt(mainIni.config.MoneyFromSells)
82local screnabled = imgui.ImBool(false)
83local dlpointls = imgui.ImBool(mainIni.config.ifDeliveryToLS)
84local dlpointsf = imgui.ImBool(mainIni.config.ifDeliveryToSF)
85local dlpointlv = imgui.ImBool(mainIni.config.ifDeliveryToLV)
86local prod_slad1 = u8:decode(mainIni.config.ProductTypeToDeliveryFirst)
87local prod_slad2 = u8:decode(mainIni.config.ProductTypeToDeliverySecond)
88local prod_slad3 = u8:decode(mainIni.config.ProductTypeToDeliveryThird)
89local prod_slad4 = u8:decode(mainIni.config.ProductTypeToDeliveryFourth)
90local min_zakaz = imgui.ImInt(mainIni.config.MinimalAmountToAccept)
91local menunum = 0
92local xyz = 0
93local tag = " {bf8f15}Helper {ffffff}• "
94------
95
96------ Все массивы
97colorThemes = {u8"Красная", u8"Фиолетовая", u8"Зелёная"}
98
99--numberofstorage = {}
100local dlendpointsls = {
101 'Police Departament LS',
102 'Аэропорт Los Santos',
103 'Больница Los Santos',
104 'СТО Los Santos',
105 'Байкерский клуб Hells Angels',
106 'Здание Суда',
107 'Business Center',
108 'Администрация Президента',
109 ''
110}
111local dlendpointssf = {
112 'Police Departament SF',
113 'Аэропорт San Fierro',
114 'Больница San Fierro',
115 'СТО San Fierro',
116 'Порт Bayside',
117 'Железнодорожный завод',
118 'База ВМФ',
119 'Байкерский клуб Bandidos',
120}
121local dlendpointslv = {
122 'Police Departament LV',
123 'Аэропорт Las Venturas',
124 'Больница Las Venturas',
125 'СТО Las Venturas',
126 'Bar "Amnesia"',
127 'База ВВС',
128 'Family Center',
129 'Байкерский клуб Outlaws',
130 'Байкерский клуб Bandidos',
131 'Alcatraz',
132}
133local producttype = {
134 u8'',
135 u8'Алкоголь',
136 u8'Аксессуары',
137 u8'Автозапчасти',
138 u8'Канцелярские товары',
139 u8'Косметические средства',
140 u8'Мебель',
141 u8'Одежда',
142 u8'Оружие',
143 u8'Пиротехника',
144 u8'Продукты питания',
145 u8'Парашютное снаряжение',
146 u8'Радиоигрушки',
147 u8'Спорт-Товары',
148 u8'Транспорт',
149 u8'Товары общего пользования',
150}
151
152------
153
154
155
156
157
158--------- Работа с уведомлениями ВК
159--vk longpoll api globals
160local key, server, ts
161
162function threadHandle(runner, url, args, resolve, reject) -- обработка effil потока без блокировок
163 local t = runner(url, args)
164 local r = t:get(0)
165 while not r do
166 r = t:get(0)
167 wait(0)
168 end
169 local status = t:status()
170 if status == 'completed' then
171 local ok, result = r[1], r[2]
172 if ok then resolve(result) else reject(result) end
173 elseif err then
174 reject(err)
175 elseif status == 'canceled' then
176 reject(status)
177 end
178 t:cancel(0)
179end
180
181function requestRunner() -- создание effil потока с функцией https запроса
182 return effil.thread(function(u, a)
183 local https = require 'ssl.https'
184 local ok, result = pcall(https.request, u, a)
185 if ok then
186 return {true, result}
187 else
188 return {false, result}
189 end
190 end)
191end
192
193function async_http_request(url, args, resolve, reject)
194 local runner = requestRunner()
195 if not reject then reject = function() end end
196 lua_thread.create(function()
197 threadHandle(runner, url, args, resolve, reject)
198 end)
199end
200
201local vkerr, vkerrsend -- сообщение с текстом ошибки, nil если все ок
202function tblfromstr(str)
203 local a = {}
204 for b in str:gmatch('%S+') do
205 a[#a+1] = b
206 end
207 return a
208end
209
210function loop_async_http_request(url, args, reject)
211 local runner = requestRunner()
212 if not reject then reject = function() end end
213 lua_thread.create(function()
214 while true do
215 while not key do wait(0) end
216 url = server .. '?act=a_check&key=' .. key .. '&ts=' .. ts .. '&wait=25' --меняем url каждый новый запрос потокa, так как server/key/ts могут изменяться
217 threadHandle(runner, url, args, longpollResolve, reject)
218 end
219 end)
220end
221
222
223function sendvknotf(msg, host)
224 host = host or sampGetCurrentServerName()
225 local acc = sampGetPlayerNickname(select(2,sampGetPlayerIdByCharHandle(playerPed))) .. '['..select(2,sampGetPlayerIdByCharHandle(playerPed))..']'
226 msg = msg:gsub('{......}', '')
227 msg = u8(msg)
228 msg = url_encode(msg)
229 local keyboard = vkKeyboard()
230 keyboard = u8(keyboard)
231 keyboard = url_encode(keyboard)
232 msg = msg .. '&keyboard=' .. keyboard
233 if mainIni.config.PlayerVKID > 0 then
234 async_http_request('https://api.vk.com/method/messages.send', 'user_id=' .. mainIni.config.PlayerVKID .. '&message=' .. msg .. '&access_token=985ad417a7bc5638437851e3712f700c32585956bfaa2e412471b79da0fa8c993d7255ed33c3902b16591&v=5.80',
235 function (result)
236 local t = decodeJson(result)
237 if not t then
238 return
239 end
240 if t.error then
241 vkerrsend = 'Ошибка!\nКод: ' .. t.error.error_code .. ' Причина: ' .. t.error.error_msg
242 return
243 end
244 vkerrsend = nil
245 end)
246 end
247end
248
249function longpollGetKey()
250 async_http_request('https://api.vk.com/method/groups.getLongPollServer?group_id=199233305&access_token=985ad417a7bc5638437851e3712f700c32585956bfaa2e412471b79da0fa8c993d7255ed33c3902b16591&v=5.80', '', function (result)
251 if result then
252 if debugMode.v then
253 print(result)
254 end
255 if not result:sub(1,1) == '{' then
256 vkerr = 'Ошибка!\nПричина: Нет соединения с VK!'
257 return
258 end
259 local t = decodeJson(result)
260 if t.error then
261 vkerr = 'Ошибка!\nКод: ' .. t.error.error_code .. ' Причина: ' .. t.error.error_msg
262 return
263 end
264 server = t.response.server
265 ts = t.response.ts
266 key = t.response.key
267 vkerr = nil
268 end
269 end)
270end
271
272----------- Отправка сообщений из ВК в игру
273function longpollResolve(result)
274 if result then
275 if not result:sub(1,1) == '{' then
276 vkerr = 'Ошибка!\nПричина: Нет соединения с VK!'
277 return
278 end
279 local t = decodeJson(result)
280 if t.failed then
281 if t.failed == 1 then
282 ts = t.ts
283 else
284 key = nil
285 longpollGetKey()
286 end
287 return
288 end
289 if t.ts then
290 ts = t.ts
291 end
292 if t.updates then
293 for k, v in ipairs(t.updates) do
294 if v.type == 'message_new' and tonumber(v.object.from_id) == tonumber(PlayerVKID.v) and v.object.text then
295 if v.object.payload then
296 local pl = decodeJson(v.object.payload)
297 if pl.button then
298 if pl.button == 'testupper' then
299 sendvknotf("Гы гы га га")
300 elseif pl.button == 'testbuttom' then
301 sendvknotf("Статус")
302 end
303 end
304 return
305 end
306 local objsend = tblfromstr(v.object.text)
307 if objsend[1] == '!sendplchat' then
308 print('this')
309 local args = table.concat(objsend, " ", 2, #objsend)
310 if #args > 0 then
311 args = u8:decode(args)
312 sampSendChat(args)
313 sendvknotf('Сообщение "' .. args .. '" было успешно отправлено в игру')
314 else
315 sendvknotf('Неправильный аргумент! Пример: !sendplchat [строка]')
316 end
317 end
318 end
319 end
320 end
321 end
322end
323-----------
324
325------ Клавиатура ВК
326function vkKeyboard() --создает конкретную клавиатуру для бота VK, как сделать для более общих случаев пока не задумывался
327 local keyboard = {}
328 keyboard.one_time = false
329 keyboard.buttons = {}
330 keyboard.buttons[1] = {}
331 keyboard.buttons[2] = {}
332 local row = keyboard.buttons[1]
333 local row2 = keyboard.buttons[2]
334 row[1] = {}
335 row[1].action = {}
336 row[1].color = 'positive'
337 row[1].action.type = 'text'
338 row[1].action.payload = '{"button": "testupper"}'
339 row[1].action.label = 'Тестовая 1'
340 row2[1] = {}
341 row2[1].action = {}
342 row2[1].color = 'positive'
343 row2[1].action.type = 'text'
344 row2[1].action.payload = '{"button": "testbuttom"}'
345 row2[1].action.label = 'Тестовая 2'
346 return encodeJson(keyboard)
347end
348
349---------- Функции кнопок клавиатуры
350function sendHelp()
351 local response = 'Отправить сообщение на аккаунт /send\nПока все ://'
352 vk_request(response)
353end
354----------
355
356-----------------------
357
358------ Main function
359function main()
360 if not isSampfuncsLoaded() or not isSampLoaded() then return end
361 while not isSampAvailable() do wait(100) end
362 --------- Проверка на наличие ключа
363 while sampGetCurrentServerName() == 'SA-MP' do wait(0) end
364 local bool, users = getTableUsersByUrl(site)
365 assert(bool, 'Downloading list users failed.')
366 local _, myid = sampGetPlayerIdByCharHandle(playerPed)
367 if isAvailableUser(users, sampGetPlayerNickname(myid)) == false then
368 sampAddChatMessage(tag .. "Купите сначала ключ, затем используйте.", 4290744085)
369 else
370 sampAddChatMessage(tag .. "Вы находитесь в списке. Приятного заработка.", 4290744085)
371 end
372 --------
373 wait(100)
374 sampRegisterChatCommand("ccomp", cmd_ccomp)
375 sampRegisterChatCommand("test", cmd_test)
376 sampRegisterChatCommand("test2", cmd_test2)
377 imgui.SwitchContext()
378 SwitchColorTheme(mainIni.config.themenumber)
379 while true do
380 wait(0)
381 px, py, pz = getCharCoordinates(PLAYER_PED)
382 -- IMGUI
383 imgui.Process = main_window_state.v
384 end
385end
386
387function char_to_hex(str)
388 return string.format("%%%02X", string.byte(str))
389end
390
391function url_encode(str)
392 local str = string.gsub(str, "\\", "\\")
393 local str = string.gsub(str, "([^%w])", char_to_hex)
394 return str
395end
396
397
398
399------ Регистрация команд
400
401function cmd_ccomp()
402 main_window_state.v = not main_window_state.v
403end
404
405function cmd_test(arg)
406 arg = "1. \tДепартамент ЛС\t\tОружие\t\t20.000 - $1.20\n"
407 table.insert(mainIni.acceptedlog, arg)
408 inicfg.save(mainIni, directIni)
409end
410
411function cmd_test2()
412 sendvknotf("helo ")
413end
414
415------ Как в чате появится строка, то..
416function sampev.onServerMessage(color, text)
417 if color == -6732289 and NotfAns.v then
418 setAudioStreamState(notfanssound, 1)
419 setAudioStreamVolume(notfanssound, 100)
420 end
421 if color == -6732289 and NotfAnsVK.v then
422 sendvknotf("Сообщение от администратора:\n" .. text)
423 end
424 if not isPauseMenuActive() and screnabled.v then
425
426 if text:find("Новый заказ на бирже доставки товара. Введите /company для просмотра") then
427 sampSendChat('/exchange2')
428 end
429 if text:find("2 новых заказов на бирже продажи товара. Введите /company для просмотра") then
430 if sampIsDialogActive() == false then
431 sampSendChat("/exchange1")
432 elseif dialogId ~= 1267 then
433 lua_thread.create(function()
434 wait(1)
435 sampCloseCurrentDialogWithButton(0)
436 local _, id = sampGetPlayerIdByCharHandle()
437 local ping = sampGetPlayerPing(id)
438 wait(ping+5)
439 sampCloseCurrentDialogWithButton(0)
440 sampSendChat("/exchange1")
441 end)
442 end
443 end
444 end
445end
446
447------ Как откроется диалог, то..
448function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
449 if dialogId == 1240 and screnabled.v then
450 lua_thread.create(function()
451 wait(1)
452 sampCloseCurrentDialogWithButton(0)
453 end)
454 end
455 if dialogId == 1268 and screnabled.v then
456 lua_thread.create(function()
457 wait(1)
458 sampCloseCurrentDialogWithButton(1)
459 end)
460 end
461 if dialogId == 1267 and screnabled.v then
462 lua_thread.create(function ()
463 wait(1)
464 for line in text:gmatch("[^\r\n]+") do
465 if line:find("{FFDF80}%d+%.{FFFFFF}") then
466 local num, kuda, tovar, kolvo, price, dostavka = line:match("{FFDF80}(%d+).{FFFFFF}%s(.*)%c(.*)%c(%d+)%s%-%s$(%S+)%c$(%S+)")
467 if dlpointls.v then
468 if (tovar == prod_slad1 or prod_slad2 or prod_slad3 or prod_slad4) and (tonumber(kolvo) > min_zakaz) and (kuda == dlendpointsls) then
469 --sampSendDialogResponse(1267, 1, num-1, -1)
470 --mainIni.config.amountofmoneyfromsells = price + amountofmoneyfromsells.v
471 --inicfg.save(mainIni, directIni)
472 end
473 if dlpointsf.v then
474 if (tovar == prod_slad1 or prod_slad2 or prod_slad3 or prod_slad4) and (tonumber(kolvo) > min_zakaz) and (kuda == dlendpointssf) then
475 --sampSendDialogResponse(1267, 1, num-1, -1)
476 --mainIni.config.amountofmoneyfromsells = price + amountofmoneyfromsells.v
477 --inicfg.save(mainIni, directIni)
478 end
479 end
480 if dlpointlv.v then
481 if (tovar == prod_slad1 or prod_slad2 or prod_slad3 or prod_slad4) and (tonumber(kolvo) > min_zakaz) and (kuda == dlendpointslv) then
482 --sampSendDialogResponse(1267, 1, num-1, -1)
483 --mainIni.config.amountofmoneyfromsells = price + amountofmoneyfromsells.v
484 --inicfg.save(mainIni, directIni)
485 sampAddChatMessage(num .."||".. kuda.."||".. tovar.."||".. min_zakaz)
486 end
487 end
488 end
489 end
490 if line:find("Далее") then
491 sampSendDialogResponse(1267, 1, 52, -1)
492 lua_thread.create(function()
493 local _, id = sampGetPlayerIdByCharHandle()
494 local ping = sampGetPlayerPing(id)
495 wait(ping+5)
496 sampCloseCurrentDialogWithButton(0)
497 end)
498 end
499 end
500 end)
501 end
502 if dialogId == 1269 and screnabled.v then
503 lua_thread.create(function()
504 wait(1)
505 sampCloseCurrentDialogWithButton(1)
506 end)
507 end
508 --[[if dialogId == 1270 and screnabled.v then
509 for line in text:gmatch("[^\r\n]+") do
510 if line:find("%%{FFDF80%}%d+%.%{FFFFFF%}") then
511 local num, numsklad, deliverypoint, prdtype, amount, price = text:match('%{FFDF80%}(.+)%.%{FFFFFF%} Перевозка товаров [Склад №(%d+) - (.+) (.+) (.+) %$(.+)')
512 tempstring1 = "{FFDF80}"..num..".{FFFFFF} "..deliverypoint.."\t"..prdtype.."\t"..amount.." - $"..price.."\n"
513 if numsklad == fnumberofstorage or snumberofstorage then
514 sampSendDialogResponse(1267, 1, num-1, -1)
515 if not text:find("{AC0000}[Ошибка] {ffffff}На Ваших складах недостаточно товара для этого заказа") then
516 amountofacceptedorders.v = amountofacceptedorders.v+1
517 amountofaccepteddeliveries.v = amountofaccepteddeliveries.v+1
518 mainIni.config.AcceptedNumber = amountofacceptedorders.v
519 mainIni.config.AcceptedDeliveries = amountofaccepteddeliveries.v
520 inicfg.save(mainIni, directIni)
521 table.insert(mainIni.acceptedlog, tempstring1)
522 end
523 if NotfAboutAcceptingInCompanyChat.v then
524 sampSendChat("[! Новый заказ !] Цена за доставку: " .. price .. "$, количество: " .. amount .. " ед, тип: " .. prdtype)
525 end
526 end
527 end
528 end
529 end]]
530 if dialogId == 1271 and screnabled.v then
531 lua_thread.create(function()
532 wait(1)
533 sampCloseCurrentDialogWithButton(1)
534 end)
535 end
536 if dialogId == 1272 and screnabled.v then
537 lua_thread.create(function()
538 wait(1)
539 sampCloseCurrentDialogWithButton(1)
540 end)
541 end
542end
543
544
545
546
547
548function imgui.BeforeDrawFrame()
549 if fa_font == nil then
550 local font_config = imgui.ImFontConfig()
551 font_config.MergeMode = true
552 fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fontawesome-webfont.ttf', 14.0, font_config, fa_glyph_ranges)
553 end
554end
555
556SwitchColorTheme = function(theme)
557 local style = imgui.GetStyle()
558 local colors = style.Colors
559 local clr = imgui.Col
560 local ImVec4 = imgui.ImVec4
561
562 style.WindowRounding = 10.0
563 style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
564 style.ChildWindowRounding = 5.0
565 style.FrameRounding = 2.0
566 style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
567 style.ScrollbarSize = 13.0
568 style.ScrollbarRounding = 0
569 style.GrabMinSize = 8.0
570 style.GrabRounding = 1.0
571
572 if theme == 1 or theme == nil then
573 colors[clr.Text] = ImVec4(0.95, 0.96, 0.98, 1.00);
574 colors[clr.TextDisabled] = ImVec4(0.29, 0.29, 0.29, 1.00);
575 colors[clr.WindowBg] = ImVec4(0.14, 0.14, 0.14, 1.00);
576 colors[clr.ChildWindowBg] = ImVec4(0.12, 0.12, 0.12, 1.00);
577 colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94);
578 colors[clr.Border] = ImVec4(0.14, 0.14, 0.14, 1.00);
579 colors[clr.BorderShadow] = ImVec4(1.00, 1.00, 1.00, 0.10);
580 colors[clr.FrameBg] = ImVec4(0.22, 0.22, 0.22, 1.00);
581 colors[clr.FrameBgHovered] = ImVec4(0.18, 0.18, 0.18, 1.00);
582 colors[clr.FrameBgActive] = ImVec4(0.09, 0.12, 0.14, 1.00);
583 colors[clr.TitleBg] = ImVec4(0.14, 0.14, 0.14, 1.00);
584 colors[clr.TitleBgActive] = ImVec4(0.40, 0.01, 0.55, 1.00);
585 colors[clr.TitleBgCollapsed] = ImVec4(0.14, 0.14, 0.14, 1.00);
586 colors[clr.MenuBarBg] = ImVec4(0.20, 0.20, 0.20, 1.00);
587 colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.39);
588 colors[clr.ScrollbarGrab] = ImVec4(0.36, 0.36, 0.36, 1.00);
589 colors[clr.ScrollbarGrabHovered] = ImVec4(0.18, 0.22, 0.25, 1.00);
590 colors[clr.ScrollbarGrabActive] = ImVec4(0.24, 0.24, 0.24, 1.00);
591 colors[clr.ComboBg] = ImVec4(0.24, 0.24, 0.24, 1.00);
592 colors[clr.CheckMark] = ImVec4(1.00, 0.28, 0.28, 1.00);
593 colors[clr.SliderGrab] = ImVec4(1.00, 0.28, 0.28, 1.00);
594 colors[clr.SliderGrabActive] = ImVec4(1.00, 0.28, 0.28, 1.00);
595 colors[clr.Button] = ImVec4(1.00, 0.28, 0.28, 1.00);
596 colors[clr.ButtonHovered] = ImVec4(1.00, 0.39, 0.39, 1.00);
597 colors[clr.ButtonActive] = ImVec4(1.00, 0.21, 0.21, 1.00);
598 colors[clr.Header] = ImVec4(1.00, 0.28, 0.28, 1.00);
599 colors[clr.HeaderHovered] = ImVec4(1.00, 0.39, 0.39, 1.00);
600 colors[clr.HeaderActive] = ImVec4(1.00, 0.21, 0.21, 1.00);
601 colors[clr.ResizeGrip] = ImVec4(1.00, 0.28, 0.28, 1.00);
602 colors[clr.ResizeGripHovered] = ImVec4(1.00, 0.39, 0.39, 1.00);
603 colors[clr.ResizeGripActive] = ImVec4(1.00, 0.19, 0.19, 1.00);
604 colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16);
605 colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39);
606 colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00);
607 colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00);
608 colors[clr.PlotLinesHovered] = ImVec4(1.00, 0.43, 0.35, 1.00);
609 colors[clr.PlotHistogram] = ImVec4(1.00, 0.21, 0.21, 1.00);
610 colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.18, 0.18, 1.00);
611 colors[clr.TextSelectedBg] = ImVec4(1.00, 0.32, 0.32, 1.00);
612 colors[clr.ModalWindowDarkening] = ImVec4(0.26, 0.26, 0.26, 0.60);
613 elseif theme == 2 then
614 colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00);
615 colors[clr.TextDisabled] = ImVec4(0.50, 0.50, 0.50, 1.00);
616 colors[clr.WindowBg] = ImVec4(0.14, 0.14, 0.14, 1.00);
617 colors[clr.ChildWindowBg] = ImVec4(0.12, 0.12, 0.12, 1.00);
618 colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94);
619 colors[clr.Border] = ImVec4(0.43, 0.43, 0.50, 0.50);
620 colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00);
621 colors[clr.FrameBg] = ImVec4(0.22, 0.22, 0.22, 1.00);
622 colors[clr.FrameBgHovered] = ImVec4(0.18, 0.35, 0.74, 0.40);
623 colors[clr.FrameBgActive] = ImVec4(0.14, 0.14, 0.14, 1.00);
624 colors[clr.TitleBg] = ImVec4(0.14, 0.14, 0.14, 1.00);
625 colors[clr.TitleBgActive] = ImVec4(0.14, 0.14, 0.14, 1.00);
626 colors[clr.TitleBgCollapsed] = ImVec4(0.14, 0.14, 0.14, 1.00);
627 colors[clr.MenuBarBg] = ImVec4(1.00, 0.28, 0.28, 1.00);
628 colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.53);
629 colors[clr.ScrollbarGrab] = ImVec4(0.31, 0.31, 0.31, 1.00);
630 colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.41, 0.41, 1.00);
631 colors[clr.ScrollbarGrabActive] = ImVec4(0.51, 0.51, 0.51, 1.00);
632 colors[clr.ComboBg] = ImVec4(0.08, 0.08, 0.08, 0.94);
633 colors[clr.CheckMark] = ImVec4(0.40, 0.01, 0.55, 1.00);
634 colors[clr.SliderGrab] = ImVec4(1.00, 0.28, 0.28, 1.00);
635 colors[clr.SliderGrabActive] = ImVec4(1.00, 0.28, 0.28, 1.00);
636 colors[clr.Button] = ImVec4(0.40, 0.01, 0.55, 1.00);
637 colors[clr.ButtonHovered] = ImVec4(0.45, 0.05, 0.60, 1.00);
638 colors[clr.ButtonActive] = ImVec4(0.35, 0.01, 0.50, 1.00);
639 colors[clr.Header] = ImVec4(1.00, 0.28, 0.28, 1.00);
640 colors[clr.HeaderHovered] = ImVec4(0.29, 0.33, 0.98, 0.80);
641 colors[clr.HeaderActive] = ImVec4(1.00, 0.28, 0.28, 1.00);
642 colors[clr.ResizeGrip] = ImVec4(1.00, 0.28, 0.28, 1.00);
643 colors[clr.ResizeGripHovered] = ImVec4(0.40, 0.39, 0.38, 0.16);
644 colors[clr.ResizeGripActive] = ImVec4(0.40, 0.39, 0.38, 0.39);
645 colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16);
646 colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39);
647 colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00);
648 colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00);
649 colors[clr.PlotLinesHovered] = ImVec4(1.00, 0.43, 0.35, 1.00);
650 colors[clr.PlotHistogram] = ImVec4(1.00, 0.21, 0.21, 1.00);
651 colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.18, 0.18, 1.00);
652 colors[clr.TextSelectedBg] = ImVec4(0.26, 0.59, 0.98, 0.35);
653 colors[clr.ModalWindowDarkening] = ImVec4(0.26, 0.26, 0.26, 0.60);
654 elseif theme == 3 then
655 colors[clr.Text] = ImVec4(0.90, 0.90, 0.90, 1.00)
656 colors[clr.TextDisabled] = ImVec4(0.60, 0.60, 0.60, 1.00)
657 colors[clr.WindowBg] = ImVec4(0.08, 0.08, 0.08, 1.00)
658 colors[clr.ChildWindowBg] = ImVec4(0.10, 0.10, 0.10, 1.00)
659 colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 1.00)
660 colors[clr.Border] = ImVec4(0.70, 0.70, 0.70, 0.40)
661 colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
662 colors[clr.FrameBg] = ImVec4(0.15, 0.15, 0.15, 1.00)
663 colors[clr.FrameBgHovered] = ImVec4(0.19, 0.19, 0.19, 0.71)
664 colors[clr.FrameBgActive] = ImVec4(0.34, 0.34, 0.34, 0.79)
665 colors[clr.TitleBg] = ImVec4(0.00, 0.69, 0.33, 0.80)
666 colors[clr.TitleBgActive] = ImVec4(0.00, 0.74, 0.36, 1.00)
667 colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.69, 0.33, 0.50)
668 colors[clr.MenuBarBg] = ImVec4(0.00, 0.80, 0.38, 1.00)
669 colors[clr.ScrollbarBg] = ImVec4(0.16, 0.16, 0.16, 1.00)
670 colors[clr.ScrollbarGrab] = ImVec4(0.00, 0.69, 0.33, 1.00)
671 colors[clr.ScrollbarGrabHovered] = ImVec4(0.00, 0.82, 0.39, 1.00)
672 colors[clr.ScrollbarGrabActive] = ImVec4(0.00, 1.00, 0.48, 1.00)
673 colors[clr.ComboBg] = ImVec4(0.20, 0.20, 0.20, 0.99)
674 colors[clr.CheckMark] = ImVec4(0.00, 0.69, 0.33, 1.00)
675 colors[clr.SliderGrab] = ImVec4(0.00, 0.69, 0.33, 1.00)
676 colors[clr.SliderGrabActive] = ImVec4(0.00, 0.77, 0.37, 1.00)
677 colors[clr.Button] = ImVec4(0.00, 0.69, 0.33, 1.00)
678 colors[clr.ButtonHovered] = ImVec4(0.00, 0.82, 0.39, 1.00)
679 colors[clr.ButtonActive] = ImVec4(0.00, 0.87, 0.42, 1.00)
680 colors[clr.Header] = ImVec4(0.00, 0.69, 0.33, 1.00)
681 colors[clr.HeaderHovered] = ImVec4(0.00, 0.76, 0.37, 0.57)
682 colors[clr.HeaderActive] = ImVec4(0.00, 0.88, 0.42, 0.89)
683 colors[clr.Separator] = ImVec4(1.00, 1.00, 1.00, 0.40)
684 colors[clr.SeparatorHovered] = ImVec4(1.00, 1.00, 1.00, 0.60)
685 colors[clr.SeparatorActive] = ImVec4(1.00, 1.00, 1.00, 0.80)
686 colors[clr.ResizeGrip] = ImVec4(0.00, 0.69, 0.33, 1.00)
687 colors[clr.ResizeGripHovered] = ImVec4(0.00, 0.76, 0.37, 1.00)
688 colors[clr.ResizeGripActive] = ImVec4(0.00, 0.86, 0.41, 1.00)
689 colors[clr.CloseButton] = ImVec4(0.00, 0.82, 0.39, 1.00)
690 colors[clr.CloseButtonHovered] = ImVec4(0.00, 0.88, 0.42, 1.00)
691 colors[clr.CloseButtonActive] = ImVec4(0.00, 1.00, 0.48, 1.00)
692 colors[clr.PlotLines] = ImVec4(0.00, 0.69, 0.33, 1.00)
693 colors[clr.PlotLinesHovered] = ImVec4(0.00, 0.74, 0.36, 1.00)
694 colors[clr.PlotHistogram] = ImVec4(0.00, 0.69, 0.33, 1.00)
695 colors[clr.PlotHistogramHovered] = ImVec4(0.00, 0.80, 0.38, 1.00)
696 colors[clr.TextSelectedBg] = ImVec4(0.00, 0.69, 0.33, 0.72)
697 colors[clr.ModalWindowDarkening] = ImVec4(0.17, 0.17, 0.17, 0.48)
698 end
699end
700
701function imgui.OnDrawFrame()
702 imgui.LockPlayer = true
703 local sw, sh = getScreenResolution()
704 -- center
705 imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
706 imgui.SetNextWindowSize(imgui.ImVec2(900, 370), imgui.Cond.FirstUseEver)
707 imgui.PushStyleVar(imgui.StyleVar.WindowPadding,imgui.ImVec2(0,0))
708 local button_size = imgui.ImVec2(200,30)
709 local smallbutton_size = imgui.ImVec2(70, 19)
710 imgui.Begin("Company Helper", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoMove + imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoScrollbar)
711 local pos = imgui.GetCursorScreenPos()
712 local menu_colors = {
713 u_left = imgui.ImColor(imgui.GetStyle().Colors[imgui.Col.Button]),
714 u_right = imgui.ImColor(imgui.GetStyle().Colors[imgui.Col.Button]),
715 b_right = imgui.ImColor(imgui.GetStyle().Colors[imgui.Col.Button]),
716 b_left = imgui.ImColor(imgui.GetStyle().Colors[imgui.Col.Button])
717 }
718 imgui.GetWindowDrawList():AddRectFilledMultiColor(imgui.ImVec2(pos.x, pos.y), imgui.ImVec2(pos.x + 200, pos.y + 600), menu_colors.u_left:GetU32(),menu_colors.u_right:GetU32(),menu_colors.b_right:GetU32(),menu_colors.b_left:GetU32())
719
720 imgui.SetCursorPos(imgui.ImVec2(0,135))
721 imgui.BeginGroup()
722 if imgui.Button(fa.ICON_TABLE .. u8" Статистика", button_size) then
723 menunum = 0
724 end
725 if imgui.Button(fa.ICON_COGS .. u8" Настройки", button_size) then
726 menunum = 1
727 end
728 imgui.EndGroup()
729 imgui.SetCursorPos(imgui.ImVec2(205, 5))
730 if menunum == 0 then
731 imgui.BeginChild(u8"Окно статистики", imgui.ImVec2(685, 23), true)
732 imgui.Columns(3, _, true)
733 imgui.Separator()
734 imgui.SetColumnWidth(-1, 225); imgui.SetCursorPosX(7); imgui.Text(fa.ICON_ROCKET .. u8" Кол-во пойманнных заказов: ".. amountofacceptedorders.v); imgui.NextColumn()
735 imgui.SetColumnWidth(-1, 225); imgui.SetCursorPosY(5); imgui.Text(fa.ICON_PRODUCT_HUNT .. u8" Количество принятого товара: " .. amountofaccepteddeliveries.v); imgui.NextColumn()
736 imgui.SetColumnWidth(-1, 225); imgui.SetCursorPosY(5); imgui.Text(fa.ICON_USD .. u8" Стоимость проданного товара: " .. amountofmoneyfromsells.v); imgui.NextColumn()
737 imgui.EndChild()
738
739 imgui.SetCursorPosX(205)
740 imgui.BeginChild(u8"Окно лога", imgui.ImVec2(685, 332), true)
741 imgui.SetCursorPosY(5)
742 imgui.CenterText(u8"Окно лога действий")
743 imgui.SameLine()
744 imgui.SetCursorPosX(605)
745 imgui.SetCursorPosY(5)
746 if imgui.Button(u8"Очистить", smallbutton_size) then
747 mainIni.acceptedlog = {}
748 end
749
750 imgui.Separator()
751 imgui.BeginChild("##220", imgui.ImVec2(685, 300), false)
752 for _, v in ipairs(mainIni.acceptedlog) do
753 imgui.SetCursorPosX(7)
754 imgui.Text(u8(v))
755 end
756 imgui.EndChild()
757 imgui.EndChild()
758 elseif menunum == 1 then
759 imgui.BeginChild(u8"Окно настроек", imgui.ImVec2(340, 150), true)
760 imgui.SetCursorPosX(7)
761 imgui.SetCursorPosY(7)
762 imgui.BeginGroup()
763 imgui.CenterText(u8"Включение и выключение ловли заказов")
764 if imgui.Checkbox(u8"Состояние", screnabled) then
765 sampAddChatMessage(screnabled.v and 'Включен' or 'Выключен', -1)
766 end
767 imgui.SameLine()
768 imgui.EndGroup()
769 imgui.Separator()
770 imgui.SetCursorPosX(7)
771 imgui.SetCursorPosY(55)
772 imgui.BeginGroup()
773 imgui.CenterText(u8"Темы")
774 for gg, value in pairs(colorThemes) do
775 if imgui.RadioButton(value, radio_theme, gg) then
776 SwitchColorTheme(gg)
777 mainIni.config.themenumber = gg
778 inicfg.save(mainIni, directIni)
779 end
780 end
781 imgui.EndGroup()
782 imgui.EndChild()
783 -------
784 imgui.SameLine()
785 -------
786 imgui.SetCursorPosX(550)
787 imgui.SetCursorPosY(5)
788 imgui.BeginChild(u8"Окно настроек фильтра", imgui.ImVec2(340, 150), true)
789 imgui.SetCursorPosY(5)
790 imgui.CenterText(u8"Брать заказы из городов "); imgui.SameLine(); imgui.TextQuestion(u8"Заказы будут браться из одного или нескольких городов")
791 imgui.SetCursorPosX(10)
792 if imgui.Checkbox(u8"Лос-Сантос", dlpointls, 0) then
793 mainIni.config.ifDeliveryToLS = dlpointls.v
794 inicfg.save(mainIni, directIni)
795 end
796 imgui.SameLine()
797 imgui.SetCursorPosX(110)
798 if imgui.Checkbox(u8"Сан-Фиерро", dlpointsf, 1) then
799 mainIni.config.ifDeliveryToSF = dlpointsf.v
800 inicfg.save(mainIni, directIni)
801 end
802 imgui.SameLine()
803 imgui.SetCursorPosX(215)
804 if imgui.Checkbox(u8"Лас-Вентурас", dlpointlv, 2) then
805 mainIni.config.ifDeliveryToLV = dlpointlv.v
806 inicfg.save(mainIni, directIni)
807 end
808 imgui.Separator()
809 imgui.CenterText(u8"Минимальное количество товаров для заказа "); imgui.SameLine(); imgui.TextQuestion(u8"От сколько единиц брать заказы в /exchange1")
810 imgui.SetCursorPosX(10)
811 imgui.PushItemWidth(100)
812 if imgui.InputInt("##3", min_zakaz, 0, 0) then
813 mainIni.config.MinimalAmountToAccept = min_zakaz.v
814 inicfg.save(mainIni, directIni)
815 end
816 imgui.EndChild()
817 ------
818 imgui.SetCursorPos(imgui.ImVec2(205, 160))
819 imgui.BeginChild(u8"Окно настроек складов", imgui.ImVec2(340, 200), true)
820 imgui.SetCursorPosX(170)
821 imgui.SetCursorPosY(5)
822 imgui.CenterText(u8"Номера 2 ваших складов")
823 imgui.PushItemWidth(70)
824 imgui.SetCursorPosX(10)
825 if imgui.InputInt("##1", fnumberofstorage, 0, 0) then
826 if fnumberofstorage.v < 0 then fnumberofstorage.v = 0 elseif fnumberofstorage.v > 99 then fnumberofstorage.v = 99 end
827 mainIni.config.FirstNumberOfStorage = fnumberofstorage.v
828 inicfg.save(mainIni, directIni)
829 end
830 imgui.SameLine()
831 if imgui.InputInt("##2", snumberofstorage, 0, 0) then
832 if snumberofstorage.v < 0 then snumberofstorage.v = 0 elseif snumberofstorage.v > 99 then snumberofstorage.v = 99 end
833 mainIni.config.SecondNumberOfStorage = snumberofstorage.v
834 inicfg.save(mainIni, directIni)
835 end
836 imgui.Separator()
837 imgui.CenterText(u8"Типы товаров")
838 imgui.SameLine()
839 imgui.TextQuestion(u8"Используется при ловле заказов")
840 imgui.PushItemWidth(180)
841 imgui.SetCursorPosX(10)
842 if imgui.Combo("##11", productintostorage_comboselect1, producttype) then
843 mainIni.config.ProductTypeToDeliveryFirst = producttype[productintostorage_comboselect1.v+1]
844 mainIni.config.ProductTypeNumberToDeliveryFirst = productintostorage_comboselect1.v
845 inicfg.save(mainIni, directIni)
846 end
847 imgui.PushItemWidth(180)
848 imgui.SetCursorPosX(10)
849 if imgui.Combo("##12", productintostorage_comboselect2, producttype) then
850 mainIni.config.ProductTypeToDeliverySecond = producttype[productintostorage_comboselect2.v+1]
851 mainIni.config.ProductTypeNumberToDeliverySecond = productintostorage_comboselect2.v
852 inicfg.save(mainIni, directIni)
853 end
854 imgui.PushItemWidth(180)
855 imgui.SetCursorPosX(10)
856 if imgui.Combo("##13", productintostorage_comboselect3, producttype) then
857 mainIni.config.ProductTypeToDeliveryThird = producttype[productintostorage_comboselect3.v+1]
858 mainIni.config.ProductTypeNumberToDeliveryThird = productintostorage_comboselect3.v
859 inicfg.save(mainIni, directIni)
860 end
861 imgui.PushItemWidth(180)
862 imgui.SetCursorPosX(10)
863 if imgui.Combo("##14", productintostorage_comboselect4, producttype) then
864 mainIni.config.ProductTypeToDeliveryFourth = producttype[productintostorage_comboselect4.v+1]
865 mainIni.config.ProductTypeNumberToDeliveryFourth = productintostorage_comboselect4.v
866 inicfg.save(mainIni, directIni)
867 end
868 imgui.EndChild()
869
870 imgui.SameLine()
871
872 imgui.BeginChild(u8"Окно настройки уведомлений", imgui.ImVec2(340, 200), true)
873 imgui.SetCursorPosY(3)
874 imgui.CenterText(u8"Уведомления")
875 imgui.Separator()
876 imgui.SetCursorPosX(10)
877 if imgui.Checkbox(u8"Уведомление в чат компании о принятии заказа", NotfAboutAcceptingInCompanyChat, 12) then
878 mainIni.config.NotfAboutAcceptingInCC = NotfAboutAcceptingInCompanyChat.v
879 inicfg.save(mainIni, directIni)
880 end
881 imgui.SameLine()
882 imgui.TextQuestion(u8"Автоматически отправляет в /cm сообщение с\nинформацией о новом заказе.")
883 imgui.SetCursorPosX(10)
884 if imgui.Checkbox(u8"Звуковое уведомление об /ans", NotfAns, 13) then
885 mainIni.config.NotfAboutAns = NotfAns.v
886 inicfg.save(mainIni, directIni)
887 end
888 imgui.SameLine()
889 imgui.TextQuestion(u8("Данное уведомление сработает при появлении вопросов\nк вам со стороны администрации."))
890
891 imgui.Separator()
892
893 imgui.CenterText(u8"Уведомления в ВК")
894
895 imgui.SetCursorPosX(10)
896 if imgui.Checkbox(u8"Уведомления об /ans", NotfAnsVK, 14) then
897 mainIni.config.NotfAboutAnsVK = NotfAnsVK.v
898 inicfg.save(mainIni, directIni)
899 end
900 imgui.SameLine()
901 imgui.TextQuestion(u8("Если администратор напишет вам в /ans, то бот группы\nнапишет вам в лс в ВК. Для этого нужно указать\nID ВК вашей страницы ниже."))
902
903 imgui.SetCursorPosX(10)
904 if imgui.Checkbox(u8"Уведомления об изменении позиции персонажа", otherPos, 15) then
905 mainIni.config.PPose = otherPos.v
906 end
907 imgui.SameLine()
908 imgui.TextAlert("{ffffff}Если персонаж изменил свою позицию(например,\n слап админа), то вам придет сообщение об этом в ВК.\n\n {ff5452}Будьте осторожны с данной опцией!\n {ffffff}Она начинает работать при {ff5452}включенной{ffffff}\n ловле заказов.\n {ff5452}Если вы будете двигаться во время работы\n данной функции, {ffffff}то в ВК будет\n лютый спам.")
909
910 imgui.SetCursorPosX(10)
911 if imgui.Checkbox(u8"Уведомление о потере соединения", NotfLostConn, 16) then
912 mainIni.config.NotfAboutLostConnection = NotfLostConn.v
913 inicfg.save(mainIni, directIni)
914 end
915
916 imgui.SetCursorPosX(10)
917 imgui.PushItemWidth(80)
918 if imgui.InputInt("##111", PVKID, 0, 0) then
919 mainIni.config.PlayerVKID = PVKID.v
920 inicfg.save(mainIni, directIni)
921 end
922 imgui.SameLine()
923 imgui.TextQuestion(u8('Укажите Ваш VK ID.\nГде его взять? Самый простой способ:\n • Зайдите в "Настройки" вашего аккаунта\n • В поле "Адрес страницы" нажмите "Изменить"\n • Над кнопкой "Сохранить" будет текст - "Номер страницы - (цифры)"\n • Перепишите эти цифры в поле "VK ID" '))
924 imgui.EndChild()
925 end
926 imgui.End()
927 imgui.PopStyleVar()
928end
929
930function handlePos(pos)
931 if otherPos.v then
932 local x, y, z = getCharCoordinates(PLAYER_PED)
933 sendvknotf('Сервер изменил позицию персонажа на\n X:' .. string.format('%.3f', pos.x) .. ' | Y: ' .. string.format('%.3f', pos.y) .. ' | Z: ' .. string.format('%.3f', pos.z) .. ' | Расстояние: ' .. string.format('%.3f', getDistanceBetweenCoords3d(x, y, z, pos.x, pos.y, pos.z)) .. '\nВозможен телепорт или слап.')
934 end
935end
936
937function sampev.onSetPlayerPos(pos)
938 handlePos(pos)
939end
940
941function sampev.onSetPlayerPosFindZ(pos)
942 handlePos(pos)
943end
944
945function onReceivePacket(id)
946 if NotfLostConn.v then
947 if id == 33 then
948 sendvknotf('Потеряно соединение с сервером. Возможна потеря интернета, или нестабильность сервера. Требуется перезаход.')
949 elseif id == 32 then
950 sendvknotf('Сервер закрыл соединение. Возможен тихий кик, кик или бан. Требуется перезаход.')
951 end
952 end
953end
954------ Текст подсказки
955function imgui.TextQuestion(text)
956 imgui.TextDisabled(fa.ICON_INFO_CIRCLE)
957 if imgui.IsItemHovered() then
958 imgui.PushStyleVar(imgui.StyleVar.WindowRounding, 6)
959 imgui.BeginTooltip()
960 local p = imgui.GetCursorScreenPos()
961 imgui.SetCursorScreenPos(imgui.ImVec2(p.x + 10,p.y + 10))
962 imgui.PushTextWrapPos(450)
963 imgui.TextUnformatted(text)
964 local p = imgui.GetCursorScreenPos()
965 local obrez = imgui.GetFont():CalcTextSizeA(imgui.GetFont().FontSize,450,450,text).x
966 imgui.SetCursorScreenPos(imgui.ImVec2(p.x + obrez + 20,p.y + 10))
967 imgui.PopTextWrapPos()
968 imgui.EndTooltip()
969 imgui.PopStyleVar()
970 end
971end
972
973function imgui.TextAlert(text)
974 imgui.TextDisabled(fa.ICON_EXCLAMATION_TRIANGLE)
975 if imgui.IsItemHovered() then
976 imgui.PushStyleVar(imgui.StyleVar.WindowRounding, 6)
977 imgui.BeginTooltip()
978 local p = imgui.GetCursorScreenPos()
979 imgui.SetCursorScreenPos(imgui.ImVec2(p.x + 10,p.y + 10))
980 imgui.PushTextWrapPos(450)
981 imgui.TextColoredRGB(text)
982 local p = imgui.GetCursorScreenPos()
983 local obrez = imgui.GetFont():CalcTextSizeA(imgui.GetFont().FontSize,450,450,text).x
984 imgui.SetCursorScreenPos(imgui.ImVec2(p.x + obrez + 20,p.y + 10))
985 imgui.PopTextWrapPos()
986 imgui.EndTooltip()
987 imgui.PopStyleVar()
988 end
989end
990
991--------------- ВСЕ ОСТАЛЬНЫЕ ФУНКИ ---------------
992----------- Закрытие окна на клавишу ESC
993function onWindowMessage(m, p)
994 if p == 0x1B and main_window_state.v then
995 consumeWindowMessage()
996 main_window_state.v = false
997 end
998end
999----------- Централизация текста
1000function imgui.CenterText(text)
1001 local width = imgui.GetWindowWidth()
1002 local calc = imgui.CalcTextSize(text)
1003 imgui.SetCursorPosX( width / 2 - calc.x / 2 )
1004 imgui.Text(text)
1005end
1006----------- Сентрализация кнопки
1007function imgui.CenterButton(text)
1008 local width = imgui.GetWindowWidth()
1009 local calc = imgui.CalcTextSize(text)
1010 imgui.SetCursorPosX( width / 2 - calc.x / 2 )
1011 imgui.Button(text)
1012end
1013----------- Скрытие курсора на краш скрипта
1014function onScriptTerminate(LuaScript, quitGame)
1015
1016 if LuaScript == thisScript() and not quitGame then
1017 showCursor(false, false)
1018 end
1019end
1020----------- Вертикальный разделитель
1021function imgui.VerticalSeparator()
1022 local p = imgui.GetCursorScreenPos()
1023 imgui.GetWindowDrawList():AddLine(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x, p.y + imgui.GetContentRegionMax().y), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.Separator]))
1024end
1025----------- Цветной текст в имгуи
1026function imgui.TextColoredRGB(text)
1027 local style = imgui.GetStyle()
1028 local colors = style.Colors
1029 local ImVec4 = imgui.ImVec4
1030
1031 local explode_argb = function(argb)
1032 local a = bit.band(bit.rshift(argb, 24), 0xFF)
1033 local r = bit.band(bit.rshift(argb, 16), 0xFF)
1034 local g = bit.band(bit.rshift(argb, 8), 0xFF)
1035 local b = bit.band(argb, 0xFF)
1036 return a, r, g, b
1037 end
1038
1039 local getcolor = function(color)
1040 if color:sub(1, 6):upper() == 'SSSSSS' then
1041 local r, g, b = colors[1].x, colors[1].y, colors[1].z
1042 local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
1043 return ImVec4(r, g, b, a / 255)
1044 end
1045 local color = type(color) == 'string' and tonumber(color, 16) or color
1046 if type(color) ~= 'number' then return end
1047 local r, g, b, a = explode_argb(color)
1048 return imgui.ImColor(r, g, b, a):GetVec4()
1049 end
1050
1051 local render_text = function(text_)
1052 for w in text_:gmatch('[^\r\n]+') do
1053 local text, colors_, m = {}, {}, 1
1054 w = w:gsub('{(......)}', '{%1FF}')
1055 while w:find('{........}') do
1056 local n, k = w:find('{........}')
1057 local color = getcolor(w:sub(n + 1, k - 1))
1058 if color then
1059 text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
1060 colors_[#colors_ + 1] = color
1061 m = n
1062 end
1063 w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
1064 end
1065 if text[0] then
1066 for i = 0, #text do
1067 imgui.TextColored(colors_[i] or colors[1], u8(text[i]))
1068 imgui.SameLine(nil, 0)
1069 end
1070 imgui.NewLine()
1071 else imgui.Text(u8(w)) end
1072 end
1073 end
1074
1075 render_text(text)
1076end
1077
1078
1079
1080----------- ПРИВЯЗКА СКРИПТА К НИКУ -----------
1081----------- Таблица ников
1082function getTableUsersByUrl(url)
1083 local n_file, bool, users = os.getenv('TEMP')..os.time(), false, {}
1084 downloadUrlToFile(url, n_file, function(id, status)
1085 if status == 6 then bool = true end
1086 end)
1087 while not doesFileExist(n_file) do wait(0) end
1088 if bool then
1089 local file = io.open(n_file, 'r')
1090 for w in file:lines() do
1091 local n, d = w:match('(.*): (.*)')
1092 users[#users+1] = { name = n, date = d }
1093 end
1094 file:close()
1095 os.remove(n_file)
1096 end
1097 return bool, users
1098end
1099----------- Проверка на доступность
1100function isAvailableUser(users, name)
1101 for i, k in pairs(users) do
1102 if k.name == name then
1103 local d, m, y = k.date:match('(%d+)%.(%d+)%.(%d+)')
1104 local time = {
1105 day = tonumber(d),
1106 isdst = true,
1107 wday = 0,
1108 yday = 0,
1109 year = tonumber(y),
1110 month = tonumber(m),
1111 hour = 0
1112 }
1113 if os.time(time) >= os.time() then return true end
1114 end
1115 end
1116 return false
1117end
1118