-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trinity-Bars.lua
650 lines (603 loc) · 22.3 KB
/
Trinity-Bars.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
-- ABOUT SCRIPT
script_name("Trinity Bars")
script_version("1.3")
script_author("eweest")
script_description("04.06.2022")
script_url("https://vk.com/gtatrinitymods")
---- ASSETS [START]
-- LIB
local se = require("lib.samp.events")
-- CHAT
local TAG = "[Trinity Mods]: "
local CMD_HELP = "/bars"
local COLOR_CHAT = {
["DONE"] = "0xFFCC00",
["ERROR"] = "0xFF3232",
}
local TABLE_ID = {
["FOOD"] = -1,
["WATER"] = -1,
["HYGIENE"] = -1,
["INV"] = -1,
["OTHER"] = {}
}
local loadTexture = {}
-- PATHS
local DIRECT = getWorkingDirectory()
local CONFIG_PATH = "/config/"
local FOLDER_MAIN_PATH = "Trinity GTA Mods/"
local FOLDER_PATH = thisScript().name .. "/"
local TEXTURES_PATH = "textures/"
local FONTS_PATH = "fonts/"
local DB_PATH = "settings.json"
-- GIT-HUB PATH
local GIT_REP_AND_NAME = "Trinity-Bars"
local UPDATE_JSON_PATH = "https://raw.githubusercontent.com/eweest/" .. GIT_REP_AND_NAME .. "/main/assets/update.json"
local UPDATE_FILE_PATH = "https://raw.githubusercontent.com/eweest/" .. GIT_REP_AND_NAME .. "/main/" .. GIT_REP_AND_NAME .. ".lua"
-- TEXTURES
local TEXTURES = { -- NAME, URL
["FOOD"] = {"food.png", "https://github.com/eweest/Trinity-Bars/raw/main/assets/textures/food.png"},
["WATER"] = {"water.png", "https://github.com/eweest/Trinity-Bars/raw/main/assets/textures/water.png"},
["HYGIENE"] = {"hygiene.png", "https://github.com/eweest/Trinity-Bars/raw/main/assets/textures/hygiene.png"},
-- STYLE 2
["FOOD_1"] = {"food-1.png", "https://github.com/eweest/Trinity-Bars/raw/main/assets/textures/food-1.png"},
["WATER_1"] = {"water-1.png", "https://github.com/eweest/Trinity-Bars/raw/main/assets/textures/water-1.png"},
["HYGIENE_1"] = {"hygiene-1.png", "https://github.com/eweest/Trinity-Bars/raw/main/assets/textures/hygiene-1.png"}
}
-- FONTS
local FONTS = {
["BARS"] = renderCreateFont("Arial", 8, 5),
["NUMBER"] = renderCreateFont("Pricedown Rus", 32, 4),
["NUMBER-1"] = renderCreateFont("Arial", 14, 5),
}
-- SOUNDS
local SOUNDS = {
["ERROR"] = 1055,
["DONE"] = 1083,
["CANCEL"] = 1085
}
-- CONFIG "settings.json"
local CONFIG = {
["VIEW"] = true,
["ROT"] = "VERTICAL", -- or HORIZONTAL
["posX"] = 500,
["posY"] = 500,
["TYPE"] = 1,
["NUMBER"] = false,
["ICON_STYLE"] = 1,
["AUTOUPDATE"] = false,
["MOVIE"] = false
}
-- SCRIPT FOLDER
if not doesDirectoryExist(DIRECT .. CONFIG_PATH .. FOLDER_MAIN_PATH .. FOLDER_PATH) then
createDirectory(DIRECT .. CONFIG_PATH .. FOLDER_MAIN_PATH .. FOLDER_PATH)
end
-- TEXTURE FOLDER
if not doesDirectoryExist(DIRECT .. CONFIG_PATH .. FOLDER_MAIN_PATH .. FOLDER_PATH .. TEXTURES_PATH) then
createDirectory(DIRECT .. CONFIG_PATH .. FOLDER_MAIN_PATH .. FOLDER_PATH .. TEXTURES_PATH)
end
-- TEXTURES DOWNLOAD
for TEXTURE, NAME_URL in pairs(TEXTURES) do
if not doesFileExist(DIRECT .. CONFIG_PATH .. FOLDER_MAIN_PATH .. FOLDER_PATH .. TEXTURES_PATH .. NAME_URL[1]) then
downloadUrlToFile(NAME_URL[2], DIRECT .. CONFIG_PATH .. FOLDER_MAIN_PATH .. FOLDER_PATH .. TEXTURES_PATH .. NAME_URL[1])
end
end
-- JSON PATH
if not doesFileExist(DIRECT .. CONFIG_PATH .. FOLDER_MAIN_PATH .. FOLDER_PATH .. DB_PATH) then
local file = io.open(DIRECT .. CONFIG_PATH .. FOLDER_MAIN_PATH .. FOLDER_PATH .. DB_PATH, "w")
file:write(encodeJson(CONFIG))
io.close(file)
end
if doesFileExist(DIRECT .. CONFIG_PATH .. FOLDER_MAIN_PATH .. FOLDER_PATH .. DB_PATH) then
local file = io.open(DIRECT .. CONFIG_PATH .. FOLDER_MAIN_PATH .. FOLDER_PATH .. DB_PATH, 'r')
if file then
DB = decodeJson(file:read("*a"))
io.close(file)
end
end
---- ASSETS [END]
-- MAIN [START]
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
-- CHECK UPDATE
if DB["AUTOUPDATE"] then
DB["AUTOUPDATE"] = true
autoupdate(UPDATE_JSON_PATH, TAG, UPDATE_FILE_PATH)
else
print("Àâòîîáíîâëåíèå Îòêëþ÷åíî.")
end
-- TRINITY SERVERS
local IP = sampGetCurrentServerAddress()
local TRINITYGTA_IP = {
["RPG"] = "185.169.134.83",
["RP1"] = "185.169.134.84",
["RP2"] = "185.169.134.85"
}
-- CHECK TRINITY SERVERS
if IP:find(TRINITYGTA_IP["RPG"]) or IP:find(TRINITYGTA_IP["RP1"]) or IP:find(TRINITYGTA_IP["RP2"]) then
-- LOAD TEXTURES
for TEXTURE, PATH in pairs(TEXTURES) do
local TEXTURE_PATH = ( DIRECT .. CONFIG_PATH .. FOLDER_MAIN_PATH .. FOLDER_PATH .. TEXTURES_PATH )
loadTexture[TEXTURE] = renderLoadTextureFromFile(TEXTURE_PATH .. PATH[1])
end
--
TRINITYGTA = true
sampAddChatMessage(TAG .. thisScript().name .."{FFFFFF} çàïóùåí. Àâòîð: {FFCC00}eweest{FFFFFF}. Âåðñèÿ: {FFCC00}" .. thisScript().version .. "{FFFFFF}. Ïîìîùü {FFCC00}" .. CMD_HELP, COLOR_CHAT["DONE"])
else
TRINITYGTA = false
sampAddChatMessage(TAG .. "{FFFFFF}Ñêðèïò " .. thisScript().name .. " (v" .. thisScript().version .. ") íå çàïóùåí, òàê êàê âû èãðûåòå íå íà Trinity GTA.", COLOR_CHAT["DONE"])
unloadScript()
end
----
--| COMMANDS
sampRegisterChatCommand("bars", function(cmd) -- HELP
if (cmd == "position" or cmd == "pos") then -- POSITION
sampAddChatMessage(TAG .. "{FFFFFF}Äëÿ ñîõðàíåíèÿ ïîçèöèè, íàæìèòå {FFCC00}ëåâóþ êíîïêó ìûøè {FFFFFF}èëè{FFCC00} ENTER.", COLOR_CHAT["DONE"])
setPosition = true
-- SETTINGS CMD
elseif (cmd == "number" or cmd == "num") then -- NUMBERS
if (DB["TYPE"] == 1) then
DB["NUMBER"] = not DB["NUMBER"]
if DB["NUMBER"] then
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["DONE"])
sampAddChatMessage(TAG .."{FFFFFF}Ïîêàçàòåëü ïîòðåáíîñòåé ïåðñîíàæà â öèôðàõ {32FF32}âêëþ÷åí.", COLOR_CHAT["DONE"])
DB["NUMBER"] = true
else
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["CANCEL"])
sampAddChatMessage(TAG .."{FFFFFF}Ïîêàçàòåëü ïîòðåáíîñòåé ïåðñîíàæà â öèôðàõ {FF3232}îòêëþ÷åí.", COLOR_CHAT["DONE"])
DB["NUMBER"] = false
end
else
sampAddChatMessage(TAG .."{FFFFFF}Ïîêàçàòåëü ïîòðåáíîñòåé ïåðñîíàæà â öèôðàõ äîñòóïåí òîëüêî â ñòèëå {FFCC00}#1 'Ñòàìèíà'{FFFFFF}.", COLOR_CHAT["DONE"])
end
saveDB()
elseif (cmd == "view" or cmd == "vw") then -- VIEW MODE
DB["VIEW"] = not DB["VIEW"]
if DB["VIEW"] then
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["DONE"])
sampAddChatMessage(TAG .."{FFFFFF}Ïîòðåáíîñòè ïåðñîíàæà {32FF32}âêëþ÷åíû.", COLOR_CHAT["DONE"])
DB["VIEW"] = true
else
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["CANCEL"])
sampAddChatMessage(TAG .."{FFFFFF}Ïîòðåáíîñòè ïåðñîíàæà {FF3232}îòêëþ÷åíû.", COLOR_CHAT["DONE"])
DB["VIEW"] = false
end
saveDB()
elseif (cmd == "rotation" or cmd == "rt") then -- VIEW MODE
if DB["ROT"] ~= "HORIZONTAL" then
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["DONE"])
sampAddChatMessage(TAG .."{FFFFFF}Âû àêòèâèðîâàëè {FFCC00}Ãîðèçîíòàëüíûé{FFFFFF} ðåæèì.", COLOR_CHAT["DONE"])
DB["ROT"] = "HORIZONTAL"
else
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["CANCEL"])
sampAddChatMessage(TAG .."{FFFFFF}Âû àêòèâèðîâàëè {FFCC00}Âåðòèêàëüíûé{FFFFFF} ðåæèì.", COLOR_CHAT["DONE"])
DB["ROT"] = "VERTICAL"
end
saveDB()
-- BARS STYLE
elseif (cmd == "type 1") then -- TYPE 1
if (DB["TYPE"] ~= 1) then
DB["TYPE"] = 1
sampAddChatMessage(TAG .."{FFFFFF}Ñòèëü ïîòðåáíîñòåé ïåðñîíàæà èçìåíåí. Âàðèàíò: {FFCC00} #1 'Ñòàìèíà'.", COLOR_CHAT["DONE"])
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["DONE"])
else
sampAddChatMessage(TAG .."{FFFFFF}Ñòèëü ïîòðåáíîñòåé ïåðñîíàæà {FFCC00}#1 'Ñòàìèíà'{FFFFFF} óæå èñïîëüçóåòñÿ!", COLOR_CHAT["DONE"])
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["ERROR"])
end
saveDB()
elseif (cmd == "type 2") then -- TYPE 2
if (DB["TYPE"] ~= 2) then
DB["TYPE"] = 2
sampAddChatMessage(TAG .."{FFFFFF}Ñòèëü ïîòðåáíîñòåé ïåðñîíàæà èçìåíåí. Âàðèàíò: {FFCC00} #2 'Öèôðû'.", COLOR_CHAT["DONE"])
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["DONE"])
else
sampAddChatMessage(TAG .."{FFFFFF}Ñòèëü ïîòðåáíîñòåé ïåðñîíàæà {FFCC00}#2 'Öèôðû'{FFFFFF} óæå èñïîëüçóåòñÿ!", COLOR_CHAT["DONE"])
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["ERROR"])
end
saveDB()
elseif (cmd == "type 3") then -- TYPE 3
if (DB["TYPE"] ~= 3) then
DB["TYPE"] = 3
sampAddChatMessage(TAG .."{FFFFFF}Ñòèëü ïîòðåáíîñòåé ïåðñîíàæà èçìåíåí. Âàðèàíò: {FFCC00} #3.", COLOR_CHAT["DONE"])
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["DONE"])
else
sampAddChatMessage(TAG .."{FFFFFF}Ñòèëü ïîòðåáíîñòåé ïåðñîíàæà {FFCC00}#3{FFFFFF} óæå èñïîëüçóåòñÿ!", COLOR_CHAT["DONE"])
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["ERROR"])
end
saveDB()
-- ICONS STYLE
elseif (cmd == "icons 1") then -- ICONS 1
if (DB["ICON_STYLE"] ~= 1) then
DB["ICON_STYLE"] = 1
sampAddChatMessage(TAG .."{FFFFFF}Ñòèëü èêîíîê èçìåíåí. Âàðèàíò: {FFCC00} #1.", COLOR_CHAT["DONE"])
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["DONE"])
else
sampAddChatMessage(TAG .."{FFFFFF}Ñòèëü èêîíîê {FFCC00}#1{FFFFFF} óæå èñïîëüçóåòñÿ!", COLOR_CHAT["DONE"])
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["ERROR"])
end
saveDB()
elseif (cmd == "icons 2") then -- ICONS 2
if (DB["ICON_STYLE"] ~= 2) then
DB["ICON_STYLE"] = 2
sampAddChatMessage(TAG .."{FFFFFF}Ñòèëü èêîíîê èçìåíåí. Âàðèàíò: {FFCC00} #2.", COLOR_CHAT["DONE"])
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["DONE"])
else
sampAddChatMessage(TAG .."{FFFFFF}Ñòèëü èêîíîê {FFCC00}#2{FFFFFF} óæå èñïîëüçóåòñÿ!", COLOR_CHAT["DONE"])
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["ERROR"])
end
saveDB()
elseif (cmd == "update" or cmd == "up") then -- UPDATE
DB["AUTOUPDATE"] = not DB["AUTOUPDATE"]
if DB["AUTOUPDATE"] then
DB["AUTOUPDATE"] = true
sampAddChatMessage(TAG .."{FFFFFF}Àâòîîáíîâëåíèå {32FF32}âêëþ÷åíî{FFFFFF}.", COLOR_CHAT["DONE"])
else
DB["AUTOUPDATE"] = false
sampAddChatMessage(TAG .."{FFFFFF}Àâòîîáíîâëåíèå {FF3232}îòêëþ÷åíî{FFFFFF}.", COLOR_CHAT["DONE"])
end
saveDB()
reloadScript()
-- reloadScript()
-- ERROR MSG
elseif #cmd == 0 then -- DONE CMD
cmdHelpCMD()
addOneOffSound(0.0, 0.0, 0.0, 1139)
else
if cmd:find("^type") then -- ERROR TYPE
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["ERROR"])
sampAddChatMessage(TAG .."{FFFFFF}Íåèçâåñòíàÿ êîìàíäà. Ââåäèòå: {FFCC00}" .. CMD_HELP .. " type (1-3)", COLOR_CHAT["ERROR"])
elseif cmd:find("^icons") then -- ERROR ICONS
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["ERROR"])
sampAddChatMessage(TAG .."{FFFFFF}Íåèçâåñòíàÿ êîìàíäà. Ââåäèòå: {FFCC00}" .. CMD_HELP .. " icons (1-2)", COLOR_CHAT["ERROR"])
else -- ERROR CMD
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["ERROR"])
sampAddChatMessage(TAG .."{FFFFFF}Íåèçâåñòíàÿ êîìàíäà. Ââåäèòå: {FFCC00}" .. CMD_HELP, COLOR_CHAT["ERROR"])
end
end
end)
----
while true do wait(0)
if setPosition then
local posX, posY = getCursorPos()
showCursor(true, true)
DB["posX"], DB["posY"] = posX, posY
if isKeyDown(0x01) or isKeyDown(0x0D) then -- LMB or ENTER
showCursor(false, false)
sampAddChatMessage(TAG .. "{FFFFFF}Ïîëîæåíèå ïîòðåáíîñòåé ïåðñîíàæà ñîõðàíåíî.", COLOR_CHAT["DONE"])
addOneOffSound(0.0, 0.0, 0.0, SOUNDS["DONE"])
setPosition = false
saveDB()
end
end
if TRINITYGTA then
if not sampTextdrawIsExists(TABLE_ID["INV"]) then
for key, val in pairs(TABLE_ID["OTHER"]) do
if sampTextdrawIsExists(val) then
sampTextdrawDelete(val)
end
end
if TABLE_ID["FOOD"] ~= -1 then
if sampTextdrawIsExists(TABLE_ID["FOOD"]) then
local posX, posY = sampTextdrawGetPos(TABLE_ID["FOOD"])
if posX ~= -20 and posY ~= -20 then
sampTextdrawSetPos(TABLE_ID["FOOD"], -20, -20)
end
end
end
if TABLE_ID["WATER"] ~= -1 then
if sampTextdrawIsExists(TABLE_ID["WATER"]) then
local posX, posY = sampTextdrawGetPos(TABLE_ID["WATER"])
if posX ~= -20 and posY ~= -20 then
sampTextdrawSetPos(TABLE_ID["WATER"], -20, -20)
end
end
end
if TABLE_ID["HYGIENE"] ~= -1 then
if sampTextdrawIsExists(TABLE_ID["HYGIENE"]) then
local posX, posY = sampTextdrawGetPos(TABLE_ID["HYGIENE"])
if posX ~= -20 and posY ~= -20 then
sampTextdrawSetPos(TABLE_ID["HYGIENE"], -20, -20)
end
end
end
if sampTextdrawIsExists(2060) then
DB["MOVIE"] = false
else
DB["MOVIE"] = true
end
end
--| CREATE BARS
local spawned = sampIsLocalPlayerSpawned()
if spawned then
if not sampTextdrawIsExists(TABLE_ID["INV"]) then
createBarIcon()
end
end
----
end
end
wait(-1)
end
-- CREATE CUSTOM BARS [START]
function createBarIcon()
local plFood = getPlayerFood(TABLE_ID["FOOD"]) -- DATA PLAYER FOOD
local plWater = getPlayerWater(TABLE_ID["WATER"]) -- DATA PLAYER WATER
local plHygiene = getPlayerHygiene(TABLE_ID["HYGIENE"]) -- DATA PLAYER HYGIENE
local sizeX, sizeY = 32, 32
local posX, posY = DB["posX"], DB["posY"]
-- COLORS
local COLORS = {
["WHITE"] = {
["F"] = '0xFFFFFFFF', -- FOOD
["W"] = '0xFFFFFFFF', -- WATER
["H"] = '0xFFFFFFFF', -- HYGIENE
["TEXT"] = '0xFFFFFFFF', -- TEXT
},
["BLACK"] = '0xAA000000',
["RED"] = '0xFFFF0000',
["GREEN"] = '0xFF56AA0E',
["BLUE"] = '0xFF3B79B3',
["YELLOW"] = '0xFFE3A51E',
}
-- COLOR SET
if plFood <= 22 then
COLORS["GREEN"] = COLORS["RED"]
COLORS["WHITE"]["F"] = COLORS["RED"]
end
if plWater <= 22 then
COLORS["YELLOW"] = COLORS["RED"]
COLORS["WHITE"]["W"] = COLORS["RED"]
end
if plHygiene <= 22 then
COLORS["BLUE"] = COLORS["RED"]
COLORS["WHITE"]["H"] = COLORS["RED"]
end
-- ICONS STYLE
local ICON_STYLE = { -- ICON, COLOR_ICON, COLOR_BAR, dataPlayer
["STYLE_1"] = {
{"FOOD", "F", "GREEN", plFood},
{"WATER", "W", "YELLOW", plWater},
{"HYGIENE", "H", "BLUE", plHygiene}
},
["STYLE_2"] = {
{"FOOD_1", "F", "GREEN", plFood},
{"WATER_1", "W", "YELLOW", plWater},
{"HYGIENE_1", "H", "BLUE", plHygiene}
},
}
--
local iconStyle = "STYLE_1"
if DB["ICON_STYLE"] == 1 then
iconStyle = "STYLE_1"
elseif DB["ICON_STYLE"] == 2 then
iconStyle = "STYLE_2"
end
--
if DB["VIEW"] then
if not DB["MOVIE"] then -- MOVIE MODE
if (DB["ROT"] == "HORIZONTAL") then -- HORIZONTAL MODE
if DB["TYPE"] == 1 then --CREATE TYPE 1
for ID, INFO in pairs(ICON_STYLE[iconStyle]) do
renderDrawBox(posX - (130*ID) + 130, posY + 8, 88, 16, COLORS["BLACK"]) -- BG BAR
renderDrawBox(posX - (130*ID) + 134, posY + 12, INFO[4] * 0.76, 8, COLORS[INFO[3]]) -- BARS
renderDrawTexture(loadTexture[INFO[1]], posX - (130*ID) + 96, posY, sizeX, sizeY, 0, COLORS["WHITE"][INFO[2]]) -- ICONS
if DB["NUMBER"] == true then -- NUMBERS
renderFontDrawText(FONTS["BARS"], string.format("%01d", INFO[4] * 0.95), posX - (130*ID) + 166, posY + 8, COLORS["WHITE"]["TEXT"]) -- TEXT
end
end
elseif DB["TYPE"] == 2 then -- CREATE TYPE 2
for ID, INFO in pairs(ICON_STYLE[iconStyle]) do
renderDrawTexture(loadTexture[INFO[1]], posX-(90*ID)+90, posY, sizeX, sizeY, 0, COLORS["WHITE"][INFO[2]]) -- ICONS
renderFontDrawText(FONTS["NUMBER"], string.format("%01d", INFO[4] * 0.95), posX - (90*ID) + 124, posY - 4, COLORS["WHITE"][INFO[2]]) -- TEXT
end
elseif DB["TYPE"] == 3 then -- CREATE TYPE 3
for ID, INFO in pairs(ICON_STYLE[iconStyle]) do
renderDrawBox(posX - (76*ID) + 76, posY, 72, 28, COLORS["BLACK"]) -- BG
renderDrawTexture(loadTexture[INFO[1]], posX - (76*ID) + 80, posY + 2, sizeX - 8, sizeY - 8, 0, COLORS["WHITE"][INFO[2]]) -- ICONS
renderFontDrawText(FONTS["NUMBER-1"], string.format("%01d", INFO[4] * 0.95), posX - (76*ID) + 108, posY + 3, COLORS["WHITE"][INFO[2]]) -- TEXT
end
end
end
if (DB["ROT"] == "VERTICAL") then -- VERTICAL MODE
if DB["TYPE"] == 1 then --CREATE TYPE 1
for ID, INFO in pairs(ICON_STYLE[iconStyle]) do
renderDrawBox(posX, posY + (34*ID) - 26, 88, 16, COLORS["BLACK"]) -- BG BAR
renderDrawBox(posX + 4, posY + (34*ID) - 22, INFO[4] * 0.76, 8, COLORS[INFO[3]]) -- BARS
renderDrawTexture(loadTexture[INFO[1]], posX-34, posY + (36*ID) - 36, sizeX, sizeY, 0, COLORS["WHITE"][INFO[2]]) -- ICONS
if DB["NUMBER"] == true then -- NUMBERS
renderFontDrawText(FONTS["BARS"], string.format("%01d", INFO[4] * 0.95), posX + 36, posY + (34*ID) - 26, COLORS["WHITE"]["TEXT"]) -- TEXT
end
end
elseif DB["TYPE"] == 2 then -- CREATE TYPE 2
for ID, INFO in pairs(ICON_STYLE[iconStyle]) do
renderDrawTexture(loadTexture[INFO[1]], posX - 34, posY + (36*ID) - 36, sizeX, sizeY, 0, COLORS["WHITE"][INFO[2]]) -- ICONS
renderFontDrawText(FONTS["NUMBER"], string.format("%01d", INFO[4] * 0.95), posX, posY + (36*ID) - 41, COLORS["WHITE"][INFO[2]]) -- TEXT
end
elseif DB["TYPE"] == 3 then -- CREATE TYPE 3
for ID, INFO in pairs(ICON_STYLE[iconStyle]) do
renderDrawBox(posX, posY + (32*ID) - 32, 72, 28, COLORS["BLACK"]) -- BG
renderDrawTexture(loadTexture[INFO[1]], posX + 4, posY + (32*ID) - 30, sizeX - 8, sizeY - 8, 0, COLORS["WHITE"][INFO[2]]) -- ICONS
renderFontDrawText(FONTS["NUMBER-1"], string.format("%01d", INFO[4] * 0.95), posX + 32, posY + (32*ID) - 30, COLORS["WHITE"][INFO[2]]) -- TEXT
end
end
end
end
end
end
-- CREATE CUSTOM BARS [END]
-- HELP WINDOW [START]
local TITLE = "Ïîìîùü ïî: {FFFFFF}"
local TITLE_COLOR = "{AFE7FF}"
local TEXT_CMD = [=[
{ffcc00}Îñíîâíûå êîìàíäû:{ffffff}
{AFE7FF}/bars{ffffff} - Îêíî ïîìîùè
{AFE7FF}/bars (pos)ition{ffffff} - Èçìåíåíèå ïîçèöèè
{AFE7FF}/bars type [1-3]{ffffff} - Èçìåíåíèå ñòèëÿ ïîêàçàòåëåé
{AFE7FF}/bars icons [1-2]{ffffff} - Èçìåíåíèå ñòèëÿ èêîíîê
{AFE7FF}/bars rotation(rt){ffffff} - Èçìåíåíèå ðåæèìà (Âåðòèêàëüíî èëè Ãîðèçîíòàëüíî)
{AFE7FF}/bars (num)ber{ffffff} - Ïîêàçàòü/Ñêðûòü öèôðû â ðåæèìå #1 "Ñòàìèíà"
{AFE7FF}/bars view(vw){ffffff} - Ïîêàçàòü/Ñêðûòü
{AFE7FF}/bars (up)date{ffffff} - Àâòîîáíîâëåíèå (Âêëþ÷èòü/Âûêëþ÷èòü)
{ffcc00}Ïîëåçíûå ñîâåòû:{ffffff}
{AFE7FF}[1]{ffffff} Åñëè ïîêàçàòåëè ïîêàçûâàþò "0" è {FF3232}ãîðÿò êðàñíûì{ffffff}, îòêðîéòå è çàêðîéòå èíâåíòàðü.
{AFE7FF}[2]{ffffff} Ïðè çàìåíå èêîíîê íà ñâîè, èñïîëüçóéòå ðàçìåð {ffcc00}32x32{ffffff} ïèêñåëÿ.
{ffcc00}Î ñêðèïòå:{ffffff}
{AFE7FF}Íàçâàíèå (Âåðñèÿ){ffffff} TRINITY Bars {AFE7FF}(v1.3){ffffff}
{AFE7FF}Àâòîð ñêðèïòà{ffffff} eweest
{AFE7FF}Íàøå ñîîáùåñòâî{ffffff} vk.com/gtatrinitymods
{AFE7FF}Äàòà ïîñëåäíåãî îáíîâëåíèÿ{ffffff} 04.06.2022
]=]
if DB["AUTOUPDATE"] == true then
text = "{32FF32}Âêëþ÷åíî"
else
text = "{FF3232}Âûêëþ÷åíî"
end
local TEXT_AUPDATE = "{AFE7FF}Àâòîîáíîâëåíèå {ffffff} " .. text
function cmdHelpCMD()
sampShowDialog(10000, TITLE_COLOR .. TITLE .. thisScript().name, TEXT_CMD .. TEXT_AUPDATE, "X")
end
-- HELP WINDOW [END]
function se.onShowTextDraw(id, data)
if TRINITYGTA then
if data.text:find("A
HEHAP") then
TABLE_ID["INV"] = id
end
-- FIND FOOD BAR
if data.letterColor == -14500865 or data.letterColor == -14518409 then
TABLE_ID["WATER"] = id
end
-- FIND WATER BAR
if data.letterColor == -15744669 or data.letterColor == -13399996 then
TABLE_ID["FOOD"] = id
end
-- FIND HYGIENE BAR
if data.letterColor == -3372988 then
TABLE_ID["HYGIENE"] = id
end
-- FIND BLACK BACKGROUND BAR
if data.letterColor == -16777216 then
if not search(id, TABLE_ID["OTHER"]) then
table.insert(TABLE_ID["OTHER"], id)
end
end
end
end
--
function getPlayerFood(id)
if TRINITYGTA then
if id ~= -1 then
if sampTextdrawIsExists(id) then
local box, color, sizeX, sizeY = sampTextdrawGetBoxEnabledColorAndSize(id)
return sizeX
end
end
end
return 0
end
function getPlayerWater(id)
if TRINITYGTA then
if id ~= -1 then
if sampTextdrawIsExists(id) then
local box, color, sizeX, sizeY = sampTextdrawGetBoxEnabledColorAndSize(id)
return sizeX
end
end
end
return 0
end
function getPlayerHygiene(id)
if TRINITYGTA then
if id ~= -1 then
if sampTextdrawIsExists(id) then
local box, color, sizeX, sizeY = sampTextdrawGetBoxEnabledColorAndSize(id)
return sizeX
end
end
end
return 0
end
function search(str, tab)
if str ~= nil then
for key, val in pairs(tab) do
if str == val then
return true
end
end
end
return false
end
-- SAVE DATABASE
function saveDB()
local file = io.open(DIRECT .. CONFIG_PATH .. FOLDER_MAIN_PATH .. FOLDER_PATH .. DB_PATH, "w")
file:write(encodeJson(DB))
file:flush()
print("Ôàéë íàñòðîåê {FFCC00}'" .. DB_PATH .. "'{CCCCCC} óñïåøíî ñîõðàíåí!")
file:close()
end
-- FUNC RELOAD SCRIPT
function reloadScript()
lua_thread.create(function()
wait(500) thisScript():reload()
end)
end
-- FUNC UNLOAD SCRIPT
function unloadScript()
lua_thread.create(function()
thisScript():unload()
end)
end
-- AUTO-UPDATE (cred: qrlk)
function autoupdate(json_url, prefix, url)
local dlstatus = require('moonloader').download_status
local json = getWorkingDirectory() .. '\\'..thisScript().name..'-version.json'
if doesFileExist(json) then os.remove(json) end
downloadUrlToFile(json_url, json,
function(id, status, p1, p2)
if status == dlstatus.STATUSEX_ENDDOWNLOAD then
if doesFileExist(json) then
local f = io.open(json, 'r')
if f then
local info = decodeJson(f:read('*a'))
updatelink = info.updateurl
updateversion = info.latest
f:close()
os.remove(json)
if updateversion > thisScript().version then
lua_thread.create(function(prefix)
local dlstatus = require('moonloader').download_status
sampAddChatMessage((prefix .. "{FFFFFF}Íàéäåíî îáíîâëåíèå äëÿ ñêðèïòà {FFCC00}" .. thisScript().name .. "."), COLOR_CHAT["DONE"])
sampAddChatMessage((prefix .. "{FFFFFF}Èäåò îáíîâëåíèå c âåðñèè {FFCC00}" .. thisScript().version .. "{FFFFFF} íà âåðñèþ {FFCC00}" .. updateversion), COLOR_CHAT["DONE"])
wait(250)
downloadUrlToFile(updatelink, thisScript().path,
function(id3, status1, p13, p23)
if status1 == dlstatus.STATUS_DOWNLOADINGDATA then
print(string.format("Çàãðóæåíî %d èç %d.", p13, p23))
elseif status1 == dlstatus.STATUS_ENDDOWNLOADDATA then
print("{32FF32}Çàãðóçêà îáíîâëåíèÿ çàâåðøåíà.")
sampAddChatMessage((prefix .. "{FFFFFF}Îáíîâëåíèå {FFCC00}" .. thisScript().name .. "{FFFFFF} çàâåðøåíî!"), COLOR_CHAT["DONE"])
goupdatestatus = true
lua_thread.create(reloadScript()) -- RELOAD SCRIPT
end
if status1 == dlstatus.STATUSEX_ENDDOWNLOAD then
if goupdatestatus == nil then
sampAddChatMessage((prefix .. "Îøèáêà {FFFFFF}îáíîâëåíèÿ. Çàïóñê ñòàðîé âåðñèè..."), COLOR_CHAT["ERROR"])
update = false
end
end
end)
end, prefix)
else
update = false
print("{32FF32}v" .. thisScript().version .. ": Àêòóàëüíàÿ âåðñèÿ. {CCCCCC}Îáíîâëåíèå íå òðåáóåòñÿ.")
end
end
else
print("{FF3232}v" .. thisScript().version .. ": Íå ìîãó ïðîâåðèòü îáíîâëåíèå. {CCCCCC}Ñîîáùèòå îá ýòîì â íàøó ãðóïïó.")
update = false
end
end
end)
while update ~= false do wait(100) end
end
----