forked from RobloxHackerManHackesAccounts/Hack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hacker
2765 lines (2450 loc) · 96.3 KB
/
Hacker
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
local MESSAGES_FADE_OUT_TIME = 30
local MAX_UDIM_SIZE = 2^15 - 1
local CHAT_WINDOW_Y_OFFSET = 2
local PHONE_SCREEN_WIDTH = 640
local TABLET_SCREEN_WIDTH = 1024
local FLOOD_CHECK_MESSAGE_COUNT = 7
local FLOOD_CHECK_MESSAGE_INTERVAL = 15 -- This is in seconds
local VR_CHAT_CLICK_DEBOUNCE = 0.25
local SCROLLBAR_THICKNESS = 7
local CHAT_COLORS =
{
Color3.new(253/255, 41/255, 67/255), -- BrickColor.new("Bright red").Color,
Color3.new(1/255, 162/255, 255/255), -- BrickColor.new("Bright blue").Color,
Color3.new(2/255, 184/255, 87/255), -- BrickColor.new("Earth green").Color,
BrickColor.new("Bright violet").Color,
BrickColor.new("Bright orange").Color,
BrickColor.new("Bright yellow").Color,
BrickColor.new("Light reddish violet").Color,
BrickColor.new("Brick yellow").Color,
}
local thisModuleName = "Chat"
local emptySelectionImage = Instance.new("ImageLabel")
emptySelectionImage.ImageTransparency = 1
emptySelectionImage.BackgroundTransparency = 1
--[[ END OF CONSTANTS ]]
--[[ SERVICES ]]
local RunService = game:GetService('RunService')
local CoreGuiService = game:GetService('CoreGui')
local PlayersService = game:GetService('Players')
local DebrisService = game:GetService('Debris')
local GuiService = game:GetService('GuiService')
local InputService = game:GetService('UserInputService')
local StarterGui = game:GetService('StarterGui')
local ContextActionService = game:GetService('ContextActionService')
local Settings = UserSettings()
local GameSettings = Settings.GameSettings
--[[ END OF SERVICES ]]
--[[ Fast Flags ]]--
local FFlagEnableNewDevConsole = settings():GetFFlag("EnableNewDevConsole")
--[[ SCRIPT VARIABLES ]]
local RobloxGui = CoreGuiService:WaitForChild("RobloxGui")
local VRHub = require(RobloxGui.Modules.VR.VRHub)
local PlayerPermissionsModule = require(RobloxGui.Modules.PlayerPermissionsModule)
local StatsUtils = require(RobloxGui.Modules.Stats.StatsUtils)
-- I am not fond of waiting at the top of the script here...
while PlayersService.LocalPlayer == nil do PlayersService.ChildAdded:wait() end
local Player = PlayersService.LocalPlayer
-- GuiRoot will act as the top-node for parenting GUIs
local GuiRoot = Instance.new('Frame')
GuiRoot.Name = 'GuiRoot';
GuiRoot.Size = UDim2.new(1,0,1,0);
GuiRoot.BackgroundTransparency = 1;
local chatRepositioned = false
local chatBarDisabled = false
local lastSelectedPlayer = nil
local lastSelectedButton = nil
local blockingUtility = nil
local topbarEnabled = true
if not NON_CORESCRIPT_MODE and not InputService.VREnabled then
blockingUtility = require(RobloxGui.Modules:WaitForChild("PlayerDropDown")):CreateBlockingUtility()
end
--[[ END OF SCRIPT VARIABLES ]]
local function GetLuaChatFilteringFlag()
return true
end
local Util = {}
do
-- Check if we are running on a touch device
function Util.IsTouchDevice()
local touchEnabled = false
pcall(function() touchEnabled = InputService.TouchEnabled end)
return touchEnabled
end
function Util.IsSmallScreenSize()
return GuiRoot.AbsoluteSize.X <= PHONE_SCREEN_WIDTH
end
function Util.Create(instanceType)
return function(data)
local obj = Instance.new(instanceType)
for k, v in pairs(data) do
if type(k) == 'number' then
v.Parent = obj
else
obj[k] = v
end
end
return obj
end
end
function Util.Clamp(low, high, input)
return math.max(low, math.min(high, input))
end
function Util.Linear(t, b, c, d)
if t >= d then return b + c end
return c*t/d + b
end
function Util.EaseOutQuad(t, b, c, d)
if t >= d then return b + c end
t = t/d;
return -c * t*(t-2) + b
end
function Util.EaseInOutQuad(t, b, c, d)
if t >= d then
return b + c
end
t = t / (d/2);
if (t < 1) then
return c/2*t*t + b
end;
t = t - 1;
return -c/2 * (t*(t-2) - 1) + b;
end
function Util.PropertyTweener(instance, prop, start, final, duration, easingFunc, cbFunc)
local this = {}
this.StartTime = tick()
this.EndTime = this.StartTime + duration
this.Cancelled = false
local finished = false
local percentComplete = 0
spawn(function()
local now = tick()
while now < this.EndTime and instance do
if this.Cancelled then
return
end
instance[prop] = easingFunc(now - this.StartTime, start, final - start, duration)
percentComplete = Util.Clamp(0, 1, (now - this.StartTime) / duration)
RunService.RenderStepped:wait()
now = tick()
end
if this.Cancelled == false and instance then
instance[prop] = final
finished = true
percentComplete = 1
if cbFunc then
cbFunc()
end
end
end)
function this:GetPercentComplete()
return percentComplete
end
function this:IsFinished()
return finished
end
function this:Cancel()
this.Cancelled = true
end
return this
end
function Util.Signal()
local sig = {}
local mSignaler = Instance.new('BindableEvent')
local mArgData = nil
local mArgDataCount = nil
function sig:fire(...)
mArgData = {...}
mArgDataCount = select('#', ...)
mSignaler:Fire()
end
function sig:connect(f)
if not f then error("connect(nil)", 2) end
return mSignaler.Event:connect(function()
f(unpack(mArgData, 1, mArgDataCount))
end)
end
function sig:wait()
mSignaler.Event:wait()
assert(mArgData, "Missing arg data, likely due to :TweenSize/Position corrupting threadrefs.")
return unpack(mArgData, 1, mArgDataCount)
end
return sig
end
function Util.DisconnectEvent(conn)
if conn then
conn:disconnect()
end
return nil
end
function Util.SetGUIInsetBounds(x, y)
local success, _ = pcall(function() GuiService:SetGlobalGuiInset(0, x, 0, y) end)
if not success then
pcall(function() GuiService:SetGlobalSizeOffsetPixel(-x, -y) end) -- Legacy GUI-offset function
end
end
local baseUrl = game:GetService("ContentProvider").BaseUrl:lower()
baseUrl = string.gsub(baseUrl,"/m.","/www.") --mobile site does not work for this stuff!
function Util.GetSecureApiBaseUrl()
local secureApiUrl = baseUrl
secureApiUrl = string.gsub(secureApiUrl,"http://","https://")
secureApiUrl = string.gsub(secureApiUrl,"www","api")
return secureApiUrl
end
function Util.GetPlayerByName(playerName)
-- O(n), may be faster if I store a reverse hash from the players list; can't trust FindFirstChild in PlayersService because anything can be parented to there.
local lowerName = string.lower(playerName)
for _, player in pairs(PlayersService:GetPlayers()) do
if string.lower(player.Name) == lowerName then
return player
end
end
return nil -- Found no player
end
local function MakeIsInGroup(groupId, requiredRank)
assert(type(requiredRank) == "nil" or type(requiredRank) == "number", "requiredRank must be a number or nil")
local inGroupCache = {}
return function(player)
if player and player.UserId then
local userId = player.UserId
if inGroupCache[userId] == nil then
local inGroup = false
pcall(function() -- Many things can error is the IsInGroup check
if requiredRank then
inGroup = player:GetRankInGroup(groupId) > requiredRank
else
inGroup = player:IsInGroup(groupId)
end
end)
inGroupCache[userId] = inGroup
end
return inGroupCache[userId]
end
return false
end
end
Util.IsPlayerAdminAsync = MakeIsInGroup(1200769)
Util.IsPlayerInternAsync = MakeIsInGroup(2868472, 100)
local function GetNameValue(pName)
local value = 0
for index = 1, #pName do
local cValue = string.byte(string.sub(pName, index, index))
local reverseIndex = #pName - index + 1
if #pName%2 == 1 then
reverseIndex = reverseIndex - 1
end
if reverseIndex%4 >= 2 then
cValue = -cValue
end
value = value + cValue
end
return value
end
function Util.ComputeChatColor(pName)
return CHAT_COLORS[(GetNameValue(pName) % #CHAT_COLORS) + 1]
end
-- This is a memo-izing function
local testLabel = Instance.new('TextLabel')
testLabel.TextWrapped = true;
testLabel.Position = UDim2.new(1,0,1,0)
testLabel.Parent = GuiRoot -- Note: We have to parent it to check TextBounds
-- The TextSizeCache table looks like this Text->Font->sizeBounds->FontSize
local TextSizeCache = {}
function Util.GetStringTextBounds(text, font, fontSize, sizeBounds)
-- If no sizeBounds are specified use some huge number
sizeBounds = sizeBounds or false
if not TextSizeCache[text] then
TextSizeCache[text] = {}
end
if not TextSizeCache[text][font] then
TextSizeCache[text][font] = {}
end
if not TextSizeCache[text][font][sizeBounds] then
TextSizeCache[text][font][sizeBounds] = {}
end
if not TextSizeCache[text][font][sizeBounds][fontSize] then
testLabel.Text = text
testLabel.Font = font
testLabel.FontSize = fontSize
if sizeBounds then
testLabel.TextWrapped = true;
testLabel.Size = sizeBounds
else
testLabel.TextWrapped = false;
end
TextSizeCache[text][font][sizeBounds][fontSize] = testLabel.TextBounds
end
return TextSizeCache[text][font][sizeBounds][fontSize]
end
local PRINTABLE_CHARS = '[^' .. string.char(32) .. '-' .. string.char(126) .. ']'
local WHITESPACE_CHARS = '(' .. string.rep('%s', 7) .. ')%s+'
function Util.FilterUnprintableCharacters(str)
if not GetLuaChatFilteringFlag() then
return str
end
local result = str:gsub(PRINTABLE_CHARS, '');
result = str:gsub(WHITESPACE_CHARS, '%1');
return result
end
end
local SelectChatModeEvent = Util.Signal()
local SelectPlayerEvent = Util.Signal()
local function CreateChatMessage()
local this = {}
this.FadeRoutines = {}
function this:GetMessageFontSize(settings)
return Util.IsSmallScreenSize() and settings.SmallScreenFontSize or settings.FontSize
end
function this:OnResize()
-- Nothing!
end
function this:FadeIn()
local gui = this:GetGui()
if gui then
gui.Visible = true
end
end
function this:FadeOut()
local gui = this:GetGui()
if gui then
gui.Visible = false
end
end
function this:GetGui()
return this.Container
end
function this:Destroy()
if this.Container ~= nil then
this.Container:Destroy()
this.Container = nil
end
if this.FadeRoutines then
for _, routine in pairs(this.FadeRoutines) do
routine:Cancel()
end
this.FadeRoutines = {}
end
end
return this
end
local function CreateSystemChatMessage(settings, chattedMessage)
local this = CreateChatMessage()
this.Settings = settings
this.rawChatString = chattedMessage
function this:OnResize(containerSize)
if this.Container and this.ChatMessage then
if InputService.VREnabled then
this.ChatMessage.Position = UDim2.new(0, 4, 0, 0)
this.ChatMessage.Size = UDim2.new(1, 0, 1, 0)
end
this.Container.Size = UDim2.new(1,0,0,1000)
local textHeight = this.ChatMessage.TextBounds.Y
local newContainerHeight = textHeight + 5
this.Container.Size = UDim2.new(1,0,0,newContainerHeight)
return newContainerHeight
end
end
function this:FadeIn()
local gui = this:GetGui()
if gui then
gui.Visible = true
for _, routine in pairs(this.FadeRoutines) do
routine:Cancel()
end
this.FadeRoutines = {}
local tweenableObjects = {
this.ChatMessage;
}
for _, object in pairs(tweenableObjects) do
object.TextTransparency = 0;
object.TextStrokeTransparency = this.Settings.TextStrokeTransparency;
end
if this.MessageBackgroundImage then
this.MessageBackgroundImage.Visible = InputService.VREnabled
end
end
end
function this:FadeOut(instant)
local gui = this:GetGui()
if gui then
if instant then
gui.Visible = false
else
local tweenableObjects = {
this.ChatMessage;
}
for _, object in pairs(tweenableObjects) do
table.insert(this.FadeRoutines, Util.PropertyTweener(object, 'TextTransparency', object.TextTransparency, 1, 1, Util.Linear))
table.insert(this.FadeRoutines, Util.PropertyTweener(object, 'TextStrokeTransparency', object.TextStrokeTransparency, 1, 0.85, Util.Linear))
end
end
if this.MessageBackgroundImage then
this.MessageBackgroundImage.Visible = false
end
end
end
local function CreateMessageGuiElement()
local fontSize = this:GetMessageFontSize(this.Settings)
local systemMessageDisplayText = this.rawChatString or ""
local systemMessageSize = Util.GetStringTextBounds(systemMessageDisplayText, this.Settings.Font, fontSize, UDim2.new(0, 400, 0, 1000))
local container = Util.Create'Frame'
{
Name = 'MessageContainer';
Position = UDim2.new(0, 0, 0, 0);
ZIndex = 1;
BackgroundColor3 = Color3.new(0, 0, 0);
BackgroundTransparency = 1;
};
this.MessageBackgroundImage = Util.Create'ImageLabel'
{
Name = 'TextEntryBackground';
Size = UDim2.new(1,0,1,-2);
Position = UDim2.new(0,0,0,1);
Image = 'rbxasset://textures/ui/Chat/VRChatBackground.png';
ScaleType = Enum.ScaleType.Slice;
SliceCenter = Rect.new(8,8,56,56);
BackgroundTransparency = 1;
ImageTransparency = 0.3;
BorderSizePixel = 0;
ZIndex = 1;
Visible = InputService.VREnabled;
Parent = container;
}
local chatMessage = Util.Create'TextLabel'
{
Name = 'SystemChatMessage';
Position = UDim2.new(0, 0, 0, 0);
Size = UDim2.new(1, 0, 1, 0);
Text = systemMessageDisplayText;
ZIndex = 1;
BackgroundColor3 = Color3.new(0, 0, 0);
BackgroundTransparency = 1;
TextXAlignment = Enum.TextXAlignment.Left;
TextYAlignment = Enum.TextYAlignment.Top;
TextWrapped = true;
TextColor3 = this.Settings.DefaultMessageTextColor;
FontSize = fontSize;
Font = this.Settings.Font;
TextStrokeColor3 = this.Settings.TextStrokeColor;
TextStrokeTransparency = this.Settings.TextStrokeTransparency;
Parent = container;
};
if InputService.VREnabled then
chatMessage.Position = UDim2.new(0, 4, 0, 0)
chatMessage.Size = UDim2.new(1, 0, 1, 0)
end
container.Size = UDim2.new(1, 0, 0, systemMessageSize.Y + 1);
this.Container = container
this.ChatMessage = chatMessage
end
CreateMessageGuiElement()
return this
end
--[[ Popup Handling ]]--
function createPopupFrame(selectedPlayer, selectedButton)
if selectedPlayer and selectedPlayer.Parent == PlayersService then
if lastSelectedButton ~= selectedButton then
if lastSelectedButton ~= nil then
lastSelectedButton.BackgroundTransparency = 1
lastSelectedButton = nil
end
lastSelectedButton = selectedButton
lastSelectedPlayer = selectedPlayer
selectedButton.BackgroundTransparency = 0.5
else
lastSelectedPlayer = nil
end
end
end
function popupHidden()
if lastSelectedButton then
lastSelectedPlayer = nil
lastSelectedButton.BackgroundTransparency = 1
lastSelectedButton = nil
end
end
InputService.InputBegan:connect(function(inputObject, isProcessed)
if isProcessed then return end
local inputType = inputObject.UserInputType
if ((inputType == Enum.UserInputType.Touch and
inputObject.UserInputState == Enum.UserInputState.Begin) or
inputType == Enum.UserInputType.MouseButton1) then
end
end)
--[[ End of popup handling ]]--
local function CreatePlayerChatMessage(settings, playerChatType, sendingPlayer, chattedMessage, receivingPlayer)
local this = CreateChatMessage()
this.Settings = settings
this.PlayerChatType = playerChatType
this.SendingPlayer = sendingPlayer
this.RawMessageContent = chattedMessage
this.ReceivingPlayer = receivingPlayer
this.ReceivedTime = tick()
this.Neutral = this.SendingPlayer and this.SendingPlayer.Neutral or true
this.TeamColor = this.SendingPlayer and this.SendingPlayer.TeamColor or BrickColor.new("White")
function this:OnResize(containerSize)
if this.Container and this.ChatMessage then
this.Container.Size = UDim2.new(1,0,0,1000)
local textHeight = this.ChatMessage.TextBounds.Y
local newContainerHeight = textHeight + 5
this.Container.Size = UDim2.new(1,0,0,newContainerHeight)
return newContainerHeight
end
end
function this:FormatMessage()
local result = ""
if this.RawMessageContent then
local message = this.RawMessageContent
result = message
end
return result
end
function this:FormatChatType()
if this.PlayerChatType then
if this.PlayerChatType == Enum.PlayerChatType.All then
--return "[All]"
elseif this.PlayerChatType == Enum.PlayerChatType.Team then
return "[Team]"
elseif this.PlayerChatType == Enum.PlayerChatType.Whisper then
-- nothing!
end
end
end
function this:FormatPlayerNameText()
local playerName = ""
-- If we are sending a whisper to someone, then we should show their name
if this.PlayerChatType == Enum.PlayerChatType.Whisper and this.SendingPlayer and this.SendingPlayer == Player then
playerName = (this.ReceivingPlayer and this.ReceivingPlayer.Name or "")
else
playerName = (this.SendingPlayer and this.SendingPlayer.Name or "")
end
return "[" .. playerName .. "]:"
end
function this:FadeIn()
local gui = this:GetGui()
if gui then
gui.Visible = true
for _, routine in pairs(this.FadeRoutines) do
routine:Cancel()
end
this.FadeRoutines = {}
local tweenableObjects = {
this.WhisperToText;
this.WhisperFromText;
this.ChatModeButton;
this.UserNameButton;
this.ChatMessage;
}
for _, object in pairs(tweenableObjects) do
object.TextTransparency = 0;
object.TextStrokeTransparency = this.Settings.TextStrokeTransparency;
object.Active = true
end
if this.UserNameDot then
this.UserNameDot.ImageTransparency = 0
end
if this.MessageBackgroundImage then
this.MessageBackgroundImage.Visible = InputService.VREnabled
end
end
end
function this:FadeOut(instant)
local gui = this:GetGui()
if gui then
if instant then
gui.Visible = false
else
local tweenableObjects = {
this.WhisperToText;
this.WhisperFromText;
this.ChatModeButton;
this.UserNameButton;
this.ChatMessage;
}
for _, object in pairs(tweenableObjects) do
table.insert(this.FadeRoutines, Util.PropertyTweener(object, 'TextTransparency', object.TextTransparency, 1, 1, Util.Linear))
table.insert(this.FadeRoutines, Util.PropertyTweener(object, 'TextStrokeTransparency', object.TextStrokeTransparency, 1, 0.85, Util.Linear))
object.Active = false
end
if this.UserNameDot then
table.insert(this.FadeRoutines, Util.PropertyTweener(this.UserNameDot, 'ImageTransparency', this.UserNameDot.ImageTransparency, 1, 1, Util.Linear))
end
end
if this.MessageBackgroundImage then
this.MessageBackgroundImage.Visible = false
end
end
end
function this:Destroy()
if this.Container ~= nil then
this.Container:Destroy()
this.Container = nil
end
this.ClickedOnModeConn = Util.DisconnectEvent(this.ClickedOnModeConn)
this.ClickedOnPlayerConn = Util.DisconnectEvent(this.ClickedOnPlayerConn)
end
local function CreateMessageGuiElement()
local fontSize = this:GetMessageFontSize(this.Settings)
local toMesasgeDisplayText = "To "
local toMessageSize = Util.GetStringTextBounds(toMesasgeDisplayText, this.Settings.Font, fontSize)
local fromMesasgeDisplayText = "From "
local fromMessageSize = Util.GetStringTextBounds(fromMesasgeDisplayText, this.Settings.Font, fontSize)
local chatTypeDisplayText = this:FormatChatType()
local chatTypeSize = chatTypeDisplayText and Util.GetStringTextBounds(chatTypeDisplayText, this.Settings.Font, fontSize) or Vector2.new(0,0)
local playerNameDisplayText = this:FormatPlayerNameText()
local playerNameSize = Util.GetStringTextBounds(playerNameDisplayText, this.Settings.Font, fontSize)
local singleSpaceSize = Util.GetStringTextBounds(" ", this.Settings.Font, fontSize)
local numNeededSpaces = math.ceil(playerNameSize.X / singleSpaceSize.X) + 1
local chatMessageDisplayText = string.rep(" ", numNeededSpaces) .. this:FormatMessage()
local chatMessageSize = Util.GetStringTextBounds(chatMessageDisplayText, this.Settings.Font, fontSize, UDim2.new(0, 400 - 5 - playerNameSize.X, 0, 1000))
local playerColor = this.Settings.DefaultMessageTextColor
if this.SendingPlayer then
if this.PlayerChatType == Enum.PlayerChatType.Whisper then
if this.SendingPlayer == Player and this.ReceivingPlayer then
playerColor = Util.ComputeChatColor(this.ReceivingPlayer.Name)
else
playerColor = Util.ComputeChatColor(this.SendingPlayer.Name)
end
else
if this.SendingPlayer.Neutral then
playerColor = Util.ComputeChatColor(this.SendingPlayer.Name)
else
playerColor = this.SendingPlayer.TeamColor.Color
end
end
end
local container = Util.Create'Frame'
{
Name = 'MessageContainer';
Position = UDim2.new(0, 0, 0, 0);
ZIndex = 1;
BackgroundColor3 = Color3.new(0, 0, 0);
BackgroundTransparency = 1;
};
this.MessageBackgroundImage = Util.Create'ImageLabel'
{
Name = 'TextEntryBackground';
Size = UDim2.new(1,0,1,-2);
Position = UDim2.new(0,0,0,1);
Image = 'rbxasset://textures/ui/Chat/VRChatBackground.png';
ScaleType = Enum.ScaleType.Slice;
SliceCenter = Rect.new(8,8,56,56);
BackgroundTransparency = 1;
ImageTransparency = 0.3;
BorderSizePixel = 0;
ZIndex = 1;
Visible = InputService.VREnabled;
Parent = container;
}
local xOffset = InputService.VREnabled and 4 or 0
if this.SendingPlayer and this.SendingPlayer == Player and this.PlayerChatType == Enum.PlayerChatType.Whisper then
local whisperToText = Util.Create'TextLabel'
{
Name = 'WhisperTo';
Position = UDim2.new(0, 0, 0, 0);
Size = UDim2.new(0, toMessageSize.X, 0, toMessageSize.Y);
Text = toMesasgeDisplayText;
ZIndex = 1;
BackgroundColor3 = Color3.new(0, 0, 0);
BackgroundTransparency = 1;
TextXAlignment = Enum.TextXAlignment.Left;
TextYAlignment = Enum.TextYAlignment.Top;
TextWrapped = true;
TextColor3 = this.Settings.DefaultMessageTextColor;
FontSize = fontSize;
Font = this.Settings.Font;
TextStrokeColor3 = this.Settings.TextStrokeColor;
TextStrokeTransparency = this.Settings.TextStrokeTransparency;
Parent = container;
};
xOffset = xOffset + toMessageSize.X
this.WhisperToText = whisperToText
elseif this.SendingPlayer and this.SendingPlayer ~= Player and this.PlayerChatType == Enum.PlayerChatType.Whisper then
local whisperFromText = Util.Create'TextLabel'
{
Name = 'WhisperFromText';
Position = UDim2.new(0, 0, 0, 0);
Size = UDim2.new(0, fromMessageSize.X, 0, fromMessageSize.Y);
Text = fromMesasgeDisplayText;
ZIndex = 1;
BackgroundColor3 = Color3.new(0, 0, 0);
BackgroundTransparency = 1;
TextXAlignment = Enum.TextXAlignment.Left;
TextYAlignment = Enum.TextYAlignment.Top;
TextWrapped = true;
TextColor3 = this.Settings.DefaultMessageTextColor;
FontSize = fontSize;
Font = this.Settings.Font;
TextStrokeColor3 = this.Settings.TextStrokeColor;
TextStrokeTransparency = this.Settings.TextStrokeTransparency;
Parent = container;
};
xOffset = xOffset + fromMessageSize.X
this.WhisperFromText = whisperFromText
end
if chatTypeDisplayText then
local chatModeButton = Util.Create(Util.IsTouchDevice() and 'TextLabel' or 'TextButton')
{
Name = 'ChatMode';
BackgroundTransparency = 1;
ZIndex = 2;
Text = chatTypeDisplayText;
TextColor3 = this.Settings.DefaultMessageTextColor;
Position = UDim2.new(0, xOffset, 0, 0);
TextXAlignment = Enum.TextXAlignment.Left;
TextYAlignment = Enum.TextYAlignment.Top;
FontSize = fontSize;
Font = this.Settings.Font;
Size = UDim2.new(0, chatTypeSize.X, 0, chatTypeSize.Y);
TextStrokeColor3 = this.Settings.TextStrokeColor;
TextStrokeTransparency = this.Settings.TextStrokeTransparency;
Parent = container
}
if chatModeButton:IsA('TextButton') then
this.ClickedOnModeConn = chatModeButton.MouseButton1Click:connect(function()
SelectChatModeEvent:fire(this.PlayerChatType)
end)
end
if this.PlayerChatType == Enum.PlayerChatType.Team then
chatModeButton.TextColor3 = playerColor
end
xOffset = xOffset + chatTypeSize.X + 1
this.ChatModeButton = chatModeButton
end
local userNameButton = Util.Create(Util.IsTouchDevice() and 'TextLabel' or 'TextButton')
{
Name = 'PlayerName';
BackgroundTransparency = 1;
BackgroundColor3 = Color3.new(0, 1, 1);
BorderSizePixel = 0;
ZIndex = 2;
Text = playerNameDisplayText;
TextColor3 = playerColor;
Position = UDim2.new(0, xOffset, 0, 0);
TextXAlignment = Enum.TextXAlignment.Left;
TextYAlignment = Enum.TextYAlignment.Top;
FontSize = fontSize;
Font = this.Settings.Font;
Size = UDim2.new(0, playerNameSize.X, 0, playerNameSize.Y);
TextStrokeColor3 = this.Settings.TextStrokeColor;
TextStrokeTransparency = this.Settings.TextStrokeTransparency;
Parent = container
}
if userNameButton:IsA('TextButton') then
this.ClickedOnPlayerConn = userNameButton.MouseButton1Click:connect(function()
local gui = this:GetGui()
if gui and gui.Visible then
if this.PlayerChatType == Enum.PlayerChatType.Whisper and this.SendingPlayer == Player and this.ReceivingPlayer then
SelectPlayerEvent:fire(this.ReceivingPlayer)
else
SelectPlayerEvent:fire(this.SendingPlayer)
end
end
end)
end
local chatMessage = Util.Create'TextLabel'
{
Name = 'ChatMessage';
Position = UDim2.new(0, xOffset, 0, 0);
Size = UDim2.new(1, -xOffset, 1, 0);
Text = chatMessageDisplayText;
ZIndex = 1;
BackgroundColor3 = Color3.new(0, 0, 0);
BackgroundTransparency = 1;
TextXAlignment = Enum.TextXAlignment.Left;
TextYAlignment = Enum.TextYAlignment.Top;
TextWrapped = true;
TextColor3 = this.Settings.DefaultMessageTextColor;
FontSize = fontSize;
Font = this.Settings.Font;
TextStrokeColor3 = this.Settings.TextStrokeColor;
TextStrokeTransparency = this.Settings.TextStrokeTransparency;
Parent = container;
};
if InputService.VREnabled then
chatMessage.Size = chatMessage.Size - UDim2.new(0,4,0,0)
end
-- Check if they got moderated and put up a real message instead of Label
if chatMessage.Text == 'Label' and chatMessageDisplayText ~= 'Label' then
chatMessage.Text = string.rep(" ", numNeededSpaces) .. '[Content Deleted]'
end
if this.SendingPlayer then
if PlayerPermissionsModule.IsPlayerAdminAsync(this.SendingPlayer) then
chatMessage.TextColor3 = this.Settings.AdminTextColor
elseif PlayerPermissionsModule.IsPlayerInternAsync(this.SendingPlayer) then
chatMessage.TextColor3 = this.Settings.InternTextColor
end
end
chatMessage.Size = chatMessage.Size + UDim2.new(0, 0, 0, chatMessage.TextBounds.Y);
container.Size = UDim2.new(1, 0, 0, math.max(chatMessageSize.Y + 1, userNameButton.Size.Y.Offset + 1));
this.Container = container
this.ChatMessage = chatMessage
this.UserNameButton = userNameButton
end
CreateMessageGuiElement()
return this
end
local function CreateChatBarWidget(settings)
local this = {}
-- MessageModes: {All, Team, Whisper}
this.MessageMode = 'All'
this.TargetWhisperPlayer = nil
this.Settings = settings
this.WidgetVisible = false
this.FadedIn = true
this.ChatBarGainedFocusEvent = Util.Signal()
this.ChatBarLostFocusEvent = Util.Signal()
this.ChatCommandEvent = Util.Signal() -- Signal Signatue: success, actionType, [captures]
this.ChatErrorEvent = Util.Signal() -- Signal Signatue: success, actionType, [captures]
this.ChatBarFloodEvent = Util.Signal()
this.unfocusedAt = 0
local chatCoreGuiEnabled = true
-- This function while lets string.find work case-insensitively without clobbering the case of the captures
local function nocase(s)
s = string.gsub(s, "%a", function (c)
return string.format("[%s%s]", string.lower(c),
string.upper(c))
end)
return s
end
this.ChatMatchingRegex =
{
[function(chatBarText) return string.find(chatBarText, nocase("^/w ") .. "(%w+_?%w+)") end] = "Whisper";
[function(chatBarText) return string.find(chatBarText, nocase("^/whisper ") .. "(%w+_?%w+)") end] = "Whisper";
[function(chatBarText) return string.find(chatBarText, "^%%") end] = "Team";
[function(chatBarText) return string.find(chatBarText, "^%(TEAM%)") end] = "Team";
[function(chatBarText) return string.find(chatBarText, nocase("^/t")) end] = "Team";
[function(chatBarText) return string.find(chatBarText, nocase("^/team")) end] = "Team";
[function(chatBarText) return string.find(chatBarText, nocase("^/a")) end] = "All";
[function(chatBarText) return string.find(chatBarText, nocase("^/all")) end] = "All";
[function(chatBarText) return string.find(chatBarText, nocase("^/s")) end] = "All";
[function(chatBarText) return string.find(chatBarText, nocase("^/say")) end] = "All";
[function(chatBarText) return string.find(chatBarText, nocase("^/e")) end] = "Emote";
[function(chatBarText) return string.find(chatBarText, nocase("^/emote")) end] = "Emote";
[function(chatBarText) return string.find(chatBarText, "^/%?") end] = "Help";
[function(chatBarText) return string.find(chatBarText, nocase("^/help")) end] = "Help";
[function(chatBarText) return string.find(chatBarText, nocase("^/block ") .. "(%w+_?%w+)") end] = "Block";
[function(chatBarText) return string.find(chatBarText, nocase("^/unblock ") .. "(%w+_?%w+)") end] = "Unblock";
[function(chatBarText) return string.find(chatBarText, nocase("^/mute ") .. "(%w+_?%w+)") end] = "Mute";
[function(chatBarText) return string.find(chatBarText, nocase("^/unmute ") .. "(%w+_?%w+)") end] = "Unmute";
}
local ChatModesDict =
{
['Whisper'] = 'Whisper';
['Team'] = 'Team';
['All'] = 'All';
[Enum.PlayerChatType.Whisper] = 'Whisper';
[Enum.PlayerChatType.Team] = 'Team';
[Enum.PlayerChatType.All] = 'All';
}
local function TearDownEvents()
this.ClickToChatButtonConn = Util.DisconnectEvent(this.ClickToChatButtonConn)
this.ChatBarFocusLostConn = Util.DisconnectEvent(this.ChatBarFocusLostConn)
this.ChatBarLostFocusConn = Util.DisconnectEvent(this.ChatBarLostFocusConn)
this.SelectChatModeConn = Util.DisconnectEvent(this.SelectChatModeConn)
this.SelectPlayerConn = Util.DisconnectEvent(this.SelectPlayerConn)
this.FocusChatBarInputBeganConn = Util.DisconnectEvent(this.FocusChatBarInputBeganConn)
this.InputBeganConn = Util.DisconnectEvent(this.InputBeganConn)
this.ChatBarChangedConn = Util.DisconnectEvent(this.ChatBarChangedConn)
end
local function HookUpEvents()
TearDownEvents() -- Cleanup old events
if this.ClickToChatButton then this.ClickToChatButtonConn = this.ClickToChatButton.MouseButton1Click:connect(function() this:FocusChatBar() end) end
if this.ChatBar then
-- Use a count to check for double backspace out of a chatmode
local count = 0
if not Util.IsTouchDevice() then
this.FocusChatBarInputBeganConn = Util.DisconnectEvent(this.FocusChatBarInputBeganConn)
this.FocusChatBarInputBeganConn = InputService.InputBegan:connect(function(inputObj)
if inputObj.KeyCode == Enum.KeyCode.Backspace and this:GetChatBarText() == "" then
if count == 0 then
count = count + 1
else
this:SetMessageMode('All')
end
else
count = 0
end
end)