Repository navigation
Expand file tree
/
Copy pathPlayerlistModule.lua
More file actions
1919 lines (1740 loc) · 59 KB
/
Copy pathPlayerlistModule.lua
File metadata and controls
1919 lines (1740 loc) · 59 KB
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
--[[
// FileName: PlayerlistModule.lua
// Version 1.2
// Written by: jmargh
// Description: Implementation of in game player list and leaderboard
]]
local CoreGui = game:GetService'CoreGui'
local GuiService = game:GetService('GuiService') -- NOTE: Can only use in core scripts
local UserInputService = game:GetService('UserInputService')
local HttpService = game:GetService('HttpService')
local HttpRbxApiService = game:GetService('HttpRbxApiService')
local Players = game:GetService('Players')
local TeamsService = game:FindService('Teams')
local RobloxReplicatedStorage = nil -- NOTE: Can only use in core scripts
local RbxGuiLibrary = nil
if LoadLibrary then
RbxGuiLibrary = LoadLibrary("RbxGui")
end
while not Players.LocalPlayer do
wait()
end
local Player = Players.LocalPlayer
local RobloxGui = CoreGui:WaitForChild('RobloxGui')
--[[ Fast Flags ]]--
local maxFriendSuccess, isMaxFriendsCountEnabled = pcall(function() return settings():GetFFlag("MaxFriendsCount") end)
local followersSuccess, isFollowersEnabled = pcall(function() return settings():GetFFlag("LuaFollowers") end)
local newSettingsSuccess, newSettingsEnabled = pcall(function() return settings():GetFFlag("NewMenuSettingsScript") end)
local serverCoreScriptsSuccess, serverCoreScriptsEnabled = pcall(function() return settings():GetFFlag("UseServerCoreScripts") end)
--
local IsMaxFriendsCount = maxFriendSuccess and isMaxFriendsCountEnabled
local IsFollowersEnabled = followersSuccess and isFollowersEnabled
local IsNewSettings = newSettingsSuccess and newSettingsEnabled
local IsServerCoreScripts = serverCoreScriptsSuccess and serverCoreScriptsEnabled
--[[ Start Module ]]--
local Playerlist = {}
--[[ Public Event API ]]--
-- Parameters: Sorted Array - see ClientStats below
Playerlist.OnLeaderstatsChanged = Instance.new('BindableEvent')
-- Parameters: nameOfStat(string), formatedStringOfStat(string)
Playerlist.OnStatChanged = Instance.new('BindableEvent')
--[[ Client Stat Table ]]--
-- Sorted Array of tables
local ClientStats = {}
-- Fields
-- Name: String the developer has given the stat
-- Text: Formated string of the stat value
--[[ Script Variables ]]--
local MyPlayerEntry = nil
local PlayerEntries = {}
local GameStats = {}
local StatAddId = 0
local TeamEntries = {}
local TeamAddId = 0
local NeutralTeam = nil
local IsShowingNeutralFrame = false
local LastSelectedFrame = nil
local LastSelectedPlayer = nil
local MinContainerSize = UDim2.new(0, 200, 0.5, 0)
local PlayerEntrySizeY = 24
local TeamEntrySizeY = 18
local NameEntrySizeX = 170
local StatEntrySizeX = 75
local IsSmallScreenDevice = UserInputService.TouchEnabled and GuiService:GetScreenResolution().Y <= 500
--[[ Bindables ]]--
local BinbableFunction_SendNotification = RobloxGui:FindFirstChild('SendNotification')
--[[ Remotes ]]--
local RemoteEvent_OnNewFollower = nil
if IsServerCoreScripts then
RobloxReplicatedStorage = game:GetService('RobloxReplicatedStorage')
RemoteEvent_OnNewFollower = RobloxReplicatedStorage:WaitForChild('OnNewFollower')
end
local IsPersonalServer = false
local PersonalServerService = nil
if workspace:FindFirstChild('PSVariable') then
IsPersonalServer = true
PersonalServerService = game:GetService('PersonalServerService')
end
workspace.ChildAdded:connect(function(child)
if child.Name == 'PSVariable' and child:IsA('BoolValue') then
IsPersonalServer = true
PersonalServerService = game:GetService('PersonalServerService')
end
end)
--Report Abuse
local AbusingPlayer = nil
local AbuseReason = nil
--[[ Constants ]]--
local ENTRY_PAD = 2
local BG_TRANSPARENCY = 0.5
local BG_COLOR = Color3.new(31/255, 31/255, 31/255)
local TEXT_STROKE_TRANSPARENCY = 0.75
local TEXT_COLOR = Color3.new(1, 1, 243/255)
local TEXT_STROKE_COLOR = Color3.new(34/255, 34/255, 34/255)
local TWEEN_TIME = 0.15
local MAX_LEADERSTATS = 4
local MAX_STR_LEN = 12
local MAX_FRIEND_COUNT = 200
local ADMINS = { -- Admins with special icons
['7210880'] = 'http://www.roblox.com/asset/?id=134032333', -- Jeditkacheff
['13268404'] = 'http://www.roblox.com/asset/?id=113059239', -- Sorcus
['261'] = 'http://www.roblox.com/asset/?id=105897927', -- shedlestky
['20396599'] = 'http://www.roblox.com/asset/?id=161078086', -- Robloxsai
}
local ABUSES = {
"Swearing",
"Bullying",
"Scamming",
"Dating",
"Cheating/Exploiting",
"Personal Questions",
"Offsite Links",
"Bad Username",
}
local FOLLOWER_STATUS = {
FOLLOWER = 0,
FOLLOWING = 1,
MUTUAL = 2,
}
local PRIVILEGE_LEVEL = {
OWNER = 255,
ADMIN = 240,
MEMBER = 128,
VISITOR = 10,
BANNED = 0,
}
--[[ Images ]]--
local CHAT_ICON = 'rbxasset://textures/ui/chat_teamButton.png'
local ADMIN_ICON = 'rbxasset://textures/ui/icon_admin-16.png'
local PLACE_OWNER_ICON = 'rbxasset://textures/ui/icon_placeowner.png'
local BC_ICON = 'rbxasset://textures/ui/icon_BC-16.png'
local TBC_ICON = 'rbxasset://textures/ui/icon_TBC-16.png'
local OBC_ICON = 'rbxasset://textures/ui/icon_OBC-16.png'
local FRIEND_ICON = 'rbxasset://textures/ui/icon_friends_16.png'
local FRIEND_REQUEST_ICON = 'rbxasset://textures/ui/icon_friendrequestsent_16.png'
local FRIEND_RECEIVED_ICON = 'rbxasset://textures/ui/icon_friendrequestrecieved-16.png'
local FOLLOWER_ICON = 'rbxasset://textures/ui/icon_follower-16.png'
local FOLLOWING_ICON = 'rbxasset://textures/ui/icon_following-16.png'
local MUTUAL_FOLLOWING_ICON = 'rbxasset://textures/ui/icon_mutualfollowing-16.png'
local FRIEND_IMAGE = 'http://www.roblox.com/thumbs/avatar.ashx?userId='
--[[ Helper Functions ]]--
local function clamp(value, min, max)
if value < min then
value = min
elseif value > max then
value = max
end
return value
end
local function getFriendStatus(selectedPlayer)
if selectedPlayer == Player then
return Enum.FriendStatus.NotFriend
else
local success, result = pcall(function()
-- NOTE: Core script only
return Player:GetFriendStatus(selectedPlayer)
end)
if success then
return result
else
return Enum.FriendStatus.NotFriend
end
end
end
-- Returns whether followerUserId is following userId
local function isFollowing(userId, followerUserId)
local apiPath = "user/following-exists?userId="
local params = userId.."&followerUserId="..followerUserId
local success, result = pcall(function()
return HttpRbxApiService:GetAsync(apiPath..params, true)
end)
if not success then
print("isFollowing() failed because", result)
return false
end
-- can now parse web response
result = HttpService:JSONDecode(result)
return result["success"] and result["isFollowing"]
end
local function getFollowerStatus(selectedPlayer)
if selectedPlayer == Player then
return nil
end
-- ignore guest
if selectedPlayer.userId <= 0 then
return
end
local myUserId = tostring(Player.userId)
local theirUserId = tostring(selectedPlayer.userId)
local isFollowingMe = isFollowing(myUserId, theirUserId)
local isFollowingThem = isFollowing(theirUserId, myUserId)
if isFollowingMe and isFollowingThem then -- mutual
return FOLLOWER_STATUS.MUTUAL
elseif isFollowingMe then
return FOLLOWER_STATUS.FOLLOWER
elseif isFollowingThem then
return FOLLOWER_STATUS.FOLLOWING
else
return nil
end
end
local function getFriendStatusIcon(friendStatus)
if friendStatus == Enum.FriendStatus.Unknown or friendStatus == Enum.FriendStatus.NotFriend then
return nil
elseif friendStatus == Enum.FriendStatus.Friend then
return FRIEND_ICON
elseif friendStatus == Enum.FriendStatus.FriendRequestSent then
return FRIEND_REQUEST_ICON
elseif friendStatus == Enum.FriendStatus.FriendRequestReceived then
return FRIEND_RECEIVED_ICON
else
error("PlayerList: Unknown value for friendStatus: "..tostring(friendStatus))
end
end
local function getFollowerStatusIcon(followerStatus)
if followerStatus == FOLLOWER_STATUS.MUTUAL then
return MUTUAL_FOLLOWING_ICON
elseif followerStatus == FOLLOWER_STATUS.FOLLOWING then
return FOLLOWING_ICON
elseif followerStatus == FOLLOWER_STATUS.FOLLOWER then
return FOLLOWER_ICON
else
return nil
end
end
local function getAdminIcon(player)
local userIdStr = tostring(player.userId)
if ADMINS[userIdStr] then return nil end
--
local success, result = pcall(function()
return player:IsInGroup(1200769) -- yields
end)
if not success then
print("PlayerListScript2: getAdminIcon() failed because", result)
return nil
end
--
if result then
return ADMIN_ICON
end
end
local function getMembershipIcon(player)
local userIdStr = tostring(player.userId)
local membershipType = player.MembershipType
if ADMINS[userIdStr] then
return ADMINS[userIdStr]
elseif player.userId == game.CreatorId and game.CreatorType == Enum.CreatorType.User then
return PLACE_OWNER_ICON
elseif membershipType == Enum.MembershipType.None then
return nil
elseif membershipType == Enum.MembershipType.BuildersClub then
return BC_ICON
elseif membershipType == Enum.MembershipType.TurboBuildersClub then
return TBC_ICON
elseif membershipType == Enum.MembershipType.OutrageousBuildersClub then
return OBC_ICON
else
error("PlayerList: Unknown value for membershipType"..tostring(membershipType))
end
end
local function isValidStat(obj)
return obj:IsA('StringValue') or obj:IsA('IntValue') or obj:IsA('BoolValue') or obj:IsA('NumberValue') or
obj:IsA('DoubleConstrainedValue') or obj:IsA('IntConstrainedValue')
end
local function sortPlayerEntries(a, b)
if a.PrimaryStat == b.PrimaryStat then
return a.Player.Name:upper() < b.Player.Name:upper()
end
if not a.PrimaryStat then return false end
if not b.PrimaryStat then return true end
return a.PrimaryStat > b.PrimaryStat
end
local function sortLeaderStats(a, b)
if a.IsPrimary ~= b.IsPrimary then
return a.IsPrimary
end
if a.Priority == b.Priority then
return a.AddId < b.AddId
end
return a.Priority < b.Priority
end
local function sortTeams(a, b)
if a.TeamScore == b.TeamScore then
return a.Id < b.Id
end
if not a.TeamScore then return false end
if not b.TeamScore then return true end
return a.TeamScore < b.TeamScore
end
local function sendNotification(title, text, image, duration, callback)
if BinbableFunction_SendNotification then
BinbableFunction_SendNotification:Invoke(title, text, image, duration, callback)
end
end
-- Start of Gui Creation
local Container = Instance.new('Frame')
Container.Name = "PlayerListContainer"
Container.Position = UDim2.new(1, -200, 0, 2)
Container.Size = MinContainerSize
Container.BackgroundTransparency = 1
Container.Visible = false
Container.Parent = RobloxGui
-- Scrolling Frame
local ScrollList = Instance.new('ScrollingFrame')
ScrollList.Name = "ScrollList"
ScrollList.Size = UDim2.new(1, -1, 0, 0)
ScrollList.BackgroundTransparency = 1
ScrollList.BackgroundColor3 = Color3.new()
ScrollList.BorderSizePixel = 0
ScrollList.CanvasSize = UDim2.new(0, 0, 0, 0) -- NOTE: Look into if x needs to be set to anything
ScrollList.ScrollBarThickness = 6
ScrollList.BottomImage = 'rbxasset://textures/ui/scroll-bottom.png'
ScrollList.MidImage = 'rbxasset://textures/ui/scroll-middle.png'
ScrollList.TopImage = 'rbxasset://textures/ui/scroll-top.png'
ScrollList.Parent = Container
-- Friend/Report Popup
local PopupFrame = nil
local PopupClipFrame = Instance.new('Frame')
PopupClipFrame.Name = "PopupClipFrame"
PopupClipFrame.Size = UDim2.new(0, 150, 1.5, 0)
PopupClipFrame.Position = UDim2.new(0, -151, 0, 2)
PopupClipFrame.BackgroundTransparency = 1
PopupClipFrame.ClipsDescendants = true
PopupClipFrame.Parent = Container
-- Report Abuse Gui
local ReportAbuseShield = Instance.new('TextButton')
ReportAbuseShield.Name = "ReportAbuseShield"
ReportAbuseShield.Size = UDim2.new(1, 0, 1, 0)
ReportAbuseShield.Position = UDim2.new(0, 0, 0, 0)
ReportAbuseShield.BackgroundColor3 = Color3.new(51/255, 51/255, 51/255)
ReportAbuseShield.BackgroundTransparency = 0.4
ReportAbuseShield.ZIndex = 1
ReportAbuseShield.Text = ""
ReportAbuseShield.AutoButtonColor = false
local ReportAbuseFrame = Instance.new('Frame')
ReportAbuseFrame.Name = "ReportAbuseFrame"
ReportAbuseFrame.Size = UDim2.new(0, 480, 0, 320)
ReportAbuseFrame.Position = UDim2.new(0.5, -240, 0.5, -160)
ReportAbuseFrame.BackgroundTransparency = 0.7
ReportAbuseFrame.BackgroundColor3 = Color3.new(0, 0, 0)
ReportAbuseFrame.Style = Enum.FrameStyle.DropShadow
ReportAbuseFrame.Parent = ReportAbuseShield
local ReportAbuseDescription = Instance.new('TextLabel')
ReportAbuseDescription.Name = "ReportAbuseDescription"
ReportAbuseDescription.Text = "This will send a complete report to a moderator. The moderator will review the chat log and take appropriate action."
ReportAbuseDescription.Size = UDim2.new(1, -20, 0, 40)
ReportAbuseDescription.Position = UDim2.new(0, 10, 0, 10)
ReportAbuseDescription.BackgroundTransparency = 1
ReportAbuseDescription.Font = Enum.Font.SourceSans
ReportAbuseDescription.FontSize = Enum.FontSize.Size18
ReportAbuseDescription.TextColor3 = Color3.new(1, 1, 1)
ReportAbuseDescription.TextWrap = true
ReportAbuseDescription.TextXAlignment = Enum.TextXAlignment.Left
ReportAbuseDescription.TextYAlignment = Enum.TextYAlignment.Top
ReportAbuseDescription.Parent = ReportAbuseFrame
local ReportPlayerLabel = Instance.new('TextLabel')
ReportPlayerLabel.Name = "ReportPlayerLabel"
ReportPlayerLabel.Text = "Player Reporting:"
ReportPlayerLabel.Size = UDim2.new(0.4, 0, 0, 36)
ReportPlayerLabel.Position = UDim2.new(0.025, 20, 0, 80)
ReportPlayerLabel.BackgroundTransparency = 1
ReportPlayerLabel.Font = Enum.Font.SourceSans
ReportPlayerLabel.FontSize = Enum.FontSize.Size18
ReportPlayerLabel.TextColor3 = Color3.new(1, 1, 1)
ReportPlayerLabel.TextXAlignment = Enum.TextXAlignment.Left
ReportPlayerLabel.Parent = ReportAbuseFrame
local ReportPlayerName = Instance.new('TextLabel')
ReportPlayerName.Name = "ReportPlayerName"
ReportPlayerName.Text = ""
ReportPlayerName.Size = UDim2.new(0.95, 0, 0, 36)
ReportPlayerName.Position = UDim2.new(0.025, 0, 0, 80)
ReportPlayerName.BackgroundTransparency = 1
ReportPlayerName.Font = Enum.Font.SourceSans
ReportPlayerName.FontSize = Enum.FontSize.Size18
ReportPlayerName.TextColor3 = Color3.new(1, 1, 1)
ReportPlayerName.TextXAlignment = Enum.TextXAlignment.Right
ReportPlayerName.Parent = ReportAbuseFrame
local ReportReasonLabel = Instance.new('TextLabel')
ReportReasonLabel.Name = "ReportReasonLabel"
ReportReasonLabel.Text = "Type of Abuse:"
ReportReasonLabel.Size = UDim2.new(0.4, 0, 0, 36)
ReportReasonLabel.Position = UDim2.new(0.025, 20, 0, 119)
ReportReasonLabel.BackgroundTransparency = 1
ReportReasonLabel.Font = Enum.Font.SourceSans
ReportReasonLabel.FontSize = Enum.FontSize.Size18
ReportReasonLabel.TextColor3 = Color3.new(1, 1, 1)
ReportReasonLabel.TextXAlignment = Enum.TextXAlignment.Left
ReportReasonLabel.Parent = ReportAbuseFrame
local ReportDescriptionLabel = Instance.new('TextLabel')
ReportDescriptionLabel.Name = "ReportDescriptionLabel"
ReportDescriptionLabel.Text = "Short Description: (optional)"
ReportDescriptionLabel.Size = UDim2.new(0.95, 0, 0, 36)
ReportDescriptionLabel.Position = UDim2.new(0.025, 0, 0, 165)
ReportDescriptionLabel.BackgroundTransparency = 1
ReportDescriptionLabel.Font = Enum.Font.SourceSans
ReportDescriptionLabel.FontSize = Enum.FontSize.Size18
ReportDescriptionLabel.TextColor3 = Color3.new(1, 1, 1)
ReportDescriptionLabel.TextXAlignment = Enum.TextXAlignment.Left
ReportDescriptionLabel.Parent = ReportAbuseFrame
local ReportSubmitButton = Instance.new('TextButton')
ReportSubmitButton.Name = "ReportSubmitButton"
ReportSubmitButton.Text = "Submit Report"
ReportSubmitButton.Size = UDim2.new(0.35, 0, 0, 40)
ReportSubmitButton.Position = UDim2.new(0.1, 0, 1, -50)
ReportSubmitButton.Font = Enum.Font.SourceSans
ReportSubmitButton.FontSize = Enum.FontSize.Size18
ReportSubmitButton.TextColor3 = Color3.new(163/255, 162/255, 165/255)
ReportSubmitButton.Active = false
ReportSubmitButton.AutoButtonColor = true
ReportSubmitButton.Modal = true
ReportSubmitButton.Style = Enum.ButtonStyle.RobloxRoundDefaultButton
ReportSubmitButton.Parent = ReportAbuseFrame
local ReportCanelButton = Instance.new('TextButton')
ReportCanelButton.Name = "ReportCanelButton"
ReportCanelButton.Text = "Cancel"
ReportCanelButton.Size = UDim2.new(0.35, 0, 0, 40)
ReportCanelButton.Position = UDim2.new(0.55, 0, 1, -50)
ReportCanelButton.Font = Enum.Font.SourceSans
ReportCanelButton.FontSize = Enum.FontSize.Size18
ReportCanelButton.TextColor3 = Color3.new(1, 1, 1)
ReportCanelButton.Style = Enum.ButtonStyle.RobloxRoundDefaultButton
ReportCanelButton.Parent = ReportAbuseFrame
local AbuseDropDown, updateAbuseSelection = nil, nil
if IsNewSettings then
AbuseDropDown = RbxGuiLibrary.CreateScrollingDropDownMenu(
function(text)
AbuseReason = text
if AbuseReason and AbusingPlayer then
ReportSubmitButton.Active = true
ReportSubmitButton.TextColor3 = Color3.new(1, 1, 1)
end
end, UDim2.new(0.55, 0, 0, 32), UDim2.new(0.425, 0, 0, 121), 1)
AbuseDropDown.CreateList(ABUSES)
AbuseDropDown.Frame.Parent = ReportAbuseFrame
else
AbuseDropDown, updateAbuseSelection = RbxGuiLibrary.CreateDropDownMenu(ABUSES,
function(abuseText)
AbuseReason = abuseText
if AbuseReason and AbusingPlayer then
ReportSubmitButton.Active = true
ReportSubmitButton.TextColor3 = Color3.new(1, 1, 1)
end
end, true, true, 1)
AbuseDropDown.Name = "AbuseDropDown"
AbuseDropDown.Size = UDim2.new(0.55, 0, 0, 32)
AbuseDropDown.Position = UDim2.new(0.425, 0, 0, 121)
AbuseDropDown.Parent = ReportAbuseFrame
end
local ReportDescriptionTextFrame = Instance.new('Frame')
ReportDescriptionTextFrame.Name = "ReportDescriptionTextFrame"
ReportDescriptionTextFrame.Size = UDim2.new(0.95, 0, 1, -250)
ReportDescriptionTextFrame.Position = UDim2.new(0.025, 0, 0, 195)
ReportDescriptionTextFrame.BackgroundColor3 = Color3.new(206/255, 206/255, 206/255)
ReportDescriptionTextFrame.BorderSizePixel = 0
ReportDescriptionTextFrame.Parent = ReportAbuseFrame
local ReportDescriptionBox = Instance.new('TextBox')
ReportDescriptionBox.Name = "ReportDescriptionBox"
ReportDescriptionBox.Text = ""
ReportDescriptionBox.Size = UDim2.new(1, -6, 1, -6)
ReportDescriptionBox.Position = UDim2.new(0, 3, 0, 3)
ReportDescriptionBox.Font = Enum.Font.SourceSans
ReportDescriptionBox.FontSize = Enum.FontSize.Size18
ReportDescriptionBox.TextColor3 = Color3.new(0, 0, 0)
ReportDescriptionBox.BackgroundColor3 = Color3.new(206/255, 206/255, 206/255)
ReportDescriptionBox.BorderColor3 = Color3.new(206/255, 206/255, 206/255)
ReportDescriptionBox.TextXAlignment = Enum.TextXAlignment.Left
ReportDescriptionBox.TextYAlignment = Enum.TextYAlignment.Top
ReportDescriptionBox.TextWrap = true
ReportDescriptionBox.ClearTextOnFocus = false
ReportDescriptionBox.Parent = ReportDescriptionTextFrame
-- Report Confirm Gui
local ReportConfirmFrame = Instance.new('Frame')
ReportConfirmFrame.Name = "ReportConfirmFrame"
ReportConfirmFrame.Size = UDim2.new(0, 400, 0, 160)
ReportConfirmFrame.Position = UDim2.new(0.5, -200, 0.5, -80)
ReportConfirmFrame.BackgroundTransparency = 0.7
ReportConfirmFrame.BackgroundColor3 = Color3.new(0, 0, 0)
ReportConfirmFrame.Style = Enum.FrameStyle.DropShadow
local ReportConfirmHeader = Instance.new('TextLabel')
ReportConfirmHeader.Name = "ReportConfirmHeader"
ReportConfirmHeader.Size = UDim2.new(0, 0, 0, 0)
ReportConfirmHeader.Position = UDim2.new(0.5, 0, 0, 14)
ReportConfirmHeader.BackgroundTransparency = 1
ReportConfirmHeader.Text = "Thank You For Your Report"
ReportConfirmHeader.Font = Enum.Font.SourceSans
ReportConfirmHeader.FontSize = Enum.FontSize.Size36
ReportConfirmHeader.TextColor3 = Color3.new(1, 1, 1)
ReportConfirmHeader.Parent = ReportConfirmFrame
local ReportConfirmText = Instance.new('TextLabel')
ReportConfirmText.Name = "ReportConfirmText"
ReportConfirmText.Text = "Our moderators will review your report and the chat log to determine what happened."
ReportConfirmText.Size = UDim2.new(1, -20, 0, 40)
ReportConfirmText.Position = UDim2.new(0, 10, 0, 46)
ReportConfirmText.BackgroundTransparency = 1
ReportConfirmText.Font = Enum.Font.SourceSans
ReportConfirmText.FontSize = Enum.FontSize.Size18
ReportConfirmText.TextColor3 = Color3.new(1, 1, 1)
ReportConfirmText.TextWrap = true
ReportConfirmText.TextXAlignment = Enum.TextXAlignment.Left
ReportConfirmText.TextYAlignment = Enum.TextYAlignment.Top
ReportConfirmText.Parent = ReportConfirmFrame
local ReportConfirmButton = Instance.new('TextButton')
ReportConfirmButton.Name = "ReportConfirmButton"
ReportConfirmButton.Text = "OK"
ReportConfirmButton.Size = UDim2.new(0, 162, 0, 40)
ReportConfirmButton.Position = UDim2.new(0.5, -81, 1, -50)
ReportConfirmButton.Font = Enum.Font.SourceSans
ReportConfirmButton.FontSize = Enum.FontSize.Size18
ReportConfirmButton.TextColor3 = Color3.new(1, 1, 1)
ReportConfirmButton.Style = Enum.ButtonStyle.RobloxRoundDefaultButton
ReportConfirmButton.Parent = ReportConfirmFrame
local function onReportConfirmPressed()
ReportConfirmFrame.Parent = nil
ReportAbuseShield.Parent = nil
ReportAbuseFrame.Parent = ReportAbuseShield
end
ReportConfirmButton.MouseButton1Click:connect(onReportConfirmPressed)
--[[ Creation Helper Functions ]]--
local function createEntryFrame(name, sizeYOffset)
local containerFrame = Instance.new('Frame')
containerFrame.Name = name
containerFrame.Position = UDim2.new(0, 0, 0, 0)
containerFrame.Size = UDim2.new(1, 0, 0, sizeYOffset)
containerFrame.BackgroundTransparency = 1
local nameFrame = Instance.new('TextButton')
nameFrame.Name = "BGFrame"
nameFrame.Position = UDim2.new(0, 0, 0, 0)
nameFrame.Size = UDim2.new(0, NameEntrySizeX, 0, sizeYOffset)
nameFrame.BackgroundTransparency = BG_TRANSPARENCY
nameFrame.BackgroundColor3 = BG_COLOR
nameFrame.BorderSizePixel = 0
nameFrame.ClipsDescendants = true
nameFrame.AutoButtonColor = false
nameFrame.Text = ""
nameFrame.Parent = containerFrame
return containerFrame, nameFrame
end
local function createEntryNameText(name, text, sizeXOffset, posXOffset)
local nameLabel = Instance.new('TextLabel')
nameLabel.Name = name
nameLabel.Size = UDim2.new(-0.01, sizeXOffset, 0.5, 0)
nameLabel.Position = UDim2.new(0.01, posXOffset, 0.245, 0)
nameLabel.BackgroundTransparency = 1
nameLabel.Font = Enum.Font.SourceSans
nameLabel.FontSize = Enum.FontSize.Size14
nameLabel.TextColor3 = TEXT_COLOR
nameLabel.TextStrokeTransparency = TEXT_STROKE_TRANSPARENCY
nameLabel.TextStrokeColor3 = TEXT_STROKE_COLOR
nameLabel.TextXAlignment = Enum.TextXAlignment.Left
nameLabel.Text = text
return nameLabel
end
local function createStatFrame(offset, parent, name)
local statFrame = Instance.new('Frame')
statFrame.Name = name
statFrame.Size = UDim2.new(0, StatEntrySizeX, 1, 0)
statFrame.Position = UDim2.new(0, offset + 1, 0, 0)
statFrame.BackgroundTransparency = BG_TRANSPARENCY
statFrame.BackgroundColor3 = BG_COLOR
statFrame.BorderSizePixel = 0
statFrame.Parent = parent
return statFrame
end
local function createStatText(parent, text)
local statText = Instance.new('TextLabel')
statText.Name = "StatText"
statText.Size = UDim2.new(1, 0, 1, 0)
statText.Position = UDim2.new(0, 0, 0, 0)
statText.BackgroundTransparency = 1
statText.Font = Enum.Font.SourceSans
statText.FontSize = Enum.FontSize.Size14
statText.TextColor3 = TEXT_COLOR
statText.TextStrokeColor3 = TEXT_STROKE_COLOR
statText.TextStrokeTransparency = TEXT_STROKE_TRANSPARENCY
statText.Text = text
statText.Active = true
statText.Parent = parent
return statText
end
local function createImageIcon(image, name, xOffset, parent)
local imageLabel = Instance.new('ImageLabel')
imageLabel.Name = name
imageLabel.Size = UDim2.new(0, 16, 0, 16)
imageLabel.Position = UDim2.new(0.01, xOffset, 0.5, -imageLabel.Size.Y.Offset/2)
imageLabel.BackgroundTransparency = 1
imageLabel.Image = image
imageLabel.BorderSizePixel = 0
imageLabel.Parent = parent
return imageLabel
end
local function getScoreValue(statObject)
if statObject:IsA('DoubleConstrainedValue') or statObject:IsA('IntConstrainedValue') then
return statObject.ConstrainedValue
elseif statObject:IsA('BoolValue') then
if statObject.Value then return 1 else return 0 end
else
return statObject.Value
end
end
local THIN_CHARS = "[^%[iIl\%.,']"
local function strWidth(str)
return string.len(str) - math.floor(string.len(string.gsub(str, THIN_CHARS, "")) / 2)
end
local function formatNumber(value)
local _,_,minusSign, int, fraction = tostring(value):find('([-]?)(%d+)([.]?%d*)')
int = int:reverse():gsub("%d%d%d", "%1,")
return minusSign..int:reverse():gsub("^,", "")..fraction
end
local function formatStatString(text)
local numberValue = tonumber(text)
if numberValue then
text = formatNumber(numberValue)
end
if strWidth(text) <= MAX_STR_LEN then
return text
else
return string.sub(text, 1, MAX_STR_LEN - 3).."..."
end
end
--[[ Resize Functions ]]--
local LastMaxScrollSize = 0
local function setScrollListSize()
local teamSize = #TeamEntries * TeamEntrySizeY
local playerSize = #PlayerEntries * PlayerEntrySizeY
local spacing = #PlayerEntries * ENTRY_PAD + #TeamEntries * ENTRY_PAD
local canvasSize = teamSize + playerSize + spacing
if #TeamEntries > 0 and NeutralTeam and IsShowingNeutralFrame then
canvasSize = canvasSize + TeamEntrySizeY + ENTRY_PAD
end
ScrollList.CanvasSize = UDim2.new(0, 0, 0, canvasSize)
local newScrollListSize = math.min(canvasSize, Container.AbsoluteSize.y)
if ScrollList.Size.Y.Offset == LastMaxScrollSize then
ScrollList.Size = UDim2.new(1, 0, 0, newScrollListSize)
end
LastMaxScrollSize = newScrollListSize
end
--[[ Re-position Functions ]]--
local function setPlayerEntryPositions()
local position = 0
for i = 1, #PlayerEntries do
PlayerEntries[i].Frame.Position = UDim2.new(0, 0, 0, position)
position = position + PlayerEntrySizeY + 2
end
end
local function setTeamEntryPositions()
local teams = {}
for _,teamEntry in ipairs(TeamEntries) do
local team = teamEntry.Team
teams[tostring(team.TeamColor)] = {}
end
if NeutralTeam then
teams.Neutral = {}
end
for _,playerEntry in ipairs(PlayerEntries) do
local player = playerEntry.Player
if player.Neutral then
table.insert(teams.Neutral, playerEntry)
elseif teams[tostring(player.TeamColor)] then
table.insert(teams[tostring(player.TeamColor)], playerEntry)
else
table.insert(teams.Neutral, playerEntry)
end
end
local position = 0
for _,teamEntry in ipairs(TeamEntries) do
local team = teamEntry.Team
teamEntry.Frame.Position = UDim2.new(0, 0, 0, position)
position = position + TeamEntrySizeY + 2
local players = teams[tostring(team.TeamColor)]
for _,playerEntry in ipairs(players) do
playerEntry.Frame.Position = UDim2.new(0, 0, 0, position)
position = position + PlayerEntrySizeY + 2
end
end
if NeutralTeam then
NeutralTeam.Frame.Position = UDim2.new(0, 0, 0, position)
position = position + TeamEntrySizeY + 2
if #teams.Neutral > 0 then
IsShowingNeutralFrame = true
local players = teams.Neutral
for _,playerEntry in ipairs(players) do
playerEntry.Frame.Position = UDim2.new(0, 0, 0, position)
position = position + PlayerEntrySizeY + 2
end
else
IsShowingNeutralFrame = false
end
end
end
local function setEntryPositions()
table.sort(PlayerEntries, sortPlayerEntries)
if #TeamEntries > 0 then
setTeamEntryPositions()
else
setPlayerEntryPositions()
end
end
--[[ Friend/Report Functions ]]--
local selectedEntryMovedCn = nil
local function createPopupFrame(buttons)
local frame = Instance.new('Frame')
frame.Name = "PopupFrame"
frame.Size = UDim2.new(1, 0, 0, (PlayerEntrySizeY * #buttons) + (#buttons - 1))
frame.Position = UDim2.new(1, 1, 0, 0)
frame.BackgroundTransparency = 1
frame.Parent = PopupClipFrame
for i,button in ipairs(buttons) do
local btn = Instance.new('TextButton')
btn.Name = button.Name
btn.Size = UDim2.new(1, 0, 0, PlayerEntrySizeY)
btn.Position = UDim2.new(0, 0, 0, PlayerEntrySizeY * (i - 1) + (i - 1))
btn.BackgroundTransparency = BG_TRANSPARENCY
btn.BackgroundColor3 = BG_COLOR
btn.BorderSizePixel = 0
btn.Text = button.Text
btn.Font = Enum.Font.SourceSans
btn.FontSize = Enum.FontSize.Size14
btn.TextColor3 = TEXT_COLOR
btn.TextStrokeTransparency = TEXT_STROKE_TRANSPARENCY
btn.TextStrokeColor3 = TEXT_STROKE_COLOR
btn.AutoButtonColor = true
btn.Parent = frame
btn.MouseButton1Click:connect(button.OnPress)
end
return frame
end
-- if userId = nil, then it will get count for local player
local function getFriendCountAsync(userId)
local friendCount = nil
local wasSuccess, result = pcall(function()
local str = 'user/get-friendship-count'
if userId then
str = str..'?userId='..tostring(userId)
end
return HttpRbxApiService:GetAsync(str, true)
end)
if not wasSuccess then
print("getFriendCountAsync() failed because", result)
return nil
end
result = HttpService:JSONDecode(result)
if result["success"] and result["count"] then
friendCount = result["count"]
end
return friendCount
end
-- checks if we can send a friend request. Right now the only way we
-- can't is if one of the players is at the max friend limit
local function canSendFriendRequestAsync(otherPlayer)
if not IsMaxFriendsCount then return true end
--
local theirFriendCount = getFriendCountAsync(otherPlayer.userId)
local myFriendCount = getFriendCountAsync()
-- assume max friends if web call fails
if not myFriendCount or not theirFriendCount then
return false
end
if myFriendCount < MAX_FRIEND_COUNT and theirFriendCount < MAX_FRIEND_COUNT then
return true
elseif myFriendCount >= MAX_FRIEND_COUNT then
sendNotification("Cannot send friend request", "You are at the max friends limit.", "", 5, function() end)
return false
elseif theirFriendCount >= MAX_FRIEND_COUNT then
sendNotification("Cannot send friend request", otherPlayer.Name.." is at the max friends limit.", "", 5, function() end)
return false
end
end
local function hideFriendReportPopup()
if PopupFrame then
PopupFrame:TweenPosition(UDim2.new(1, 1, 0, PopupFrame.Position.Y.Offset), Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad, TWEEN_TIME, true, function()
PopupFrame:Destroy()
PopupFrame = nil
if selectedEntryMovedCn then
selectedEntryMovedCn:disconnect()
selectedEntryMovedCn = nil
end
end)
end
if LastSelectedFrame then
for _,childFrame in pairs(LastSelectedFrame:GetChildren()) do
if childFrame:IsA('TextButton') or childFrame:IsA('Frame') then
childFrame.BackgroundColor3 = BG_COLOR
end
end
end
ScrollList.ScrollingEnabled = true
LastSelectedFrame = nil
LastSelectedPlayer = nil
end
local function updateSocialIcon(newIcon, bgFrame)
local socialIcon = bgFrame:FindFirstChild('SocialIcon')
local nameFrame = bgFrame:FindFirstChild('PlayerName')
local offset = 19
if socialIcon then
if newIcon then
socialIcon.Image = newIcon
else
if nameFrame then
newSize = nameFrame.Size.X.Offset + socialIcon.Size.X.Offset + 2
nameFrame.Size = UDim2.new(-0.01, newSize, 0.5, 0)
nameFrame.Position = UDim2.new(0.01, offset, 0.245, 0)
end
socialIcon:Destroy()
end
elseif newIcon and bgFrame then
socialIcon = createImageIcon(newIcon, "SocialIcon", offset, bgFrame)
offset = offset + socialIcon.Size.X.Offset + 2
if nameFrame then
local newSize = bgFrame.Size.X.Offset - offset
nameFrame.Size = UDim2.new(-0.01, newSize, 0.5, 0)
nameFrame.Position = UDim2.new(0.01, offset, 0.245, 0)
end
end
end
local function onFollowerStatusChanged()
if not LastSelectedFrame or not LastSelectedPlayer then
return
end
-- don't update icon if already friends
local friendStatus = getFriendStatus(LastSelectedPlayer)
if friendStatus == Enum.FriendStatus.Friend then
return
end
local bgFrame = LastSelectedFrame:FindFirstChild('BGFrame')
local followerStatus = getFollowerStatus(LastSelectedPlayer)
local newIcon = getFollowerStatusIcon(followerStatus)
if bgFrame then
updateSocialIcon(newIcon, bgFrame)
end
end
-- Client follows followedUserId
local function onFollowButtonPressed()
if not LastSelectedPlayer then return end
--
local followedUserId = tostring(LastSelectedPlayer.userId)
local apiPath = "user/follow"
local params = "followedUserId="..followedUserId
local success, result = pcall(function()
return HttpRbxApiService:PostAsync(apiPath, params, true, Enum.ThrottlingPriority.Default, Enum.HttpContentType.ApplicationUrlEncoded)
end)
if not success then
print("followPlayer() failed because", result)
hideFriendReportPopup()
return
end
result = HttpService:JSONDecode(result)
if result["success"] then
sendNotification("You are", "now following "..LastSelectedPlayer.Name, FRIEND_IMAGE..followedUserId.."&x=48&y=48", 5, function() end)
if IsServerCoreScripts and RemoteEvent_OnNewFollower then
RemoteEvent_OnNewFollower:FireServer(Player, LastSelectedPlayer)
end
-- now update the social icon
onFollowerStatusChanged()
end
hideFriendReportPopup()
end
-- TODO: Move this to the notifications script. For now I want to keep it here until the
-- new notifications system goes live
if IsServerCoreScripts and RemoteEvent_OnNewFollower then
RemoteEvent_OnNewFollower.OnClientEvent:connect(function(followerRbxPlayer)
sendNotification("New Follower", followerRbxPlayer.Name.."is now following you!",
FRIEND_IMAGE..followerRbxPlayer.userId.."&x=48&y=48", 5, function() end)
end)
end
-- Client unfollows followedUserId
local function onUnfollowButtonPressed()
if not LastSelectedPlayer then return end
--
local apiPath = "user/unfollow"
local params = "followedUserId="..tostring(LastSelectedPlayer.userId)
local success, result = pcall(function()
return HttpRbxApiService:PostAsync(apiPath, params, true, Enum.ThrottlingPriority.Default, Enum.HttpContentType.ApplicationUrlEncoded)
end)
if not success then
print("unfollowPlayer() failed because", result)
hideFriendReportPopup()
return
end
result = HttpService:JSONDecode(result)
if result["success"] then
onFollowerStatusChanged()
end
hideFriendReportPopup()
-- no need to send notification when someone unfollows
end
local function onFriendButtonPressed()
if LastSelectedPlayer then
local status = getFriendStatus(LastSelectedPlayer)
if status == Enum.FriendStatus.Friend then
Player:RevokeFriendship(LastSelectedPlayer)
elseif status == Enum.FriendStatus.Unknown or status == Enum.FriendStatus.NotFriend then
-- cache and spawn
local cachedLastSelectedPlayer = LastSelectedPlayer
spawn(function()
-- check for max friends before letting them send the request
if canSendFriendRequestAsync(cachedLastSelectedPlayer) then -- Yields
if cachedLastSelectedPlayer and cachedLastSelectedPlayer.Parent == Players then
Player:RequestFriendship(cachedLastSelectedPlayer)