This repository was archived by the owner on Mar 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTiagoHoax.lua
8969 lines (8112 loc) · 416 KB
/
TiagoHoax.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
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--==================================================================================================================================================--
--[[ NativeUI\Wrapper\Ordered Table ]]
--==================================================================================================================================================--
oTable = {}
do
function oTable.insert(t, k, v)
if not rawget(t._values, k) then -- new key
t._keys[#t._keys + 1] = k
end
if v == nil then -- delete key too.
oTable.remove(t, k)
else -- update/store value
t._values[k] = v
end
end
local function find(t, value)
for i,v in ipairs(t) do
if v == value then
return i
end
end
end
function oTable.remove(t, k)
local v = t._values[k]
if v ~= nil then
table.remove(t._keys, find(t._keys, k))
t._values[k] = nil
end
return v
end
function oTable.index(t, k)
return rawget(t._values, k)
end
function oTable.pairs(t)
local i = 0
return function()
i = i + 1
local key = t._keys[i]
if key ~= nil then
return key, t._values[key]
end
end
end
function oTable.new(init)
init = init or {}
local t = {_keys={}, _values={}}
local n = #init
if n % 2 ~= 0 then
error"in oTable initialization: key is missing value"
end
for i=1,n/2 do
local k = init[i * 2 - 1]
local v = init[i * 2]
if t._values[k] ~= nil then
error("duplicate key:"..k)
end
t._keys[#t._keys + 1] = k
t._values[k] = v
end
return setmetatable(t,
{__newindex=oTable.insert,
__len=function(t) return #t._keys end,
__pairs=oTable.pairs,
__index=t._values
})
end
end
--==================================================================================================================================================--
--[[ NativeUI\Wrapper\Utility ]]
--==================================================================================================================================================--
do
function table.Contains(table, val)
for index, value in pairs(table) do if value == val then return true end end
return false
end
function table.ContainsKey(table, key)
return table[key] ~= nil
end
function table.Count(table)
local count = 0
if table ~= nil then
for _ in pairs(table) do count = count + 1 end
end
return count
end
function string.IsNullOrEmpty(str) return str == nil or str == '' end
function GetResolution()
local W, H = 1920, 1080
if GetActiveScreenResolution ~= nil then
W, H = GetActiveScreenResolution()
elseif GetScreenActiveResolution ~= nil then
W, H = GetScreenActiveResolution()
else
W, H = N_0x873c9f3104101dd3()
end
if (W / H) > 3.5 then W, H = GetScreenResolution() end
if W < 1920 then W = 1920 end
if H < 1080 then H = 1080 end
return W, H
end
function FormatXWYH(Value, Value2)
local W, H = GetScreenResolution()
local AW, AH = GetResolution()
local XW = Value * (1 / W - ((1 / W) - (1 / AW)))
local YH = Value2 * (1 / H - ((1 / H) - (1 / AH)))
return XW, YH
end
function ReverseFormatXWYH(Value, Value2)
local W, H = GetScreenResolution()
local AW, AH = GetResolution()
local XW = Value / (1 / W - (1 * (1 / W) - (1 / AW)))
local YH = Value2 / (1 / H - ((1 / H) - (1 / AH)))
return XW, YH
end
function ConvertToPixel(x, y)
local AW, AH = GetResolution()
return math.round(x * AW), math.round(y * AH)
end
function math.round(num, numDecimalPlaces) return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num)) end
function math.trim(value) if value then return (string.gsub(value, "^%s*(.-)%s*$", "%1")) else return nil end end
function ToBool(input)
if input == "true" or tonumber(input) == 1 or input == true then
return true
else
return false
end
end
function string.split(inputstr, sep)
if sep == nil then sep = "%s" end
local t = {}
local i = 1
for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
t[i] = str
i = i + 1
end
return t
end
function string.starts(String, Start) return string.sub(String, 1, string.len(Start)) == Start end
function IsMouseInBounds(X, Y, Width, Height, DrawOffset)
local W, H = GetResolution()
local MX, MY = math.round(GetControlNormal(0, 239) * W), math.round(GetControlNormal(0, 240) * H)
MX, MY = FormatXWYH(MX, MY)
X, Y = FormatXWYH(X, Y)
if DrawOffset then
X = X + DrawOffset.X
Y = Y + DrawOffset.Y
end
Width, Height = FormatXWYH(Width, Height)
return (MX >= X and MX <= X + Width) and (MY > Y and MY < Y + Height)
end
function TableDump(o)
if type(o) == 'table' then
local s = '{ '
for k, v in pairs(o) do
if type(k) ~= 'number' then k = '"' .. k .. '"' end
s = s .. '[' .. k .. '] = ' .. TableDump(v) .. ','
end
return s .. '} '
else
return print(tostring(o))
end
end
function Controller()
return not GetLastInputMethod(2) -- IsInputDisabled() --N_0xA571D46727E2B718
end
function RenderText(Text, X, Y, Font, Scale, R, G, B, A, Alignment, DropShadow, Outline, WordWrap)
Text = tostring(Text)
X, Y = FormatXWYH(X, Y)
SetTextFont(Font or 0)
SetTextScale(1.0, Scale or 0)
SetTextColour(R or 255, G or 255, B or 255, A or 255)
if DropShadow then SetTextDropShadow() end
if Outline then SetTextOutline() end
if Alignment ~= nil then
if Alignment == 1 or Alignment == "Center" or Alignment == "Centre" then
SetTextCentre(true)
elseif Alignment == 2 or Alignment == "Right" then
SetTextRightJustify(true)
SetTextWrap(0, X)
end
end
if tonumber(WordWrap) then
if tonumber(WordWrap) ~= 0 then
WordWrap, _ = FormatXWYH(WordWrap, 0)
SetTextWrap(WordWrap, X - WordWrap)
end
end
if BeginTextCommandDisplayText ~= nil then
BeginTextCommandDisplayText("STRING")
else
SetTextEntry("STRING")
end
AddLongString(Text)
if EndTextCommandDisplayText ~= nil then
EndTextCommandDisplayText(X, Y)
else
DrawText(X, Y)
end
end
function DrawRectangle(X, Y, Width, Height, R, G, B, A)
X, Y, Width, Height = X or 0, Y or 0, Width or 0, Height or 0
X, Y = FormatXWYH(X, Y)
Width, Height = FormatXWYH(Width, Height)
DrawRect(X + Width * 0.5, Y + Height * 0.5, Width, Height, tonumber(R) or 255, tonumber(G) or 255, tonumber(B) or 255,
tonumber(A) or 255)
end
function DrawTexture(TxtDictionary, TxtName, X, Y, Width, Height, Heading, R, G, B, A)
if not HasStreamedTextureDictLoaded(tostring(TxtDictionary) or "") then
RequestStreamedTextureDict(tostring(TxtDictionary) or "", true)
end
X, Y, Width, Height = X or 0, Y or 0, Width or 0, Height or 0
X, Y = FormatXWYH(X, Y)
Width, Height = FormatXWYH(Width, Height)
DrawSprite(tostring(TxtDictionary) or "", tostring(TxtName) or "", X + Width * 0.5, Y + Height * 0.5, Width, Height,
tonumber(Heading) or 0, tonumber(R) or 255, tonumber(G) or 255, tonumber(B) or 255, tonumber(A) or 255)
end
function PrintTable(node)
-- to make output beautiful
local function tab(amt)
local str = ""
for i = 1, amt do str = str .. "\t" end
return str
end
local cache, stack, output = {}, {}, {}
local depth = 1
local output_str = "{\n"
while true do
local size = 0
for k, v in pairs(node) do size = size + 1 end
local cur_index = 1
for k, v in pairs(node) do
if (cache[node] == nil) or (cur_index >= cache[node]) then
if (string.find(output_str, "}", output_str:len())) then
output_str = output_str .. ",\n"
elseif not (string.find(output_str, "\n", output_str:len())) then
output_str = output_str .. "\n"
end
-- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings
table.insert(output, output_str)
output_str = ""
local key
if (type(k) == "number" or type(k) == "boolean") then
key = "[" .. tostring(k) .. "]"
else
key = "['" .. tostring(k) .. "']"
end
if (type(v) == "number" or type(v) == "boolean") then
output_str = output_str .. tab(depth) .. key .. " = " .. tostring(v)
elseif (type(v) == "table") then
output_str = output_str .. tab(depth) .. key .. " = {\n"
table.insert(stack, node)
table.insert(stack, v)
cache[node] = cur_index + 1
break
else
output_str = output_str .. tab(depth) .. key .. " = '" .. tostring(v) .. "'"
end
if (cur_index == size) then
output_str = output_str .. "\n" .. tab(depth - 1) .. "}"
else
output_str = output_str .. ","
end
else
-- close the table
if (cur_index == size) then output_str = output_str .. "\n" .. tab(depth - 1) .. "}" end
end
cur_index = cur_index + 1
end
if (size == 0) then output_str = output_str .. "\n" .. tab(depth - 1) .. "}" end
if (#stack > 0) then
node = stack[#stack]
stack[#stack] = nil
depth = cache[node] == nil and depth + 1 or depth - 1
else
break
end
end
-- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings
table.insert(output, output_str)
output_str = table.concat(output)
print(output_str)
end
--[[ Rainbow Color Generator ]]
function GenerateRainbow(frequency)
local result = {}
local curtime = GetGameTimer() / 1000
result.r = math.floor(math.sin(curtime * frequency + 0) * 127 + 128)
result.g = math.floor(math.sin(curtime * frequency + 2) * 127 + 128)
result.b = math.floor(math.sin(curtime * frequency + 4) * 127 + 128)
return result
end
end
--==================================================================================================================================================--
--[[ NativeUI\UIElements\UIVisual ]]
--==================================================================================================================================================--
UIVisual = setmetatable({}, UIVisual)
UIVisual.__index = UIVisual
do
function UIVisual:Popup(array)
ClearPrints()
if (array.colors == nil) then
SetNotificationBackgroundColor(140)
else
SetNotificationBackgroundColor(array.colors)
end
SetNotificationTextEntry("STRING")
if (array.message == nil) then
error("Missing arguments, message")
else
AddTextComponentString(tostring(array.message))
end
DrawNotification(false, true)
if (array.sound ~= nil) then
if (array.sound.audio_name ~= nil) then
if (array.sound.audio_ref ~= nil) then
PlaySoundFrontend(-1, array.sound.audio_name, array.sound.audio_ref, true)
else
error("Missing arguments, audio_ref")
end
else
error("Missing arguments, audio_name")
end
end
end
function UIVisual:PopupChar(array)
if (array.colors == nil) then
SetNotificationBackgroundColor(140)
else
SetNotificationBackgroundColor(array.colors)
end
SetNotificationTextEntry("STRING")
if (array.message == nil) then
error("Missing arguments, message")
else
AddTextComponentString(tostring(array.message))
end
if (array.request_stream_texture_dics ~= nil) then RequestStreamedTextureDict(array.request_stream_texture_dics) end
if (array.picture ~= nil) then
if (array.iconTypes == 1) or (array.iconTypes == 2) or (array.iconTypes == 3) or (array.iconTypes == 7) or
(array.iconTypes == 8) or (array.iconTypes == 9) then
SetNotificationMessage(tostring(array.picture), tostring(array.picture), true, array.iconTypes, array.sender, array.title)
else
SetNotificationMessage(tostring(array.picture), tostring(array.picture), true, 4, array.sender, array.title)
end
else
if (array.iconTypes == 1) or (array.iconTypes == 2) or (array.iconTypes == 3) or (array.iconTypes == 7) or
(array.iconTypes == 8) or (array.iconTypes == 9) then
SetNotificationMessage('CHAR_ALL_PLAYERS_CONF', 'CHAR_ALL_PLAYERS_CONF', true, array.iconTypes, array.sender, array.title)
else
SetNotificationMessage('CHAR_ALL_PLAYERS_CONF', 'CHAR_ALL_PLAYERS_CONF', true, 4, array.sender, array.title)
end
end
if (array.sound ~= nil) then
if (array.sound.audio_name ~= nil) then
if (array.sound.audio_ref ~= nil) then
PlaySoundFrontend(-1, array.sound.audio_name, array.sound.audio_ref, true)
else
error("Missing arguments, audio_ref")
end
else
error("Missing arguments, audio_name")
end
end
DrawNotification(false, true)
end
function UIVisual:Text(array)
ClearPrints()
SetTextEntry_2("STRING")
if (array.message ~= nil) then
AddTextComponentString(tostring(array.message))
else
error("Missing arguments, message")
end
if (array.time_display ~= nil) then
DrawSubtitleTimed(tonumber(array.time_display), 1)
else
DrawSubtitleTimed(6000, 1)
end
if (array.sound ~= nil) then
if (array.sound.audio_name ~= nil) then
if (array.sound.audio_ref ~= nil) then
PlaySoundFrontend(-1, array.sound.audio_name, array.sound.audio_ref, true)
else
error("Missing arguments, audio_ref")
end
else
error("Missing arguments, audio_name")
end
end
end
function UIVisual:FloatingHelpText(array)
BeginTextCommandDisplayHelp("STRING")
if (array.message ~= nil) then
AddTextComponentScaleform(array.message)
else
error("Missing arguments, message")
end
EndTextCommandDisplayHelp(0, 0, 1, -1)
if (array.sound ~= nil) then
if (array.sound.audio_name ~= nil) then
if (array.sound.audio_ref ~= nil) then
PlaySoundFrontend(-1, array.sound.audio_name, array.sound.audio_ref, true)
else
error("Missing arguments, audio_ref")
end
else
error("Missing arguments, audio_name")
end
end
end
function UIVisual:ShowFreemodeMessage(array)
if (array.sound ~= nil) then
if (array.sound.audio_name ~= nil) then
if (array.sound.audio_ref ~= nil) then
PlaySoundFrontend(-1, array.sound.audio_name, array.sound.audio_ref, true)
else
error("Missing arguments, audio_ref")
end
else
error("Missing arguments, audio_name")
end
end
if (array.request_scaleform ~= nil) then
local scaleform = Pyta.Request.Scaleform({movie = array.request_scaleform.movie})
if (array.request_scaleform.scale ~= nil) then
PushScaleformMovieFunction(scaleform, array.request_scaleform.scale)
else
PushScaleformMovieFunction(scaleform, 'SHOW_SHARD_WASTED_MP_MESSAGE')
end
else
local scaleform = Pyta.Request.Scaleform({movie = 'MP_BIG_MESSAGE_FREEMODE'})
if (array.request_scaleform.scale ~= nil) then
PushScaleformMovieFunction(scaleform, array.request_scaleform.scale)
else
PushScaleformMovieFunction(scaleform, 'SHOW_SHARD_WASTED_MP_MESSAGE')
end
end
if (array.title ~= nil) then
PushScaleformMovieFunctionParameterString(array.title)
else
ConsoleLog({message = 'Missing arguments { title = "Nice title" } '})
end
if (array.message ~= nil) then
PushScaleformMovieFunctionParameterString(array.message)
else
ConsoleLog({message = 'Missing arguments { message = "Yeah display message right now" } '})
end
if (array.shake_gameplay ~= nil) then ShakeGameplayCam(array.shake_gameplay, 1.0) end
if (array.screen_effect_in ~= nil) then StartScreenEffect(array.screen_effect_in, 0, 0) end
PopScaleformMovieFunctionVoid()
while array.time > 0 do
Citizen.Wait(1)
array.time = array.time - 1.0
StopScreenEffect(scaleform, 255, 255, 255, 255)
end
if (array.screen_effect_in ~= nil) then StopScreenEffect(array.screen_effect_in) end
if (array.screen_effect_out ~= nil) then StartScreenEffect(array.screen_effect_out, 0, 0) end
SetScaleformMovieAsNoLongerNeeded(scaleform)
end
end
--==================================================================================================================================================--
--[[ NativeUI\UIElements\UIResRectangle ]]
--==================================================================================================================================================--
UIResRectangle = setmetatable({}, UIResRectangle)
UIResRectangle.__index = UIResRectangle
UIResRectangle.__call = function() return "Rectangle" end
do
function UIResRectangle.New(X, Y, Width, Height, R, G, B, A)
local _UIResRectangle = {
X = tonumber(X) or 0,
Y = tonumber(Y) or 0,
Width = tonumber(Width) or 0,
Height = tonumber(Height) or 0,
_Colour = {R = tonumber(R) or 255, G = tonumber(G) or 255, B = tonumber(B) or 255, A = tonumber(A) or 255}
}
return setmetatable(_UIResRectangle, UIResRectangle)
end
function UIResRectangle:Position(X, Y)
if tonumber(X) and tonumber(Y) then
self.X = tonumber(X)
self.Y = tonumber(Y)
else
return {X = self.X, Y = self.Y}
end
end
function UIResRectangle:Size(Width, Height)
if tonumber(Width) and tonumber(Height) then
self.Width = tonumber(Width)
self.Height = tonumber(Height)
else
return {Width = self.Width, Height = self.Height}
end
end
function UIResRectangle:Colour(R, G, B, A)
if tonumber(R) or tonumber(G) or tonumber(B) or tonumber(A) then
self._Colour.R = tonumber(R) or 255
self._Colour.B = tonumber(B) or 255
self._Colour.G = tonumber(G) or 255
self._Colour.A = tonumber(A) or 255
else
return self._Colour
end
end
function UIResRectangle:Draw()
local Position = self:Position()
local Size = self:Size()
Size.Width, Size.Height = FormatXWYH(Size.Width, Size.Height)
Position.X, Position.Y = FormatXWYH(Position.X, Position.Y)
DrawRect(Position.X + Size.Width * 0.5, Position.Y + Size.Height * 0.5, Size.Width, Size.Height, self._Colour.R, self._Colour.G,
self._Colour.B, self._Colour.A)
end
end
--==================================================================================================================================================--
--[[ NativeUI\UIElements\UIResText ]]
--==================================================================================================================================================--
UIResText = setmetatable({}, UIResText)
UIResText.__index = UIResText
UIResText.__call = function() return "Text" end
do
function GetCharacterCount(str)
local characters = 0
for c in str:gmatch("[%z\1-\127\194-\244][\128-\191]*") do
local a = c:byte(1, -1)
if a ~= nil then characters = characters + 1 end
end
return characters
end
function GetByteCount(str)
local bytes = 0
for c in str:gmatch("[%z\1-\127\194-\244][\128-\191]*") do
local a, b, c, d = c:byte(1, -1)
if a ~= nil then bytes = bytes + 1 end
if b ~= nil then bytes = bytes + 1 end
if c ~= nil then bytes = bytes + 1 end
if d ~= nil then bytes = bytes + 1 end
end
return bytes
end
function AddLongStringForAscii(str)
local maxByteLengthPerString = 99
for i = 1, GetCharacterCount(str), maxByteLengthPerString do
AddTextComponentString(string.sub(str, i, i + maxByteLengthPerString))
end
end
function AddLongStringForUtf8(str)
local maxByteLengthPerString = 99
local bytecount = GetByteCount(str)
local charcount = GetCharacterCount(str)
if bytecount < maxByteLengthPerString then
AddTextComponentString(str)
return
end
local startIndex = 0
for i = 0, charcount, 1 do
local length = i - startIndex
if GetByteCount(string.sub(str, startIndex, length)) > maxByteLengthPerString then
AddTextComponentString(string.sub(str, startIndex, length - 1))
i = i - 1
startIndex = startIndex + (length - 1)
end
end
AddTextComponentString(string.sub(str, startIndex, charcount - startIndex))
end
function AddLongString(str)
local bytecount = GetByteCount(str)
if bytecount == GetCharacterCount(str) then
AddLongStringForAscii(str)
else
AddLongStringForUtf8(str)
end
end
function MeasureStringWidthNoConvert(str, font, scale)
SetTextEntryForWidth("STRING")
AddLongString(str)
SetTextFont(font or 0)
SetTextScale(1.0, scale or 0)
if EndTextCommandGetWidth ~= nil then
return EndTextCommandGetWidth(true)
else
return GetTextScreenWidth(true)
end
end
function MeasureStringWidth(str, font, scale)
local W, H = GetResolution()
return MeasureStringWidthNoConvert(str, font, scale) * W
end
function UIResText.New(Text, X, Y, Scale, R, G, B, A, Font, Alignment, DropShadow, Outline, WordWrap, LongText)
local _UIResText = {
_Text = tostring(Text) or "",
X = tonumber(X) or 0,
Y = tonumber(Y) or 0,
Scale = tonumber(Scale) or 0,
_Colour = {R = tonumber(R) or 255, G = tonumber(G) or 255, B = tonumber(B) or 255, A = tonumber(A) or 255},
Font = tonumber(Font) or 0,
Alignment = Alignment or nil,
DropShadow = DropShadow or nil,
Outline = Outline or nil,
WordWrap = tonumber(WordWrap) or 0,
LongText = ToBool(LongText) or false
}
return setmetatable(_UIResText, UIResText)
end
function UIResText:Position(X, Y)
if tonumber(X) and tonumber(Y) then
self.X = tonumber(X)
self.Y = tonumber(Y)
else
return {X = self.X, Y = self.Y}
end
end
function UIResText:Colour(R, G, B, A)
if tonumber(R) and tonumber(G) and tonumber(B) and tonumber(A) then
self._Colour.R = tonumber(R)
self._Colour.B = tonumber(B)
self._Colour.G = tonumber(G)
self._Colour.A = tonumber(A)
else
return self._Colour
end
end
function UIResText:Text(Text)
if tostring(Text) and Text ~= nil then
self._Text = tostring(Text)
else
return self._Text
end
end
function UIResText:Draw()
local Position = self:Position()
Position.X, Position.Y = FormatXWYH(Position.X, Position.Y)
SetTextFont(self.Font)
SetTextScale(1.0, self.Scale)
SetTextColour(self._Colour.R, self._Colour.G, self._Colour.B, self._Colour.A)
if self.DropShadow then SetTextDropShadow() end
if self.Outline then SetTextOutline() end
if self.Alignment ~= nil then
if self.Alignment == 1 or self.Alignment == "Center" or self.Alignment == "Centre" then
SetTextCentre(true)
elseif self.Alignment == 2 or self.Alignment == "Right" then
SetTextRightJustify(true)
SetTextWrap(0, Position.X)
end
end
if tonumber(self.WordWrap) then
if tonumber(self.WordWrap) ~= 0 then
SetTextWrap(Position.X, Position.X + (tonumber(self.WordWrap) / Resolution.Width))
end
end
if BeginTextCommandDisplayText ~= nil then
BeginTextCommandDisplayText(self.LongText and "CELL_EMAIL_BCON" or "STRING");
else
SetTextEntry(self.LongText and "CELL_EMAIL_BCON" or "STRING");
end
AddLongString(self._Text)
if EndTextCommandDisplayText ~= nil then
EndTextCommandDisplayText(Position.X, Position.Y)
else
DrawText(Position.X, Position.Y)
end
end
end
--==================================================================================================================================================--
--[[ NativeUI\UIElements\Sprite ]]
--==================================================================================================================================================--
Sprite = setmetatable({}, Sprite)
Sprite.__index = Sprite
Sprite.__call = function() return "Sprite" end
do
function Sprite.New(TxtDictionary, TxtName, X, Y, Width, Height, Heading, R, G, B, A)
local _Sprite = {
TxtDictionary = tostring(TxtDictionary),
TxtName = tostring(TxtName),
X = tonumber(X) or 0,
Y = tonumber(Y) or 0,
Width = tonumber(Width) or 0,
Height = tonumber(Height) or 0,
Heading = tonumber(Heading) or 0,
_Colour = {R = tonumber(R) or 255, G = tonumber(G) or 255, B = tonumber(B) or 255, A = tonumber(A) or 255}
}
return setmetatable(_Sprite, Sprite)
end
function Sprite:Position(X, Y)
if tonumber(X) and tonumber(Y) then
self.X = tonumber(X)
self.Y = tonumber(Y)
else
return {X = self.X, Y = self.Y}
end
end
function Sprite:Size(Width, Height)
if tonumber(Width) and tonumber(Width) then
self.Width = tonumber(Width)
self.Height = tonumber(Height)
else
return {Width = self.Width, Height = self.Height}
end
end
function Sprite:Colour(R, G, B, A)
if tonumber(R) or tonumber(G) or tonumber(B) or tonumber(A) then
self._Colour.R = tonumber(R) or 255
self._Colour.B = tonumber(B) or 255
self._Colour.G = tonumber(G) or 255
self._Colour.A = tonumber(A) or 255
else
return self._Colour
end
end
function Sprite:Draw()
if not HasStreamedTextureDictLoaded(self.TxtDictionary) then RequestStreamedTextureDict(self.TxtDictionary, true) end
local Position = self:Position()
local Size = self:Size()
Size.Width, Size.Height = FormatXWYH(Size.Width, Size.Height)
Position.X, Position.Y = FormatXWYH(Position.X, Position.Y)
DrawSprite(self.TxtDictionary, self.TxtName, Position.X + Size.Width * 0.5, Position.Y + Size.Height * 0.5, Size.Width, Size.Height,
self.Heading, self._Colour.R, self._Colour.G, self._Colour.B, self._Colour.A)
end
end
--==================================================================================================================================================--
--[[ NativeUI\UIMenu\elements\Badge ]]
--==================================================================================================================================================--
BadgeStyle = {
None = 0,
BronzeMedal = 1,
GoldMedal = 2,
SilverMedal = 3,
Alert = 4,
Crown = 5,
Ammo = 6,
Armour = 7,
Barber = 8,
Clothes = 9,
Franklin = 10,
Bike = 11,
Car = 12,
Gun = 13,
Heart = 14,
Makeup = 15,
Mask = 16,
Michael = 17,
Star = 18,
Tattoo = 19,
Trevor = 20,
Lock = 21,
Tick = 22,
Sale = 23,
ArrowLeft = 24,
ArrowRight = 25,
Audio1 = 26,
Audio2 = 27,
Audio3 = 28,
AudioInactive = 29,
AudioMute = 30,
Info = 31,
MenuArrow = 32,
GTAV = 33
}
BadgeTexture = {
[0] = function() return "" end,
[1] = function() return "mp_medal_bronze" end,
[2] = function() return "mp_medal_gold" end,
[3] = function() return "mp_medal_silver" end,
[4] = function() return "mp_alerttriangle" end,
[5] = function() return "mp_hostcrown" end,
[6] = function(Selected)
if Selected then
return "shop_ammo_icon_b"
else
return "shop_ammo_icon_a"
end
end,
[7] = function(Selected)
if Selected then
return "shop_armour_icon_b"
else
return "shop_armour_icon_a"
end
end,
[8] = function(Selected)
if Selected then
return "shop_barber_icon_b"
else
return "shop_barber_icon_a"
end
end,
[9] = function(Selected)
if Selected then
return "shop_clothing_icon_b"
else
return "shop_clothing_icon_a"
end
end,
[10] = function(Selected)
if Selected then
return "shop_franklin_icon_b"
else
return "shop_franklin_icon_a"
end
end,
[11] = function(Selected)
if Selected then
return "shop_garage_bike_icon_b"
else
return "shop_garage_bike_icon_a"
end
end,
[12] = function(Selected)
if Selected then
return "shop_garage_icon_b"
else
return "shop_garage_icon_a"
end
end,
[13] = function(Selected)
if Selected then
return "shop_gunclub_icon_b"
else
return "shop_gunclub_icon_a"
end
end,
[14] = function(Selected)
if Selected then
return "shop_health_icon_b"
else
return "shop_health_icon_a"
end
end,
[15] = function(Selected)
if Selected then
return "shop_makeup_icon_b"
else
return "shop_makeup_icon_a"
end
end,
[16] = function(Selected)
if Selected then
return "shop_mask_icon_b"
else
return "shop_mask_icon_a"
end
end,
[17] = function(Selected)
if Selected then
return "shop_michael_icon_b"
else
return "shop_michael_icon_a"
end
end,
[18] = function() return "shop_new_star" end,
[19] = function(Selected)
if Selected then
return "shop_tattoos_icon_b"
else
return "shop_tattoos_icon_a"
end
end,
[20] = function(Selected)
if Selected then
return "shop_trevor_icon_b"
else
return "shop_trevor_icon_a"
end
end,
[21] = function() return "shop_lock" end,
[22] = function() return "shop_tick_icon" end,
[23] = function() return "saleicon" end,
[24] = function() return "arrowleft" end,
[25] = function() return "arrowright" end,
[26] = function() return "leaderboard_audio_1" end,
[27] = function() return "leaderboard_audio_2" end,
[28] = function() return "leaderboard_audio_3" end,
[29] = function() return "leaderboard_audio_inactive" end,
[30] = function() return "leaderboard_audio_mute" end,
[31] = function() return "info_icon_32" end,
[32] = function() return "menuarrow_32" end,
[33] = function() return "mpgroundlogo_bikers" end
}
BadgeDictionary = {
[0] = function(Selected)
if Selected then
return "commonmenu"
else
return "commonmenu"
end
end,
[31] = function(Selected)
if Selected then
return "shared"
else
return "shared"
end
end,
[32] = function(Selected)
if Selected then
return "shared"
else
return "shared"
end
end,
[33] = function(Selected)
if Selected then
return "3dtextures"
else
return "3dtextures"
end
end
}
BadgeColour = {
[5] = function(Selected)
if Selected then
return 0, 0, 0, 255
else
return 255, 255, 255, 255
end
end,
[21] = function(Selected)
if Selected then
return 0, 0, 0, 255
else
return 255, 255, 255, 255
end
end,