-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainModule.ModuleScript.lua
1497 lines (848 loc) · 41.9 KB
/
MainModule.ModuleScript.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
if _G.RaidLib then
warn("RaidLib already required, using existing running RaidLib:\n" .. debug.traceback())
return _G.RaidLib
end
script.Parent = game:GetService("ServerStorage")
local CollectionService, TweenService, Debris, Players, GroupService, HttpService, RunService = game:GetService("CollectionService"), game:GetService("TweenService"), game:GetService("Debris"), game:GetService("Players"), game:GetService("GroupService"), game:GetService("HttpService"), game:GetService("RunService")
local LoaderModule = require(game:GetService("ServerStorage"):FindFirstChild("LoaderModule") and game:GetService("ServerStorage").LoaderModule:FindFirstChild("MainModule") or 03593768376)("RaidLib")
if not game:GetService("ServerStorage"):FindFirstChild("VH_Command_Modules") then
local Folder = Instance.new("Folder")
Folder.Name = "VH_Command_Modules"
Folder.Parent = game:GetService("ServerStorage")
end
script.VH_Command_Modules.RaidLib.RaidLib.Value = script
LoaderModule(script:WaitForChild("VH_Command_Modules"), game:GetService("ServerStorage").VH_Command_Modules)
local RaidLib = {
RaidLimit = 60 * 60 * 2.5, -- How long a raid can go before the away team lose, 2.5 hours
HomeTeams = {}, -- Teams that can capture for the home group
HomeRequired = 1, -- How many of the home teams are required for capturepoints to be taken
AwayTeams = {}, -- Teams that can raid
AwayRequired = 1, -- How many of the home teams are required for capturepoints to be taken
RespawnAllPlayers = true, -- Respawns all the players at the start of the raid if this is true
EqualTeams = false, -- If true, raid will only be started if teams are equal
LockTeams = false, -- If true, teams will be limited to the same size when people leave
ManualStart = false, -- If true, raid can only be started by command
SingleSpawnPoints = true, -- If true any spawn points at capture points required by the captured point will be disabled
GracePeriod = 15, -- The away team won't be able to move when the raid starts for this period of time
BanWhenWinOrLoss = false, -- Do the away team get banned when raid limit is reached or they win? (Require V-Handle admin)
CaptureSpeed = 1, -- The speed at which points are captured as a percentage of the normal speed (1 = 100%, 0.5 = 50%)
AwayCaptureSpeed = 1, -- The speed at which points are captured relative to CaptureSpeed (1 = 100% of normal speed, 0.5 = 50% normal)
MaxPlrMultiplier = 100, -- Up to this many players will increase the speed of capturing a capture point
-- NO TOUCHY --
GameTick = 1,
CapturePoints = {},
RequiredCapturePoints = {},
Event_PreMatchStarted = Instance.new("BindableEvent"),
Event_RaidEnded = Instance.new("BindableEvent"),
Event_WinChanged = Instance.new("BindableEvent"),
Event_OfficialCheck = Instance.new("BindableEvent"),
Event_CapturePointAdded = Instance.new("BindableEvent"),
Event_ResetAll = Instance.new("BindableEvent"),
}
_G.RaidLib = RaidLib
local RFolder = Instance.new("Folder")
RFolder.Name = "RaidLib"
RFolder.Parent = game:GetService("ReplicatedStorage")
local VHMain
RaidLib.MaxPlayers = Players.MaxPlayers
RaidLib.OfficialRaid = Instance.new("BoolValue")
RaidLib.OfficialRaid.Name = "OfficialRaid"
RaidLib.OfficialRaid.Parent = RFolder
RaidLib.RaidID = Instance.new("StringValue")
RaidLib.RaidID.Name = "RaidID"
RaidLib.RaidID.Parent = RFolder
RaidLib.AwayWinAmount = Instance.new("NumberValue")
RaidLib.AwayWinAmount.Name = "AwayWinAmount"
RaidLib.AwayWinAmount.Parent = RFolder
RaidLib.HomeWinAmount = Instance.new("NumberValue")
RaidLib.HomeWinAmount.Name = "HomeWinAmount"
local RaidStarted = Instance.new("RemoteEvent")
RaidStarted.Name = "RaidStarted"
RaidStarted.Parent = RFolder
local RaidEnded = Instance.new("RemoteEvent")
RaidEnded.Name = "RaidEnded"
RaidEnded.Parent = RFolder
local RaidTimerEvent = Instance.new("RemoteEvent")
RaidTimerEvent.Name = "RaidTimerEvent"
RaidTimerEvent.OnServerEvent:Connect(function(Plr)
if RaidLib.RaidStart then
RaidTimerEvent:FireClient(Plr, RaidLib.RaidStart, RaidLib.CurRaidLimit)
end
end)
RaidTimerEvent.Parent = RFolder
RaidLib.Captured = Instance.new("RemoteEvent")
RaidLib.Captured.Name = "Captured"
RaidLib.Captured.Parent = RFolder
RaidLib.CheckpointReached = Instance.new("RemoteEvent")
RaidLib.CheckpointReached.Name = "CheckpointReached"
RaidLib.CheckpointReached.Parent = RFolder
local Ran, PlaceName = pcall(function() return game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Name:gsub("%b()", ""):gsub("%b[]", ""):gsub("^%s*(.+)%s*$", "%1") end)
RaidLib.PlaceName = Ran and PlaceName or "TestPlace"
RaidLib.PlaceAcronym = RaidLib.PlaceName:sub(1, 1):upper() .. RaidLib.PlaceName:sub(2):gsub(".", {a = "", e = "", i = "", o = "", u = ""}):gsub(" (.?)", function(a) return a:upper() end)
RaidLib.DefaultAwayEmblemUrl = "https://i.imgur.com/cYesNvI.png"
function RaidLib.FormatTime(Time)
return ("%.2d:%.2d:%.2d"):format(Time / (60 * 60), Time / 60 % 60, Time % 60)
end
local function HandleRbxAsync(DefualtValue, Function, ...)
local Result = {pcall(Function, ...)}
if Result[1] then
return select(2, unpack(Result))
else
warn(Result[2] .. "\n" .. debug.traceback(nil,2))
return DefualtValue
end
end
local function HandleGrace(Plr, Cur)
local Event, Event3, Event4
if RaidLib.AwayTeams[Plr.Team] then
Event = Plr.CharacterAdded:Connect(function(Char)
Char:WaitForChild("Humanoid").PlatformStand = true
Event4 = Char.ChildAdded:Connect(function(Obj)
if Obj:IsA("Tool") then
wait()
Obj.Parent = Plr.Backpack
end
end)
end)
end
local Event2 = Plr:GetPropertyChangedSignal("Team"):Connect(function()
if RaidLib.AwayTeams[Plr.Team] then
if not Event then
Event = Plr.CharacterAdded:Connect(function(Char)
Char:WaitForChild("Humanoid").PlatformStand = true
Event4 = Char.ChildAdded:Connect(function(Obj)
if Obj:IsA("Tool") then
Obj.Parent = Plr.Backpack
end
end)
end)
Plr:LoadCharacter()
end
else
if Event then
Event:Disconnect()
Event4:Disconnect()
Event = nil
if Plr.Character and Plr.Character:FindFirstChild("Humanoid") then
Plr.Character.Humanoid.PlatformStand = false
end
end
end
end)
Event3 = RaidLib.OfficialRaid:GetPropertyChangedSignal("Value"):Connect(function()
if not RaidLib.OfficialRaid.Value then
if Event then
Event:Disconnect()
Event = nil
Event2:Disconnect()
Event3:Disconnect()
Event4:Disconnect()
if Plr.Character and Plr.Character:FindFirstChild("Humanoid") then
Plr.Character.Humanoid.PlatformStand = false
end
end
end
end)
delay(RaidLib.GracePeriod - (tick() - Cur), function()
Event2:Disconnect()
Event3:Disconnect()
if Event then
Event:Disconnect()
Event = nil
Event4:Disconnect()
if Plr.Character and Plr.Character:FindFirstChild("Humanoid") then
Plr.Character.Humanoid.PlatformStand = false
end
end
end)
end
function RaidLib.CheckRequired(CapturePoint)
if CapturePoint.Required and (CapturePoint.ShouldRequireCheck == nil or CapturePoint:ShouldRequireCheck()) then
for _, Required in ipairs(CapturePoint.Required) do
if Required:RequireCheck() then
return false
end
end
end
return true
end
local RunningGameLoop
local function RunGameLoop()
RunningGameLoop = true
local Time = wait(0.1)
while RaidLib.RaidStart do
for _, CapturePoint in ipairs(RaidLib.CapturePoints) do
if CapturePoint.Tick then
local Active
if CapturePoint.ShouldTick then
Active = CapturePoint:ShouldTick()
else
Active = CapturePoint.Active
end
if Active and RaidLib.CheckRequired(CapturePoint) then
if CapturePoint.TickWithNear then
local Home, Away = RaidLib.GetSidesNear(CapturePoint.MainPart.Position, CapturePoint.Dist)
local CaptureSpeed = 0
if Home ~= 0 or Away ~= 0 or CapturePoint.PassiveCapture then
local BonusSpeed = 1
if CapturePoint.BonusSpeeds then
for _, Speed in pairs(CapturePoint.BonusSpeeds) do
BonusSpeed = BonusSpeed * Speed
end
end
CaptureSpeed = ((CapturePoint.PassiveCapture or 0) + (Home == Away and 0 or math.min(Home > Away and Home - Away or Away - Home, CapturePoint.MaxPlrMultiplier))) ^ 0.5 * (Away > Home and CapturePoint.AwayCaptureSpeed or CapturePoint.CaptureSpeed) * BonusSpeed
end
CapturePoint:Tick(CaptureSpeed, Home, Away)
else
CapturePoint:Tick()
end
end
end
end
local Result = RaidLib.GameMode.Function(RaidLib, Time, (#RaidLib.RequiredCapturePoints == 0 and #RaidLib.CapturePoints == 1) and RaidLib.CapturePoints or RaidLib.RequiredCapturePoints)
if Result then
RaidLib.EndRaid(Result)
end
Time = wait(RaidLib.GameTick)
end
RunningGameLoop = nil
end
function RaidLib.GetAwayGroup()
local Highest, HighestGroup
local AllGroups = {}
local Away = 0
for _, Plr in ipairs(Players:GetPlayers()) do
if RaidLib.AwayTeams[Plr.Team] then
for _, Group in ipairs(GroupService:GetGroupsAsync(Plr.UserId)) do
AllGroups[Group.Id] = (AllGroups[Group.Id] or 0) + (Group.IsPrimary and 2 or 1)
if not Highest or AllGroups[Group.Id] > AllGroups[Highest] then
Highest = Group.Id
HighestGroup = Group
end
end
end
end
if not Highest or AllGroups[Highest] <= Away * 0.35 then
return {Name = (RaidLib.DefaultAwayName or next(RaidLib.AwayTeams).Name), EmblemUrl = RaidLib.DefaultAwayEmblemUrl or "", EmblemId = RaidLib.DefaultAwayEmblemId or "", Id = RaidLib.DefaultAwayId or 0}
end
return HighestGroup
end
function RaidLib.GroupPagesToArray(Pages)
local Array = {}
while true do
local Page = Pages:GetCurrentPage()
for _, Group in ipairs(Page) do
Array[#Array + 1] = Group.Id
end
if Pages.isFinished then break end
Pages:AdvanceToNextPageAsync()
end
return Array
end
local IDWords = {"Roblox", "Robloxian", "TRA", "Observation", "Jumpy", "Books", "Level", "Fast", "Loud", "Wheel", "Abandoned", "Deliver", "Rock", "Rub", "Tame", "Muscle", "Frighten", "Sore", "Number", "Dress", "Lucky", "Love", "Roomy", "Rambunctious", "Tiger", "Group", "Flame", "Gullible", "Obtainable", "Trail", "Brake", "Famous", "Perform", "Idea", "Mix", "Graceful", "Cub", "Argument", "Male", "Trust", "Gigantic", "Pump", "Move", "Ear", "Paddle", "Tall", "Feigned", "Toad", "Public", "Delightful", "Test", "Sponge", "Regular", "Marry", "Grotesque", "Stop", "Walk", "Memorise", "Spectacular", "Giants", "Drawer", "Cloudy", "Pies", "Cheap", "Woozy", "Dinner", "Guide", "Rabid", "Statement", "Four", "Pipe", "Crate", "Paper", "Seemly", "Old", "Heal", "Base", "Marked", "Disturbed", "Shiny", "Boiling", "Wary", "Bone", "Play", "Copy", "Toys", "Mourn", "Support", "Haircut", "Downtown", "Closed", "Film", "Stiff", "Murky", "Frantic", "Juvenile", "Disagreeable", "Madly", "Unsuitable", "Nonstop", "Grab", "Wrong", "Melt", "Anxious", "Clip", "Weary", "Crow", "Refuse", "Frightened", "Fluffy", "Breezy", "Pizzas", "Right", "Tangy", "Toy", "Bizarre", "Concentrate", "Pocket", "Fork", "Push", "Quick", "Miniature", "Abusive", "Carry", "Heavenly", "Better", "Silent", "Few", "Versed", "Receipt", "Tug", "Matter", "Excuse", "Sore", "Practise", "Brown", "Clear", "Gamy", "Increase", "Subsequent", "Connect", "Careful", "Attraction", "Silk", "Vessel", "Plant", "Summer", "North", "Deeply", "Able", "Fresh", "Splendid", "True", "Bag", "Fixed", "Damaged", "Manage", "General", "Thoughtless", "Nappy", "Breakable", "Disagree", "Curious", "Learned", "Zippy", "Understood", "Fascinated", "Meaty", "Jaded", "Regret", "Switch", "House", "Torpid", "Neat", "String", "Top", "Literate", "Actually", "Things", "Girls", "Voiceless", "Delicious", "Check", "Aspiring", "Decorate", "Allow", "Oatmeal", "Massive", "Spiky", "Towering", "Horrible", "Many", "Education", "Scrape", "Moan", "Regret", "Head", "Decorous", "Weight", "Rain", "Hill", "Determined", "Smooth", "Lake", "Hideous", "Clever", "Average", "Discovery", "Squirrel", "Husky", "Flow", "Probable", "Illegal", "Imaginary", "Quill", "Start", "Laughable", "Temper", "Wool", "Smash", "Lopsided", "Shelf", "Premium", "Stem", "Zipper", "Used", "Receptive", "Hat", "Rush", "Example", "Knotty", "Heartbreaking", "Drip", "Part", "Succinct", "Amusement", "Sprout", "Late", "Scintillating", "Fairies", "Willing", "Unnatural", "Terrific", "Maniacal", "Glove", "Devilish", "Callous", "Liquid", "Mute", "Fry", "Tightfisted", "Accidental", "Coal", "Ancient", "Simplistic", "Tempt", "Shrug", "Tax", "Calendar", "Reaction", "Trade", "Drop", "Tickle", "Kindly", "Hop", "Town", "License", "Scold", "Obey", "Ambitious", "Book", "Itch", "Reminiscent", "Argue", "Cup", "Separate", "Meek", "Worthless", "Disillusioned", "Brick", "Innate", "Scare", "Macho", "Harbor", "Flowers", "Arm", "Advice", "Voyage", "Suffer", "Quixotic", "Dirty", "Thaw", "Malicious", "Impress", "Prevent", "Watch", "Stew", "Upset", "Green", "Adjustment", "Smart", "Land", "Caring", "Slow", "Purple", "Remove", "Nest", "Wash", "Attack", "Swift", "Low", "Squalid", "Labored", "Sticky", "Kindhearted", "Milk", "Bruise", "Bear", "Offer", "Even", "Juice", "Place", "End", "Flower", "Terrible", "Disgusting", "Veil", "Hard", "Whistle", "Exchange", "Surprise", "Fancy", "Pen", "Army", "Dazzling", "Harsh", "Knowledgeable", "Unhealthy", "Root", "Puny", "Oval", "Cows", "Juicy", "Daughter", "Dirt", "Low", "Slippery", "Agree", "Shoe", "Cattle", "Rebel", "Sparkle", "Adhesive", "Duck", "Warm", "Lowly", "Parsimonious", "Arrive", "Camp", "Join", "Thread", "Paste", "Drag", "Kind", "Impolite", "Steady", "Spoon", "Rose", "Curve", "Coach", "Sidewalk", "Panicky", "Rejoice", "Hand", "Settle", "Suspend", "Hope", "Foregoing", "Sound", "Preserve", "Scatter", "Carpenter", "Boast", "Good", "Poised", "Risk", "Nifty", "Beautiful", "Pinch", "Gruesome", "Alluring", "Amuse", "Sticks", "Request", "Unadvised", "Meddle", "Unpack", "Knit", "Smell", "Screeching", "Perfect", "Crazy", "Hapless", "Dolls", "Coach", "Cakes", "Gray", "Level", "Roasted", "Naughty", "Nation", "Bird", "Equable", "Stamp", "Button", "Quiet", "Butter", "Helpless", "Store", "Box", "Debonair", "Dispensable", "Desk", "Head", "Bolt", "Push", "Homely", "Picayune", "Demonic", "Rely", "Obscene", "Defeated", "Safe", "Fear", "Domineering", "Long", "Erect", "Produce", "Jellyfish", "End", "Rabbits", "Violet", "Sophisticated", "Scattered", "Swing", "Tart", "Government", "Silver", "Shame", "Wholesale", "Detail", "Minister", "Holistic", "Mate", "Fragile", "Lackadaisical", "Control", "Steadfast", "Ugliest", "Yellow", "Seat", "Future", "Engine", "Icy", "Gate", "Acidic", "Capricious", "Abaft", "Telephone", "Question", "False", "Sneaky", "Enormous", "Spray", "Exclusive", "Run", "Scene", "Inform", "Fail", "Uncle", "Ablaze", "Trousers", "Wanting", "Surround", "Grandmother", "Stop", "Slip", "Reply", "Vegetable", "Hulking", "Confused", "Sheet", "Coil", "Whisper", "Last", "Person", "Jeans", "Smoggy", "Gratis", "Search", "Partixel", "CodeNil", "Antyronio", "Peekay"}
local PracticeWords = {"Test", "Debug", "Fake", "Tryhard", "Learn", "Lesson", "Usage", "Action", "Discipline", "Drill", "Experience", "Study", "Training", "Assignment", "Homework", "Recitation", "Rehearsal", "Prepping"}
local IDRandom = Random.new()
function RaidLib.StartRaid()
RaidLib.Practice = RaidLib.Practice or game.PrivateServerId ~= ""
if RaidLib.GameMode then
local MyId
if RaidLib.Practice then
local Pos = math.random(1, 3)
if Pos == 1 then
MyId = "Practice" .. PracticeWords[IDRandom:NextInteger(1, #PracticeWords)] .. PracticeWords[IDRandom:NextInteger(1, #PracticeWords)]
elseif Pos == 2 then
MyId = PracticeWords[IDRandom:NextInteger(1, #PracticeWords)] .. "Practice" .. PracticeWords[IDRandom:NextInteger(1, #PracticeWords)]
else
MyId = PracticeWords[IDRandom:NextInteger(1, #PracticeWords)] .. PracticeWords[IDRandom:NextInteger(1, #PracticeWords)] .. "Practice"
end
else
MyId = IDWords[IDRandom:NextInteger(1, #IDWords)] .. IDWords[IDRandom:NextInteger(1, #IDWords)] .. IDWords[IDRandom:NextInteger(1, #IDWords)]
end
RaidLib.RaidID.Value = MyId
RaidLib.AwayGroup = RaidLib.GetAwayGroup()
RaidLib.TeamLog = {}
if RaidLib.PreMatchTime then
RaidLib.Event_PreMatchStarted:Fire()
wait(RaidLib.PreMatchTime)
end
if MyId == RaidLib.RaidID.Value then
local Cur = tick()
RaidLib.RaidStart = Cur
RaidLib.CurRaidLimit = RaidLib.RaidLimit
RaidLib.OfficialRaid.Value = true
RaidTimerEvent:FireAllClients(RaidLib.RaidStart, RaidLib.CurRaidLimit, RaidLib.GameMode.WinTime or RaidLib.GameMode.WinPoints)
RaidStarted:FireAllClients(RaidLib.RaidID.Value, RaidLib.AwayGroup)
for _, Plr in ipairs(Players:GetPlayers()) do
RaidLib.TeamLog[tostring(Plr.UserId)] = {{Cur, Plr.Team}}
if RaidLib.GracePeriod and RaidLib.GracePeriod > 0 then
HandleGrace(Plr, Cur)
end
if RaidLib.RespawnPlayers ~= false and (RaidLib.RespawnAllPlayers or RaidLib.AwayTeams[Plr.Team]) then
Plr:LoadCharacter()
end
end
for a = 1, #RaidLib.CapturePoints do
if not RaidLib.CapturePoints[a].ManualActivation then
if RaidLib.CapturePoints[a].Required then
local Active = true
for b = 1, #RaidLib.CapturePoints[a].Required do
if not RaidLib.CapturePoints[a].Required[b].Active then
Active = false
break
end
end
if Active then
RaidLib.CapturePoints[a].Active = true
end
elseif RaidLib.CapturePoints[a].DefaultActive ~= nil then
RaidLib.CapturePoints[a].Active = RaidLib.CapturePoints[a].DefaultActive
else
RaidLib.CapturePoints[a].Active = true
end
end
end
if not RunningGameLoop then
coroutine.wrap(RunGameLoop)()
end
end
end
end
function RaidLib.EndRaid(Result)
RaidLib.Event_RaidEnded:Fire(RaidLib.RaidID.Value, RaidLib.AwayGroup, Result, RaidLib.TeamLog, RaidLib.RaidStart)
RaidEnded:FireAllClients(RaidLib.RaidID.Value, RaidLib.AwayGroup, Result)
local Practice = RaidLib.Practice or not RaidLib.RaidStart
RaidLib.ResetAll()
if not Practice and Result ~= "Forced" and Result ~= "Left" and RaidLib.KickOnEnd ~= false then
wait(20)
for _, Plr in ipairs(Players:GetPlayers()) do
if RaidLib.AwayTeams[Plr.Team] then
if RaidLib.BanWhenWinOrLoss and VHMain then
VHMain.ParseCmdStacks(nil, "permban/" .. Plr.UserId .. "/30m")
else
Plr:Kick("Raid is over, please rejoin to raid again")
end
end
end
end
end
game:BindToClose(function()
if RaidLib.RaidID.Value then
RaidLib.EndRaid("Left")
end
end)
function RaidLib.ResetAll()
RaidLib.HomeMax, RaidLib.AwayMax = nil, nil
RaidLib.Practice = nil
RaidLib.RallyMessage = nil
RaidLib.Forced = nil
RaidLib.RaidStart = nil
RaidLib.CurRaidLimit = nil
RaidLib.TeamLog = nil
RaidLib.AwayGroup = nil
RaidLib.RaidID.Value = ""
RaidLib.AwayWinAmount.Value = 0
RaidLib.HomeWinAmount.Value = 0
RaidTimerEvent:FireAllClients()
RaidLib.OfficialRaid.Value = false
for _, CapturePoint in ipairs(RaidLib.CapturePoints) do
CapturePoint:Reset()
end
RaidLib.Event_ResetAll:Fire()
end
function RaidLib.GetCountFor(Side, Plr)
local Team = Side[Plr.Team]
if Team then
local CountsFor = Team.CountsFor
for _, Counts in ipairs(Team) do
if Counts.CountsFor then
for _, Count in ipairs(Counts) do
if HandleRbxAsync(false, Plr.IsInGroup, Plr, Count) then
return Counts.CountsFor
end
end
end
end
return CountsFor
end
return 0
end
function RaidLib.SetWinTimer(Val)
if RaidLib.AwayWinAmount.Value ~= Val then
local Old = RaidLib.AwayWinAmount.Value
RaidLib.AwayWinAmount.Value = Val
RaidLib.Event_WinChanged:Fire(Old)
end
end
function RaidLib.CountTeams()
local Home, Away = 0, 0
for _, Plr in ipairs(Players:GetPlayers()) do
Home = Home + RaidLib.GetCountFor(RaidLib.HomeTeams, Plr)
Away = Away + RaidLib.GetCountFor(RaidLib.AwayTeams, Plr)
end
return Home, Away
end
local TimeCheck
function RaidLib.OfficialCheck(Manual)
local Home, Away = RaidLib.CountTeams()
if RaidLib.RaidID.Value ~= "" then
if Away == 0 and not RaidLib.Forced then
RaidLib.EndRaid("Left")
end
else
local Result
if Manual == true or not RaidLib.ManualStart then
local BST = HttpService:GetAsync("https://rbxapi.v-handle.com/?type=4"):sub(1, 1) == "1"
local InTime
if RaidLib.MinTime and RaidLib.MaxTime then
local MinTime, MaxTime = RaidLib.MinTime - (BST and 1 or 0), RaidLib.MaxTime - (BST and 1 or 0)
InTime = false
local Time = os.date("!*t").hour + (os.date("!*t").min / 60)
if MaxTime > MinTime then
if Time >= MinTime and Time < MaxTime then
InTime = true
end
elseif Time < MaxTime or Time >= MinTime then
InTime = true
end
end
if InTime == false then
local MinTime, MaxTime = RaidLib.MinTime, RaidLib.MaxTime
MinTime = math.floor(MinTime) .. ":" .. math.floor((MinTime - math.floor(MinTime) * 60) + 0.5)
MaxTime = math.floor(MaxTime) .. ":" .. math.floor((MaxTime - math.floor(MaxTime) * 60) + 0.5)
Result = "Must raid between the times of " .. MinTime .. " and " .. MaxTime
if not TimeCheck then
TimeCheck = true
coroutine.wrap(function()
while wait(1) and not RaidLib.RaidStart do
RaidLib.OfficialCheck()
end
TimeCheck = nil
end)()
end
elseif Away < RaidLib.AwayRequired or Away == 0 then
Result = "Must be at least " .. math.max(RaidLib.AwayRequired, 1) .. " players on the away teams"
elseif Home < RaidLib.HomeRequired then
Result = "Must be at least " .. RaidLib.HomeRequired .. " players on the home teams"
elseif RaidLib.EqualTeams and (Home ~= Away) then
Result = "Teams must be equal to start"
else
coroutine.wrap(RaidLib.StartRaid)()
end
end
RaidLib.Event_OfficialCheck:Fire(Home, Away, Result)
return Result
end
end
function PlayerAdded(Plr)
local Found
for Team, CountsFor in pairs(RaidLib.HomeTeams) do
for _, Counts in ipairs(CountsFor) do
for _, Count in ipairs(Counts) do
if HandleRbxAsync(false, Plr.IsInGroup, Plr, Count) then
Plr.Team = Team
Plr:LoadCharacter()
Found = true
break
end
end
end
if Found then break end
end
if not Found then
for Team, CountsFor in pairs(RaidLib.AwayTeams) do
for _, Counts in ipairs(CountsFor) do
for _, Count in ipairs(Counts) do
if HandleRbxAsync(false, Plr.IsInGroup, Plr, Count) then
Plr.Team = Team
Found = true
break
end
end
end
if Found then break end
end
end
local Home, Away = RaidLib.CountTeams()
if not RaidLib.RaidStart and RaidLib.AwayTeams[Plr.Team] then
if RaidLib.MaxPlayers - Away < RaidLib.HomeRequired then
Plr:Kick("You were kicked to make room for " .. (RaidLib.HomeRequired - (RaidLib.MaxPlayers - Away)) .. " more " .. next(RaidLib.HomeTeams).Name)
return
elseif RaidLib.EqualTeams and Away > RaidLib.MaxPlayers / 2 then
Plr:Kick("You were kicked to make room for " .. (RaidLib.MaxPlayers / 2 - Home) .. " more " .. next(RaidLib.HomeTeams).Name)
return
end
end
if RaidLib.RaidStart then
if RaidLib.LockTeams then
if RaidLib.HomeTeams[Plr.Team] and Home > Away + 1 then
Plr:Kick(next(RaidLib.HomeTeams).Name .. " is full, please wait for more " .. next(RaidLib.AwayTeams).Name)
return
elseif RaidLib.AwayTeams[Plr.Team] and Away > Home + 1 then
Plr:Kick(next(RaidLib.AwayTeams).Name .. " is full, please wait for more " .. next(RaidLib.HomeTeams).Name)
return
end
end
if RaidLib.GracePeriod and RaidLib.GracePeriod > 0 and tick() - RaidLib.RaidStart < RaidLib.GracePeriod then
if RaidLib.AwayTeams[Plr.Team] then
HandleGrace(Plr)
end
end
RaidLib.TeamLog[tostring(Plr.UserId)] = RaidLib.TeamLog[tostring(Plr.UserId)] or {}
RaidLib.TeamLog[tostring(Plr.UserId)][#RaidLib.TeamLog[tostring(Plr.UserId)] + 1] = {tick(), Plr.Team }
end
RaidLib.OfficialCheck()
local Team = Plr.Team
Plr:GetPropertyChangedSignal("Team"):Connect(function()
if RaidLib.RaidStart then
if RaidLib.LockTeams then
local Home, Away = RaidLib.CountTeams()
if RaidLib.HomeTeams[Plr.Team] and (Home > Away + 1 or (not RaidLib.EqualTeams or Home > RaidLib.MaxPlayers / 2)) then
Plr.Team = Team
return
elseif RaidLib.AwayTeams[Plr.Team] and (Away > Home + 1 or (not RaidLib.EqualTeams or Home > RaidLib.MaxPlayers / 2)) then
Plr.Team = Team
return
end
end
RaidLib.TeamLog[tostring(Plr.UserId)][#RaidLib.TeamLog[tostring(Plr.UserId)] + 1] = {tick(), Plr.Team}
end
Team = Plr.Team
RaidLib.OfficialCheck()
end)
end
Players.PlayerRemoving:Connect(function(Plr)
RaidLib.OfficialCheck()
if RaidLib.RaidStart then
RaidLib.TeamLog[tostring(Plr.UserId)] = RaidLib.TeamLog[tostring(Plr.UserId)] or {}
RaidLib.TeamLog[tostring(Plr.UserId)][#RaidLib.TeamLog[tostring(Plr.UserId)] + 1] = {tick()}
end
end)
Players.PlayerAdded:Connect(PlayerAdded)
for _, Plr in ipairs(Players:GetPlayers()) do
PlayerAdded(Plr)
end
function RaidLib.OldFlagCompat()
local Message
RaidLib.OfficialRaid:GetPropertyChangedSignal("Value"):Connect(function()
if RaidLib.OfficialRaid.Value then
if Message then Message:Destroy() end
Message = Instance.new("Message", workspace)
Message.Text = RaidLib.AwayGroup.Name .. " have started raiding"
Debris:AddItem(Message, 5)
end
end)
RaidLib.Event_CapturePointAdded.Event:Connect(function(Num)
local CapturePoint = RaidLib.CapturePoints[Num]
CapturePoint.Event_Captured.Event:Connect(function()
local Hint = Instance.new("Hint", workspace)
Hint.Text = "The flag at the " .. CapturePoint.Name .. " is now owned by " .. next(CapturePoint.CurOwner).Name
Debris:AddItem(Hint, 5)
end)
end)
for _, CapturePoint in ipairs(RaidLib.CapturePoints) do
CapturePoint.Event_Captured.Event:Connect(function()
local Hint = Instance.new("Hint", workspace)
Hint.Text = "The flag at the " .. CapturePoint.Name .. " is now owned by " .. next(CapturePoint.CurOwner).Name
Debris:AddItem(Hint, 5)
end)
end
RaidLib.Event_RaidEnded.Event:Connect(function(ID, AwayGroup, Result, RaidStart)
if not RaidStart then return end
if Message then Message:Destroy() end
Message = Instance.new("Message", workspace)
if Result ~= "Forced" and Result ~= "Left" then
local Name
if Result == "Lost" then
Name = AwayGroup.Name
else
Name = RaidLib.HomeGroup.Name
end
Message.Text = Name .. " has won! ID: " .. ID .. " - " .. AwayGroup.Name .. " get kicked in 20s"
Debris:AddItem(Message, 20)
for a = 19, 0, -1 do
wait(1)
Message.Text = Name .. " has won! ID: " .. ID .. " - " .. AwayGroup.Name .. " get kicked in " .. a .. "s"
end
else
local Txt = Result == "Left" and AwayGroup.Name .. " have left, raid over!" or Result == "Forced" and "An admin has force ended the raid!"
Message.Text = Txt
Debris:AddItem(Message, 5)
end
end)
end
function RaidLib.GetSidesNear(Point, Dist)
local Home, Away = 0, 0
for _, Plr in ipairs(Players:GetPlayers()) do
local b = Plr
if b.Character and b.Character:FindFirstChild("Humanoid") and b.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Dead and b:DistanceFromCharacter(Point) < Dist then
if RaidLib.HomeTeams[b.Team] then
Home = Home + 1
elseif RaidLib.AwayTeams[b.Team]then