-
Notifications
You must be signed in to change notification settings - Fork 0
/
pf_thirdp.lua
1516 lines (1472 loc) · 72.8 KB
/
pf_thirdp.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
-- Services
local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")
local plrs = game:GetService("Players")
local ws = game:GetService("Workspace")
-- Local
local plr = plrs.LocalPlayer
local fake_rep_object = nil
local game_client = {}
do -- Client Collector
local garbage = getgc(true)
local loaded_modules = getloadedmodules()
for i = 1, #garbage do
local v = garbage[i]
if typeof(v) == "table" then
if rawget(v, "send") and rawget(v, "fetch") then -- Networking Module
game_client.network = v
elseif rawget(v, "getCharacterObject") then -- Used for sending LocalPlayer Character Data to Server
game_client.character_interface = v
elseif rawget(v, "updateReplication") and rawget(v, "getThirdPersonObject") then -- This represents a "Player" separate from their character
game_client.replication_object = v
elseif rawget(v, "getController") then -- Weapon Detection
game_client.weapon_controller_interface = v
elseif rawget(v, "getCharacterModel") and rawget(v, 'popCharacterModel') then -- Used for Displaying other Characters
game_client.third_person_object = v
end
end
end
for i = 1, #loaded_modules do
local v = loaded_modules[i]
if v.Name == "ActiveLoadoutUtils" then
game_client.active_loadout = require(v)
elseif v.Name == "GameClock" then
game_client.game_clock = require(v)
elseif v.Name == "PlayerDataStoreClient" then
game_client.player_data = require(v)
elseif v.Name == "ContentDatabase" then
game_client.content_database = require(v)
end
end
end
local old_send = game_client.network.send
local old_new_index
local library = {}
local utility = {}
local shared = {
drawings = {},
connections = {},
hidden_connections = {},
pointers = {},
theme = {
inline = Color3.fromRGB(6, 6, 6),
dark = Color3.fromRGB(24, 24, 24),
text = Color3.fromRGB(255, 255, 255),
section = Color3.fromRGB(150, 150, 150),
accent = Color3.fromRGB(0, 102, 255)
},
accents = {},
moveKeys = {
["Movement"] = {
["Up"] = "Up",
["Down"] = "Down"
},
["Action"] = {
["Return"] = "Enter",
["Left"] = "Left",
["Right"] = "Right"
}
},
allowedKeyCodes = {"Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","Z","X","C","V","B","N","M","One","Two","Three","Four","Five","Six","Seveen","Eight","Nine","0","Insert","Tab","Home","End","LeftAlt","LeftControl","LeftShift","RightAlt","RightControl","RightShift","CapsLock","Return","Up","Down","Left","Right"},
allowedInputTypes = {"MouseButton1","MouseButton2","MouseButton3"},
shortenedInputs = {["MouseButton1"] = "MB1", ["MouseButton2"] = "MB2", ["MouseButton3"] = "MB3", ["Insert"] = "Ins", ["LeftAlt"] = "LAlt", ["LeftControl"] = "LCtrl", ["LeftShift"] = "LShift", ["RightAlt"] = "RAlt", ["RightControl"] = "RCtrl", ["RightShift"] = "RShift", ["CapsLock"] = "Caps"},
colors = {Color3.fromRGB(255, 0, 0), Color3.fromRGB(255, 100, 0), Color3.fromRGB(255, 200, 0), Color3.fromRGB(210, 255, 0), Color3.fromRGB(110, 255, 0), Color3.fromRGB(10, 255, 0), Color3.fromRGB(0, 255, 90), Color3.fromRGB(0, 255, 190), Color3.fromRGB(0, 220, 255), Color3.fromRGB(0, 120, 255), Color3.fromRGB(0, 20, 255), Color3.fromRGB(80, 0, 255), Color3.fromRGB(180, 0, 255), Color3.fromRGB(255, 0, 230), Color3.fromRGB(255, 0, 130), Color3.fromRGB(255, 255, 255), Color3.fromRGB(0, 0, 0)},
toggleKey = {Enum.KeyCode.Home, true},
unloadKey = {Enum.KeyCode.End, true},
windowActive = true
}
-- Utility Functions
do
function utility:Create(instanceType, instanceProperties)
local instance = Drawing.new(instanceType)
local parent
--
if instanceProperties["Parent"] or instanceProperties["parent"] then
parent = instanceProperties["Parent"] or instanceProperties["parent"]
--
instanceProperties["parent"] = nil
instanceProperties["Parent"] = nil
end
--
for property, value in pairs(instanceProperties) do
if property and value then
if property == "Size" or property == "Size" then
if instanceType == "Text" then
instance.Size = value
else
local xSize = (value.X.Scale * ((parent and parent.Size) or ws.CurrentCamera.ViewportSize).X) + value.X.Offset
local ySize = (value.Y.Scale * ((parent and parent.Size) or ws.CurrentCamera.ViewportSize).Y) + value.Y.Offset
--
instance.Size = Vector2.new(xSize, ySize)
end
elseif property == "Position" or property == "position" then
if instanceType == "Text" then
local xPosition = ((((parent and parent.Position) or Vector2.new(0, 0)).X) + (value.X.Scale * ((typeof(parent.Size) == "number" and parent.TextBounds) or parent.Size).X)) + value.X.Offset
local yPosition = ((((parent and parent.Position) or Vector2.new(0, 0)).Y) + (value.Y.Scale * ((typeof(parent.Size) == "number" and parent.TextBounds) or parent.Size).Y)) + value.Y.Offset
--
instance.Position = Vector2.new(xPosition, yPosition)
else
local xPosition = ((((parent and parent.Position) or Vector2.new(0, 0)).X) + value.X.Scale * ((parent and parent.Size) or ws.CurrentCamera.ViewportSize).X) + value.X.Offset
local yPosition = ((((parent and parent.Position) or Vector2.new(0, 0)).Y) + value.Y.Scale * ((parent and parent.Size) or ws.CurrentCamera.ViewportSize).Y) + value.Y.Offset
--
instance.Position = Vector2.new(xPosition, yPosition)
end
elseif property == "Color" or property == "color" then
if typeof(value) == "string" then
instance["Color"] = shared.theme[value]
--
if value == "accent" then
shared.accents[#shared.accents + 1] = instance
end
else
instance[property] = value
end
else
instance[property] = value
end
end
end
--
shared.drawings[#shared.drawings + 1] = instance
--
return instance
end
--
function utility:Update(instance, instanceProperty, instanceValue, instanceParent)
if instanceProperty == "Size" or instanceProperty == "Size" then
local xSize = (instanceValue.X.Scale * ((instanceParent and instanceParent.Size) or ws.CurrentCamera.ViewportSize).X) + instanceValue.X.Offset
local ySize = (instanceValue.Y.Scale * ((instanceParent and instanceParent.Size) or ws.CurrentCamera.ViewportSize).Y) + instanceValue.Y.Offset
--
instance.Size = Vector2.new(xSize, ySize)
elseif instanceProperty == "Position" or instanceProperty == "position" then
local xPosition = ((((instanceParent and instanceParent.Position) or Vector2.new(0, 0)).X) + (instanceValue.X.Scale * ((typeof(instanceParent.Size) == "number" and instanceParent.TextBounds) or instanceParent.Size).X)) + instanceValue.X.Offset
local yPosition = ((((instanceParent and instanceParent.Position) or Vector2.new(0, 0)).Y) + (instanceValue.Y.Scale * ((typeof(instanceParent.Size) == "number" and instanceParent.TextBounds) or instanceParent.Size).Y)) + instanceValue.Y.Offset
--
instance.Position = Vector2.new(xPosition, yPosition)
elseif instanceProperty == "Color" or instanceProperty == "color" then
if typeof(instanceValue) == "string" then
instance.Color = shared.theme[instanceValue]
--
if instanceValue == "accent" then
shared.accents[#shared.accents + 1] = instance
else
if table.find(shared.accents, instance) then
table.remove(shared.accents, table.find(shared.accents, instance))
end
end
else
instance.Color = instanceValue
end
end
end
--
function utility:Connection(connectionType, connectionCallback)
local connection = connectionType:Connect(connectionCallback)
shared.connections[#shared.connections + 1] = connection
--
return connection
end
--
function utility:RemoveConnection(connection)
for index, con in pairs(shared.connections) do
if con == connection then
shared.connections[index] = nil
con:Disconnect()
end
end
--
for index, con in pairs(shared.hidden_connections) do
if con == connection then
shared.hidden_connections[index] = nil
con:Disconnect()
end
end
end
--
function utility:Lerp(instance, instanceTo, instanceTime)
local currentTime = 0
local currentIndex = {}
local connection
--
for i,v in pairs(instanceTo) do
currentIndex[i] = instance[i]
end
--
local function lerp()
for i,v in pairs(instanceTo) do
instance[i] = ((v - currentIndex[i]) * currentTime / instanceTime) + currentIndex[i]
end
end
--
connection = rs.RenderStepped:Connect(function(delta)
if currentTime < instanceTime then
currentTime = currentTime + delta
lerp()
else
connection:Disconnect()
end
end)
end
--
function utility:Unload()
for i,v in pairs(shared.drawings) do
v:Remove()
end
--
for i,v in pairs(shared.connections) do
v:Disconnect()
end
--
shared.drawings = nil
shared.connections = nil
--
local third_person_object = fake_rep_object:getThirdPersonObject()
if third_person_object then
local character_model = third_person_object:popCharacterModel()
character_model:Destroy()
fake_rep_object:despawn()
end
--
shared = nil
utility = nil
library = nil
end
--
function utility:Toggle()
shared.toggleKey[2] = not shared.toggleKey[2]
--
for index, drawing in pairs(shared.drawings) do
if getmetatable(drawing).__type == "Text" then
utility:Lerp(drawing, {Transparency = shared.toggleKey[2] and 1 or 0}, 0.15)
else
utility:Lerp(drawing, {Transparency = shared.toggleKey[2] and 1 or 0}, 0.25)
end
end
end
--
function utility:ChangeAccent(accentColor)
shared.theme.accent = accentColor
--
for index, drawing in pairs(shared.accents) do
drawing.Color = shared.theme.accent
end
end
--
function utility:Object(type, properties)
local object = Instance.new(type)
for i,v in next, properties do
object[i] = v
end
return object
end
--
function utility:Round(n, scale)
return tonumber(string.format("%." .. (typeof(scale) == "number" and scale or 2) .. "f", n))
end
end
-- Library Functions
do
function library:Window(windowProperties)
-- // Variables
local window = {
current = nil,
currentindex = 1,
content = {},
pages = {}
}
local windowProperties = windowProperties or {}
--
local windowName = windowProperties.name or windowProperties.Name or "New Window"
-- // Functions
function window:Movement(moveAction, moveDirection)
if moveAction == "Movement" then
window.content[window.currentindex]:Turn(false)
--
if window.content[moveDirection == "Down" and window.currentindex + 1 or window.currentindex - 1] then
window.currentindex = moveDirection == "Down" and window.currentindex + 1 or window.currentindex - 1
else
window.currentindex = moveDirection == "Down" and 1 or #window.content
end
--
window.content[window.currentindex]:Turn(true)
else
window.content[window.currentindex]:Action(moveDirection)
end
end
--
function window:ChangeKeys(keyType, moveDirection, newKey)
for i,v in pairs(shared.moveKeys[keyType]) do
if tostring(v) == tostring(moveDirection) then
shared.moveKeys[keyType][i] = nil
shared.moveKeys[keyType][newKey] = moveDirection
end
end
end
-- // Main
local windowFrame = utility:Create("Square", {
Visible = true,
Filled = true,
Thickness = 0,
Color = shared.theme.inline,
Size = UDim2.new(0, 280, 0, 19),
Position = UDim2.new(0, 50, 0, 80)
})
--
local windowInline = utility:Create("Square", {
Parent = windowFrame,
Visible = true,
Filled = true,
Thickness = 0,
Color = shared.theme.dark,
Size = UDim2.new(1, -2, 1, -4),
Position = UDim2.new(0, 1, 0, 3)
})
--
local windowAccent = utility:Create("Square", {
Parent = windowFrame,
Visible = true,
Filled = true,
Thickness = 0,
Color = "accent",
Size = UDim2.new(1, 0, 0, 2),
Position = UDim2.new(0, 0, 0, 0)
})
--
local windowText = utility:Create("Text", {
Parent = windowAccent,
Visible = true,
Text = windowName,
Center = true,
Outline = true,
Font = 2,
Color = shared.theme.text,
Size = 13,
Position = UDim2.new(0.5, 0, 0, 3)
})
-- // Connections
utility:Connection(uis.InputBegan, function(Input)
if shared.toggleKey[2] and Input.KeyCode then
if shared.moveKeys["Movement"][Input.KeyCode.Name] then
window:Movement("Movement", shared.moveKeys["Movement"][Input.KeyCode.Name])
elseif shared.moveKeys["Action"][Input.KeyCode.Name] then
window:Movement("Action", shared.moveKeys["Action"][Input.KeyCode.Name])
end
end
--
if Input.KeyCode and Input.KeyCode == shared.toggleKey[1] then
utility:Toggle()
end
end)
-- // Nested Functions
function window:ChangeName(newName)
windowText.Text = newName
end
--
function window:Refresh()
window.content = {}
local contentCount = 0
--
for index, page in pairs(window.pages) do
page:Position(19 + (contentCount * 17))
window.content[#window.content + 1] = page
contentCount = contentCount + 1
--
if page.open then
for index, section in pairs(page.sections) do
section:Position(19 + (contentCount * 17))
contentCount = contentCount + 1
--
for index, content in pairs(section.content) do
content:Position(19 + (contentCount * 17))
if not content.noaction then
window.content[#window.content + 1] = content
end
contentCount = contentCount + 1
end
end
end
end
--
utility:Update(windowFrame, "Size", UDim2.new(0, 280, 0, 23 + (contentCount * 17)))
utility:Update(windowInline, "Size", UDim2.new(1, -2, 1, -4), windowFrame)
end
--
function window:Page(pageProperties)
-- // Variables
local page = {open = false, sections = {}}
local pageProperties = pageProperties or {}
--
local pageName = pageProperties.name or pageProperties.Name or "New Page"
-- // Functions
-- // Main
local pageText = utility:Create("Text", {
Parent = windowFrame,
Visible = true,
Text = "[+] "..pageName,
Outline = true,
Font = 2,
Color = (#window.content == 0 and shared.theme.accent or shared.theme.text),
Size = 13,
Position = UDim2.new(0, 5, 0, 19 + ((#window.content) * 17))
})
-- // Nested Functions
function page:Turn(state)
if state then
utility:Update(pageText, "Color", "accent")
else
utility:Update(pageText, "Color", "text")
end
end
--
function page:Position(yAxis)
utility:Update(page.text, "Position", UDim2.new(0, 5, 0, yAxis), windowFrame)
end
--
function page:Open(state, externalOpen)
if not externalOpen then
local ind = 0
for index, other_page in pairs(window.pages) do
if other_page == page then
ind = index
else
if other_page.open then
other_page:Open(false, true)
end
end
end
--
window.currentindex = ind
end
--
page.open = state
pageText.Text = (page.open and "[-] " or "[+] ") .. pageName
--
for index, section in pairs(page.sections) do
section:Open(page.open)
end
--
window:Refresh()
end
--
function page:Action(action)
if action == "Enter" then
page:Open(not page.open)
elseif action == "Right" and not page.open then
page:Open(true)
elseif action == "Left" and page.open then
page:Open(false)
end
end
--
function page:Section(sectionProperties)
-- // Variables
local section = {content = {}}
local sectionProperties = sectionProperties or {}
--
local sectionName = sectionProperties.name or sectionProperties.Name or "New Section"
-- // Functions
-- // Main
local sectionText = utility:Create("Text", {
Visible = false,
Text = "["..sectionName.."]",
Outline = true,
Font = 2,
Color = shared.theme.section,
Size = 13
})
-- // Nested Functions
function section:Open(state)
section.text.Visible = state
--
for index, content in pairs(section.content) do
content:Open(state)
end
end
--
function section:Position(yAxis)
utility:Update(section.text, "Position", UDim2.new(0, 22, 0, yAxis), windowFrame)
end
--
function section:Label(labelProperties)
-- // Variables
local label = {noaction = true}
local labelProperties = labelProperties or {}
--
local labelName = labelProperties.name or labelProperties.Name or "New Label"
-- // Functions
-- // Main
local labelText = utility:Create("Text", {
Visible = false,
Text = labelName,
Outline = true,
Font = 2,
Color = shared.theme.text,
Size = 13
})
-- // Nested Functions
function label:Turn(state)
if state then
utility:Update(label.text, "Color", "accent")
else
utility:Update(label.text, "Color", "text")
end
end
--
function label:Position(yAxis)
utility:Update(label.text, "Position", UDim2.new(0, 22, 0, yAxis), windowFrame)
end
--
function label:Open(state)
label.text.Visible = state
end
--
function label:Action(action)
end
-- // Returning + Other
label.name = labelName
label.text = labelText
--
section.content[#section.content + 1] = label
--
return label
end
--
function section:Button(buttonProperties)
-- // Variables
local button = {}
local buttonProperties = buttonProperties or {}
--
local buttonName = buttonProperties.name or buttonProperties.Name or "New Button"
local buttonConfirm = buttonProperties.confirm or buttonProperties.Confirm or false
local buttonCallback = buttonProperties.callback or buttonProperties.Callback or buttonProperties.CallBack or buttonProperties.callBack or function() end
-- // Functions
-- // Main
local buttonText = utility:Create("Text", {
Visible = false,
Text = buttonName,
Outline = true,
Font = 2,
Color = shared.theme.text,
Size = 13
})
-- // Nested Functions
function button:Turn(state)
if state then
utility:Update(button.text, "Color", "accent")
else
utility:Update(button.text, "Color", "text")
end
end
--
function button:Position(yAxis)
utility:Update(button.text, "Position", UDim2.new(0, 22, 0, yAxis), windowFrame)
end
--
function button:Open(state)
button.text.Visible = state
end
--
function button:Action(action)
if buttonConfirm and button.text.Text ~= "confirm?" then
button.text.Text = "confirm?"
task.delay(3, function()
if button.text.Text == "confirm?" then
button.text.Text = buttonName
end
end)
return
end
--
button.text.Text = "<"..buttonName..">"
--
buttonCallback()
--
wait(0.2)
button.text.Text = buttonName
end
-- // Returning + Other
button.name = buttonName
button.text = buttonText
--
section.content[#section.content + 1] = button
--
return button
end
--
function section:Toggle(toggleProperties)
local toggle = {}
local toggleProperties = toggleProperties or {}
--
local toggleName = toggleProperties.name or toggleProperties.Name or "New Toggle"
local toggleDefault = toggleProperties.default or toggleProperties.Default or toggleProperties.def or toggleProperties.Def or false
local togglePointer = toggleProperties.pointer or toggleProperties.Pointer or toggleProperties.flag or toggleProperties.Flag or nil
local toggleCallback = toggleProperties.callback or toggleProperties.Callback or toggleProperties.CallBack or toggleProperties.callBack or function() end
-- // Functions
-- // Main
local toggleText = utility:Create("Text", {
Visible = false,
Text = toggleName .. " -> " .. (toggleDefault and "ON" or "OFF"),
Outline = true,
Font = 2,
Color = shared.theme.text,
Size = 13
})
-- // Nested Functions
function toggle:Turn(state)
if state then
utility:Update(toggle.text, "Color", "accent")
else
utility:Update(toggle.text, "Color", "text")
end
end
--
function toggle:Position(yAxis)
utility:Update(toggle.text, "Position", UDim2.new(0, 22, 0, yAxis), windowFrame)
end
--
function toggle:Open(state)
toggle.text.Visible = state
end
--
function toggle:Action(action)
toggle.current = not toggle.current
toggle.text.Text = toggle.name .. " -> " .. (toggle.current and "ON" or "OFF")
--
toggleCallback(toggle.current)
end
-- // Returning + Other
toggle.name = toggleName
toggle.text = toggleText
toggle.current = toggleDefault
--
section.content[#section.content + 1] = toggle
--
if togglePointer then
local pointer = {}
--
function pointer:Get()
return toggle.current
end
--
function pointer:Set(value)
if typeof(value) == "bool" then
toggle.current = value
toggle.text.Text = toggle.name .. " -> " .. (toggle.current and "ON" or "OFF")
--
toggleCallback(toggle.current)
end
end
--
shared.pointers[togglePointer] = pointer
end
--
return toggle
end
--
function section:Slider(sliderProperties)
local slider = {}
local sliderProperties = sliderProperties or {}
--
local sliderName = sliderProperties.name or sliderProperties.Name or "New Toggle"
local sliderDefault = sliderProperties.default or sliderProperties.Default or sliderProperties.def or sliderProperties.Def or 1
local sliderMax = sliderProperties.max or sliderProperties.Max or sliderProperties.maximum or sliderProperties.Maximum or 10
local sliderMin = sliderProperties.min or sliderProperties.Min or sliderProperties.minimum or sliderProperties.Minimum or 1
local sliderDigits = sliderProperties.digits or sliderProperties.Digits or sliderProperties.scale or sliderProperties.Scale or 1
local sliderTick = sliderProperties.tick or sliderProperties.Tick or sliderProperties.decimals or sliderProperties.Decimals or 1
local sliderPointer = sliderProperties.pointer or sliderProperties.Pointer or sliderProperties.flag or sliderProperties.Flag or nil
local sliderCallback = sliderProperties.callback or sliderProperties.Callback or sliderProperties.CallBack or sliderProperties.callBack or function() end
-- // Functions
-- // Main
local sliderText = utility:Create("Text", {
Visible = false,
Text = sliderName .. " -> " .. "<" .. tostring(sliderDefault) .. "/" .. tostring(sliderMax) .. ">",
Outline = true,
Font = 2,
Color = shared.theme.text,
Size = 13
})
-- // Nested Functions
function slider:Turn(state)
if state then
utility:Update(slider.text, "Color", "accent")
else
utility:Update(slider.text, "Color", "text")
end
end
--
function slider:Position(yAxis)
utility:Update(slider.text, "Position", UDim2.new(0, 22, 0, yAxis), windowFrame)
end
--
function slider:Open(state)
slider.text.Visible = state
end
--
function slider:Action(action)
slider.current = math.clamp(action == "Left" and (slider.current - slider.tick) or (slider.current + slider.tick), slider.min, slider.max)
slider.text.Text = sliderName .. " -> " .. "<" .. utility:Round(slider.current, slider.digits) .. "/" .. utility:Round(slider.max, slider.digits) .. ">"
--
sliderCallback(slider.current)
end
-- // Returning + Other
slider.name = sliderName
slider.text = sliderText
slider.current = sliderDefault
slider.max = sliderMax
slider.min = sliderMin
slider.digits = sliderDigits
slider.tick = sliderTick
--
section.content[#section.content + 1] = slider
--
if sliderPointer then
local pointer = {}
--
function pointer:Get()
return slider.current
end
--
function pointer:Set(value)
if typeof(value) == "number" then
slider.current = value
slider.text.Text = sliderName .. " -> " .. "<" .. utility:Round(slider.current, slider.digits) .. "/" .. utility:Round(slider.max, slider.digits) .. ">"
--
sliderCallback(slider.current)
end
end
--
shared.pointers[sliderPointer] = pointer
end
--
return slider
end
--
function section:List(listProperties)
local list = {}
local listProperties = listProperties or {}
--
local listName = listProperties.name or listProperties.Name or "New Toggle"
local listEnter = listProperties.enter or listProperties.Enter or listProperties.comfirm or listProperties.Comfirm or false
local listDefault = listProperties.default or listProperties.Default or listProperties.def or listProperties.Def or 1
local listOptions = listProperties.options or listProperties.Options or {"Option 1", "Option 2", "Option 3"}
local listPointer = listProperties.pointer or listProperties.Pointer or listProperties.flag or listProperties.Flag or nil
local listCallback = listProperties.callback or listProperties.Callback or listProperties.CallBack or listProperties.callBack or function() end
-- // Functions
-- // Main
local listText = utility:Create("Text", {
Visible = false,
Text = listName .. " -> " .. "<" .. tostring(listOptions[listDefault]) .. ">",
Outline = true,
Font = 2,
Color = shared.theme.text,
Size = 13
})
-- // Nested Functions
function list:Turn(state)
if state then
utility:Update(list.text, "Color", "accent")
else
utility:Update(list.text, "Color", "text")
end
end
--
function list:Position(yAxis)
utility:Update(list.text, "Position", UDim2.new(0, 22, 0, yAxis), windowFrame)
end
--
function list:Open(state)
list.text.Visible = state
end
--
function list:Action(action)
if (listEnter and action == "Enter") then
listCallback(list.options[list.current])
else
list.current = ((list.options[action == "Left" and list.current - 1 or list.current + 1]) and (action == "Left" and list.current - 1 or list.current + 1)) or (action == "Left" and #list.options or 1)
--
list.text.Text = listName .. " -> " .. "<" .. tostring(list.options[list.current]) .. ">"
--
if not listEnter then
listCallback(list.options[list.current])
end
end
end
-- // Returning + Other
if listPointer then
local pointer = {}
--
function pointer:Get(cfg)
if cfg then
return list.current
else
return list.options[list.current]
end
end
--
function pointer:Set(value)
if typeof(value) == "number" and list.options[value] then
list.current = value
--
list.text.Text = listName .. " -> " .. "<" .. tostring(list.options[list.current]) .. ">"
--
if not listEnter then
listCallback(list.options[list.current])
end
end
end
--
shared.pointers[listPointer] = pointer
end
--
list.name = listName
list.text = listText
list.current = listDefault
list.options = listOptions
--
section.content[#section.content + 1] = list
--
return list
end
--
function section:MultiList(multiListProperties)
local multiList = {}
local multiListProperties = multiListProperties or {}
--
local multiListName = multiListProperties.name or multiListProperties.Name or "New Toggle"
local multiListDefault = multiListProperties.default or multiListProperties.Default or multiListProperties.def or multiListProperties.Def or 1
local multiListOptions = multiListProperties.options or multiListProperties.Options or {{"Option 1", false}, {"Option 2", false}, {"Option 3", false}}
local multiListPointer = multiListProperties.pointer or multiListProperties.Pointer or multiListProperties.flag or multiListProperties.Flag or nil
local multiListCallback = multiListProperties.callback or multiListProperties.Callback or multiListProperties.CallBack or multiListProperties.callBack or function() end
-- // Functions
-- // Main
local multiListText = utility:Create("Text", {
Visible = false,
Text = multiListName .. " -> " .. "<" .. (multiListOptions[multiListDefault] and (tostring(multiListOptions[multiListDefault][1]) .. ":" .. ((multiListOptions[multiListDefault][2]) and "ON" or "OFF")) or "Nil") .. ">",
Outline = true,
Font = 2,
Color = shared.theme.text,
Size = 13
})
-- // Nested Functions
function multiList:Turn(state)
if state then
utility:Update(multiList.text, "Color", "accent")
else
utility:Update(multiList.text, "Color", "text")
end
end
--
function multiList:Position(yAxis)
utility:Update(multiList.text, "Position", UDim2.new(0, 22, 0, yAxis), windowFrame)
end
--
function multiList:Open(state)
multiList.text.Visible = state
end
--
function multiList:Action(action)
if action == "Enter" then
multiList.options[multiList.current][2] = not multiList.options[multiList.current][2]
--
multiList.text.Text = multiList.name .. " -> " .. "<" .. tostring(multiList.options[multiList.current][1]) .. ":" .. (multiList.options[multiList.current][2] and "ON" or "OFF") .. ">"
--
multiListCallback(multiList.options)
else
multiList.current = ((multiList.options[action == "Left" and multiList.current - 1 or multiList.current + 1]) and (action == "Left" and multiList.current - 1 or multiList.current + 1)) or (action == "Left" and #multiList.options or 1)
--
multiList.text.Text = multiList.name .. " -> " .. "<" .. tostring(multiList.options[multiList.current][1]) .. ":" .. (multiList.options[multiList.current][2] and "ON" or "OFF") .. ">"
--
multiListCallback(multiList.options)
end
end
-- // Returning + Other
if multiListPointer then
local pointer = {}
--
function pointer:Get()
return list.options
end
--
function pointer:Set(value)
if typeof(value) == "table" and value[multiList.current] then
multiList.options = value
--
multiList.text.Text = multiList.name .. " -> " .. "<" .. tostring(multiList.options[multiList.current][1]) .. ":" .. (multiList.options[multiList.current][2] and "ON" or "OFF") .. ">"
--
multiListCallback(multiList.options)
end
end
--
shared.pointers[multiListPointer] = pointer
end
--
multiList.name = multiListName
multiList.text = multiListText
multiList.current = multiListDefault
multiList.options = multiListOptions
--
section.content[#section.content + 1] = multiList
--
return multiList
end
--
function section:PlayerList(playerListProperties)
local playerList = {}
local playerListProperties = playerListProperties or {}
--
local playerListName = playerListProperties.name or playerListProperties.Name or "New Toggle"
local playerListEnter = playerListProperties.enter or playerListProperties.Enter or playerListProperties.comfirm or playerListProperties.Comfirm or false
local playerListCallback = playerListProperties.callback or playerListProperties.Callback or playerListProperties.CallBack or playerListProperties.callBack or function() end
local playerListOptions = {}
-- // Functions
for index, player in pairs(plrs:GetPlayers()) do
if player ~= plr then
playerListOptions[#playerListOptions + 1] = player
end
end
--
utility:Connection(plrs.PlayerAdded, function(player)
if player ~= plr then
if not table.find(playerList.options, player) then
playerList.options[#playerList.options + 1] = player
end
--
if #playerList.options == 1 then
playerList.current = 1
--
playerList.text.Text = playerList.name .. " -> " .. "<" .. tostring(playerList.options[playerList.current].Name) .. ">"
--
if not playerListEnter then
playerListCallback(tostring(playerList.options[playerList.current]))
end
end
end
end)
--
utility:Connection(plrs.PlayerRemoving, function(player)
if player ~= plr then
local index = table.find(playerList.options, player)
local current = playerList.current
local current_plr = playerList.options[current]
--
if index then
table.remove(playerList.options, index)
end
--
if #playerList.options == 0 then
playerList.text.Text = playerList.name .. " -> " .. "<Nil>"
else
local oldCurrent = playerList.current
--
if index and playerList.options[playerList.current] ~= current_plr and table.find(playerList.options, current_plr) then
playerList.current = table.find(playerList.options, current_plr)
end
--
playerList.text.Text = playerList.name .. " -> " .. "<" .. tostring(playerList.options[playerList.current].Name) .. ">"
--
if not playerListEnter then
if oldCurrent ~= playerList.current then
playerListCallback(tostring(playerList.options[playerList.current]))
end
end
end
end
end)
-- // Main
local playerListText = utility:Create("Text", {
Visible = false,
Text = playerListName .. " -> " .. "<" .. (#playerListOptions >= 1 and tostring(playerListOptions[1].Name) or "Nil") .. ">",
Outline = true,
Font = 2,
Color = shared.theme.text,
Size = 13
})
-- // Nested Functions
function playerList:Turn(state)
if state then
utility:Update(playerList.text, "Color", "accent")
else
utility:Update(playerList.text, "Color", "text")
end