-
-
Notifications
You must be signed in to change notification settings - Fork 233
Expand file tree
/
Copy pathProcess.luau
More file actions
1233 lines (1056 loc) · 37.3 KB
/
Copy pathProcess.luau
File metadata and controls
1233 lines (1056 loc) · 37.3 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
--// Processing
return function(Vargs, GetEnv)
local env = GetEnv(nil, {script = script})
setfenv(1, env)
local server = Vargs.Server
local service = Vargs.Service
local Commands, Decrypt, Encrypt, AddLog, TrackTask, Pcall
local Functions, Admin, Anti, Core, HTTP, Logs, Remote, Process, Variables, Settings, Defaults
local logError = env.logError
local Routine = env.Routine
local function Init()
Functions = server.Functions;
Admin = server.Admin;
Anti = server.Anti;
Core = server.Core;
HTTP = server.HTTP;
Logs = server.Logs;
Remote = server.Remote;
Process = server.Process;
Variables = server.Variables;
Settings = server.Settings;
Defaults = server.Defaults;
logError = logError or env.logError;
Routine = Routine or env.Routine;
Commands = Remote.Commands
Decrypt = Remote.NewDecrypt
Encrypt = Remote.NewEncrypt
AddLog = Logs.AddLog
TrackTask = service.TrackTask
Pcall = server.Pcall
--// NetworkServer Events
if service.NetworkServer then
service.RbxEvent(service.NetworkServer.ChildAdded, server.Process.NetworkAdded)
service.RbxEvent(service.NetworkServer.DescendantRemoving, server.Process.NetworkRemoved)
end
--// Necessary checks to prevent first time users from bypassing bans.
service.Events.DataStoreAdd_Banned:Connect(function(data: table|string)
local userId = if type(data) == "string" then tonumber(string.match(data, ":(%d+)$"))
elseif type(data) == "table" then data.UserId
else nil
local plr = userId and service.Players:GetPlayerByUserId(userId)
if plr then
local reason = if type(data) == "table" and data.Reason then data.Reason
else "No reason provided"
pcall(plr.Kick, plr, string.format("%s | Reason: %s", Variables.BanMessage, reason))
AddLog("Script", {
Text = `Applied ban on {plr.Name}`;
Desc = `Ban reason: {reason}`;
})
end
end)
service.Events["DataStoreAdd_Core.Variables.TimeBans"]:Connect(function(data)
local userId = if type(data) == "string" then tonumber(string.match(data, ":(%d+)$"))
elseif type(data) == "table" then data.UserId
else nil
local plr = userId and service.Players:GetPlayerByUserId(userId)
if plr then
local reason = if type(data) == "table" and data.Reason then data.Reason
else "No reason provided"
pcall(
plr.Kick,
plr,
string.format(
"\n Reason: %s\n Banned until %s",
(reason or "(No reason provided."),
service.FormatTime(data.EndTime, { WithWrittenDate = true })
)
)
AddLog("Script", {
Text = `Applied TimeBan on {plr.Name}`;
Desc = `Ban reason: {reason}`;
})
end
end)
if Settings.G_Access_Key ~= "Example_Key" and Settings.Allowed_API_Calls.Client then
Remote._globalAccessHash = Functions.SHA256(Settings.G_Access_Key..game.GameId)
end
Process.Init = nil
AddLog("Script", "Processing Module Initialized")
end;
local function RunAfterPlugins(data)
local existingPlayers = service.Players:GetPlayers()
--// Events
service.RbxEvent(service.Players.PlayerAdded, service.EventTask("PlayerAdded", Process.PlayerAdded))
service.RbxEvent(service.Players.PlayerRemoving, service.EventTask("PlayerRemoving", Process.PlayerRemoving))
task.spawn(function()
local oldVer = tonumber(Core.GetData("VersionNumber"))
if oldVer and server.Version and server.Version > oldVer then
Process.SaveDatastoreVersionDebounce = true
table.insert(server.Messages, {
Level = 1;
Title = "Updated!";
Message = "Click to view the changelog.";
Time = 10;
Icon = "MatIcon://System upgrade";
onClick = Core.Bytecode(`client.Remote.Send("ProcessCommand","{Settings.Prefix}changelog")`);
})
end
end)
if Core.DebugMode == true then
table.insert(server.Messages, {
Level = 301;
Title = "Debug Mode Enabled";
Message = "Adonis is currently running in Debug Mode.";
Time = 10;
Icon = "MatIcon://Bug report";
onClick = Core.Bytecode(`client.Remote.Send("ProcessCommand","{Settings.Prefix}debugcmds")`);
})
end
if Settings.DataStoreKey == Defaults.Settings.DataStoreKey and Core.DebugMode == false then
table.insert(server.Messages, {
Level = 301;
Title = "Warning!";
Message = "Using default datastore key!";
Time = 15;
Icon = "MatIcon://Description";
onClick = Core.Bytecode([[
local window = client.UI.Make("Window", {
Title = "How to change the DataStore key";
Size = {700,300};
Icon = "rbxassetid://7510994359";
})
window:Add("ImageLabel", {
Image = "rbxassetid://1059543904";
})
window:Ready()
]])})
end
--// Load client onto existing players
if existingPlayers then
for i, p in existingPlayers do
Core.LoadExistingPlayer(p)
end
end
Process.RunAfterPlugins = nil
AddLog("Script", "Process Module RunAfterPlugins Finished")
end
local function newRateLimit(rateLimit: table, rateKey: string|number)
-- Ratelimit: table
-- Ratekey: string or number
local rateData = (type(rateLimit)=="table" and rateLimit) or nil
if not rateData then
error("Rate data doesn't exist (unable to check)")
else
-- RATELIMIT TABLE
--[[
Table:
{
Rates = 100; -- Max requests per traffic
Reset = 1; -- Interval seconds since the cache last updated to reset
ThrottleEnabled = false/true; -- Whether throttle can be enabled
ThrottleReset = 10; -- Interval seconds since the cache last throttled to reset
ThrottleMax = 10; -- Max interval count of throttles
Caches = {}; -- DO NOT ADD THIS. IT WILL AUTOMATICALLY BE CREATED ONCE RATELIMIT TABLE IS CHECKING-
--... FOR RATE PASS AND THROTTLE CHECK.
}
]]
-- RATECACHE TABLE
--[[
Table:
{
Rate = 0;
Throttle = 0; -- Interval seconds since the cache last updated to reset
LastUpdated = 0; -- Last checked for rate limit
LastThrottled = nil or 0; -- Last checked for throttle (only changes if rate limit failed)
}
]]
local maxRate: number = math.abs(rateData.Rates) -- Max requests per traffic
local resetInterval: number = math.floor(math.abs(rateData.Reset or 1)) -- Interval seconds since the cache last updated to reset
local rateExceeded: boolean? = rateLimit.Exceeded or rateLimit.exceeded
local ratePassed: boolean? = rateLimit.Passed or rateLimit.passed
local canThrottle: boolean? = rateLimit.ThrottleEnabled
local throttleReset: number? = rateLimit.ThrottleReset
local throttleMax: number? = math.floor(math.abs(rateData.ThrottleMax or 1))
-- Ensure minimum requirement is followed
maxRate = (maxRate>1 and maxRate) or 1
-- Max rate must have at least one rate else anything below 1 returns false for all rate checks
local cacheLib = rateData.Caches
if not cacheLib then
cacheLib = {}
rateData.Caches = cacheLib
end
-- Check cache
local rateCache: table = cacheLib[rateKey]
local throttleCache
if not rateCache then
rateCache = {
Rate = 0;
Throttle = 0;
LastUpdated = os.clock();
LastThrottled = nil;
}
cacheLib[rateKey] = rateCache
end
local nowOs = os.clock()
if nowOs-rateCache.LastUpdated > resetInterval then
rateCache.LastUpdated = nowOs
rateCache.Rate = 0
end
local ratePass: boolean = rateCache.Rate+1<=maxRate
local didThrottle: boolean = canThrottle and rateCache.Throttle+1<=throttleMax
local throttleResetOs: number? = rateCache.ThrottleReset
local canResetThrottle: boolean = throttleResetOs and nowOs-throttleResetOs <= 0
rateCache.Rate += 1
-- Check can throttle and whether throttle could be reset
if canThrottle and canResetThrottle then
rateCache.Throttle = 0
end
-- If rate failed and can also throttle, count tick
if canThrottle and (not ratePass and didThrottle) then
rateCache.Throttle += 1
rateCache.LastThrottled = nowOs
-- Check whether cache time expired and replace it with a new one or set a new one
if not throttleResetOs or canResetThrottle then
rateCache.ThrottleReset = nowOs
end
elseif canThrottle and ratePass then
rateCache.Throttle = 0
end
if rateExceeded and not ratePass then
rateExceeded:Fire(rateKey, rateCache.Rate, maxRate)
end
if ratePassed and ratePass then
ratePassed:Fire(rateKey, rateCache.Rate, maxRate)
end
return ratePass, didThrottle, canThrottle, rateCache.Rate, maxRate, throttleResetOs
end
end
local RateLimiter = {
Remote = {
Rates = 120;
Reset = 60;
};
Command = {
Rates = 20;
Reset = 40;
};
Chat = {
Rates = 10;
Reset = 1;
};
RateLog = {
Rates = 10;
Reset = 2;
};
}
local unWrap = service.unWrap
local function RateLimit(p, typ)
local isPlayer = type(p)=="userdata" and p:IsA"Player"
if isPlayer then
local rateData = RateLimiter[typ]
assert(rateData, `No rate limit data available for the given type {typ}`)
local ratePass, didThrottle, canThrottle, curRate, maxRate = newRateLimit(rateData, p.UserId)
return ratePass, didThrottle, canThrottle, curRate, maxRate
else
return true
end
end
server.Process = {
Init = Init;
RunAfterPlugins = RunAfterPlugins;
RateLimit = RateLimit;
newRateLimit = newRateLimit;
MsgStringLimit = 500; --// Max message string length to prevent long length chat spam server crashing (chat & command bar); Anything over will be truncated;
MaxChatCharacterLimit = 250; --// Roblox chat character limit; The actual limit of the Roblox chat's textbox is 200 characters; I'm paranoid so I added 50 characters; Users should not be able to send a message larger than that;
RemoteMaxArgCount = 5; --// The maximum argument count Adonis will take from Remote (alter if your script requires more arguments)
RateLimits = {
Remote = 0.01;
Command = 0.1;
Chat = 0.1;
RateLog = 10;
};
Remote = function(p, cliData, com, ...)
if p and p:IsA("Player") then
if Anti.KickedPlayers[p] then
p:Kick(":: Adonis :: Communication following disconnect.")
elseif not com or type(com) ~= "string" or #com > 50 or cliData == "BadMemes" or com == "BadMemes" then
Anti.Detected(p, "Kick", service.MaxLen((tostring(com) ~= "BadMemes" and tostring(com)) or tostring(select(1, ...)), 150))
elseif cliData and type(cliData) ~= "table" then
Anti.Detected(p, "Kick", "Invalid Client Data (r10002)")
--elseif cliData and keys and cliData.Module ~= keys.Module then
-- Anti.Detected(p, "Kick", "Invalid Client Module (r10006)")
else
local keys = Remote.Clients[tostring(p.UserId)]
if keys and select("#", ...) <= Process.RemoteMaxArgCount then
local args = table.pack(...)
local rateLimitCheck, _, _, curRemoteRate = RateLimit(p, "Remote")
keys.LastUpdate = os.time()
keys.Received += 1
if type(com) == "string" then
if com == `{keys.Special}GET_KEY` then
if cliData.Mode == "Get" then
AddLog("RemoteFires", {
Text = `{p.Name} requested key from server`,
Desc = "Player requested key from server",
Player = p;
})
if keys.LoadingStatus == "WAITING_FOR_KEY" then
keys.LoadingStatus = "LOADING"
keys.RemoteReady = true
AddLog("Script", string.format("%s requested client keys", p.Name))
return keys.Key
--else
--Anti.Detected(p, "kick", "Communication Key Error (r10003)")
end
elseif cliData.Mode == "Fire" then
if keys.LoadingStatus == "WAITING_FOR_KEY" then
Remote.Fire(p, `{keys.Special}GIVE_KEY`, keys.Key)
keys.LoadingStatus = "LOADING"
keys.RemoteReady = true
AddLog("Script", string.format("%s requested client keys", p.Name))
--else
--Anti.Detected(p, "kick","Communication Key Error (r10003)")
end
AddLog("RemoteFires", {
Text = `{p.Name} requested key from server`,
Desc = "Player requested key from server",
Player = p;
})
else
Anti.Detected(p, "kick", "Communication Key Error (r10003)")
end
elseif rateLimitCheck and string.len(com) <= Remote.MaxLen then
local comString = Decrypt(com, keys.Key, keys.Cache)
local command = cliData.Mode == "Get" and Remote.Returnables[comString] or Remote.Commands[comString]
AddLog("RemoteFires", {
Text = string.format("%s fired %s; Arg1: %s", p.Name, comString, service.MaxLen(tostring(args[1]), 50));
Desc = string.format("Player fired remote command %s; %s", comString, Functions.ArgsToString(args));
Player = p;
})
if command then
local rets = {TrackTask(`Remote: {p.Name}: {comString}`, command, false, p, args)}
if not rets[1] then
logError(p, `{comString}: {rets[2]}`)
else
return {table.unpack(rets, 2)}
end
else
Anti.Detected(p, "Kick", "Invalid Remote Data (r10004)")
end
elseif rateLimitCheck and RateLimit(p, "RateLog") then
Anti.Detected(p, "Log", string.format("Firing RemoteEvent too quickly (>Rate: %s/sec)", curRemoteRate))
warn(string.format("%s is firing Adonis's RemoteEvent too quickly (>Rate: %s/sec)", p.Name, curRemoteRate))
end
else
Anti.Detected(p, "Log", "Out of Sync (r10005)")
end
end
end
end
end;
GetOverrideMap = function(str)
local inputs, outputs = string.match(str, `{Settings.BatchKey}([%d,]+)>([%d,]+)`)
local tbl1, tbl2 = {}, {}
local i = 0
for num in string.gmatch(inputs or "", "(%d+),?") do
table.insert(tbl1, tonumber(num) or 1)
end
for num in string.gmatch(outputs or "", "(%d+),?") do
i += 1
if tbl1[i] then
tbl2[tbl1[i]] = tonumber(num) or 1
end
end
return tbl2
end;
Command = function(p, msg, opts, noYield)
opts = opts or {}
if #msg > Process.MsgStringLimit and type(p) == "userdata" and p:IsA("Player") and not Admin.CheckAdmin(p) then
msg = string.sub(msg, 1, Process.MsgStringLimit)
end
msg = Functions.Trim(msg)
if string.match(msg, Settings.BatchKey) then
local overrideArgs = {}
for cmd, overrideMap in string.gmatch(msg, `([^{Settings.BatchKey}]+)({Settings.BatchKey}?[%d,>]*)`) do
cmd, overrideMap = Functions.Trim(cmd), Process.GetOverrideMap(overrideMap)
local returnArgs = table.pack(Process.Command(p, cmd, opts, false))
table.clear(overrideArgs)
for i, i2 in overrideMap do
overrideArgs[i2] = returnArgs[i + 1]
end
opts.OverrideArgs = overrideArgs
end
else
msg = Admin.AliasFormat(Admin.GetAliases(p), msg) or msg
if string.match(msg, Settings.BatchKey) then
return Process.Command(p, msg, opts, false)
end
local index, command, matched = Admin.GetCommand(msg)
if not command then
if opts.Check then
Remote.MakeGui(p, "Output", {
Title = "Invalid command";
Message = if Settings.SilentCommandDenials
then string.format("'%s' is either not a valid command, or you do not have permission to run it.", msg)
else string.format("'%s' is not a valid command.", msg);
})
end
return
end
local allowed, denialMessage = false, nil
local isSystem = false
local pDat = {
Player = opts.Player or p;
Level = opts.AdminLevel or Admin.GetLevel(p);
isDonor = opts.IsDonor or (Admin.CheckDonor(p) and (Settings.DonorCommands or command.AllowDonors));
}
if opts.isSystem or p == "SYSTEM" then
isSystem = true
allowed = not command.Disabled
p = p or "SYSTEM"
else
allowed, denialMessage = Admin.CheckPermission(pDat, command, false, opts)
end
if not allowed then
if not (isSystem or opts.NoOutput) and (denialMessage or not Settings.SilentCommandDenials or opts.Check) then
Remote.MakeGui(p, "Output", {
Message = denialMessage or (if Settings.SilentCommandDenials
then string.format("'%s' is either not a valid command, or you do not have permission to run it.", msg)
else string.format("You do not have permission to run '%s'.", msg));
})
end
return
end
local cmdArgs = command.Args or command.Arguments
local argString = string.match(msg, `^.-{Settings.SplitKey}(.+)`) or ""
local args = (opts.Args or opts.Arguments) or (#cmdArgs > 0 and Functions.Split(argString, Settings.SplitKey, #cmdArgs)) or {}
local taskName = string.format("Command :: %s : (%s)", p.Name, msg)
if #args > 0 and not isSystem and command.Filter or opts.Filter then
for i, arg in args do
local cmdArg = cmdArgs[i]
if cmdArg then
if Admin.IsLax(cmdArg) == false then
args[i] = service.LaxFilter(arg, p)
end
else
args[i] = service.LaxFilter(arg, p)
end
end
end
if command.Dangerous and Settings.WarnDangerousCommand and not isSystem then
-- more checks
for i, argname in ipairs(cmdArgs) do
if string.find(argname, "player") ~= nil or string.find(argname, "plr") ~= nil then
local playersamount = #(service.GetPlayers(p, args[i], {UseFakePlayer = true}));
if playersamount > 1 then
if Remote.GetGui(p, "YesNoPrompt", {
Question = string.format("Are you sure you want to proceed? (%s selected %s possible players)", msg, playersamount);
Title = "Dangerous command"
}) == "No" then
Functions.Hint(string.format("Aborted command %s", msg), { p })
return
end
end
end
end
end
if opts.OverrideArgs then
for i, v in opts.OverrideArgs do
args[i] = v
end
end
if (opts.CrossServer or (not isSystem and not opts.DontLog)) and not command.NoLog then
local noSave = command.AdminLevel == "Player" or command.Donors or command.AdminLevel == 0
AddLog("Commands", {
Text = `{((opts.CrossServer and "[CRS_SERVER] ") or "")}{p.Name}`;
Desc = `{matched}{Settings.SplitKey}{table.concat(args, Settings.SplitKey)}`;
Player = p;
NoSave = noSave;
})
if Settings.ConfirmCommands then
Functions.Hint(`Executed Command: [ {msg} ]`, {p})
end
end
if noYield then
taskName = `Thread: {taskName}`
end
Admin.UpdateCooldown(pDat, command)
local returnArgs = table.pack(TrackTask(taskName, command.Function, function(cmdError)
if not opts.IgnoreErrors then
if type(cmdError) == "string" then
AddLog("Errors", `[{matched}] {cmdError}`)
cmdError = cmdError:match("%d: (.+)$") or cmdError
if not isSystem then
Remote.MakeGui(p, "Output", {
Message = cmdError,
})
if Core.DebugMode == true then
warn(`Encountered an error while running a command: {msg}\n{cmdError}\n{debug.traceback()}`)
end
end
elseif cmdError ~= nil and cmdError ~= true and not isSystem then
Remote.MakeGui(p, "Output", {
Message = `There was an error but the error was not a string? : {cmdError}`;
})
end
end
end, p, args, {
PlayerData = pDat,
Options = opts
}))
local ran, cmdError = returnArgs[1], returnArgs[2]
service.Events.CommandRan:Fire(p, {
Message = msg,
Matched = matched,
Args = args,
Command = command,
Index = index,
Success = ran,
Error = if not ran then cmdError else nil,
Options = opts,
PlayerData = pDat
})
return unpack(returnArgs)
end
end;
CrossServerChat = function(data)
if data then
for _, v in service.GetPlayers() do
if Admin.GetLevel(v) > 0 then
Remote.Send(v, "handler", "ChatHandler", data.Player, data.Message, "Cross")
end
end
end
end;
Chat = function(p, msg)
local didPassRate, didThrottle, canThrottle, curRate, maxRate = RateLimit(p, "Chat")
if didPassRate then
local isMuted = Admin.IsMuted(p);
if utf8.len(utf8.nfcnormalize(msg)) > Process.MaxChatCharacterLimit and not Admin.CheckAdmin(p) then
Anti.Detected(p, "Kick", "Chatted message over the maximum character limit")
elseif not isMuted then
if not Admin.CheckSlowMode(p) then
msg = service.TextChatService.ChatVersion == Enum.ChatVersion.TextChatService and service.UnsanitizeXML(msg) or msg -- Hack to fix TextChatService invalidly XML escaping messages
local msg = string.sub(msg, 1, Process.MsgStringLimit)
local filtered = service.LaxFilter(msg, p)
AddLog(Logs.Chats, {
Text = `{p.Name}: {filtered}`;
Desc = tostring(filtered);
Player = p;
})
if Settings.ChatCommands then
if Admin.DoHideChatCmd(p, msg) then
Remote.Send(p,"Function","ChatMessage",`> {msg}`,Color3.new(1, 1, 1))
Process.Command(p, msg, {Chat = true;})
elseif string.sub(msg, 1, 3) == "/e " then
service.Events.PlayerChatted:Fire(p, msg)
msg = string.sub(msg, 4)
Process.Command(p, msg, {Chat = true;})
elseif string.sub(msg, 1, 8) == "/system " then
service.Events.PlayerChatted:Fire(p, msg)
msg = string.sub(msg, 9)
Process.Command(p, msg, {Chat = true;})
else
service.Events.PlayerChatted:Fire(p, msg)
Process.Command(p, msg, {Chat = true;})
end
else
service.Events.PlayerChatted:Fire(p, msg)
end
else
local msg = string.sub(msg, 1, Process.MsgStringLimit)
if Settings.ChatCommands then
if Admin.DoHideChatCmd(p, msg) then
Remote.Send(p,"Function","ChatMessage",`> {msg}`,Color3.new(1, 1, 1))
Process.Command(p, msg, {Chat = true;})
else
Process.Command(p, msg, {Chat = true;})
end
end
end
elseif isMuted then
local msg = string.sub(msg, 1, Process.MsgStringLimit);
service.Events.MutedPlayerChat_UnFiltered:Fire(p, msg)
local filtered = service.LaxFilter(msg, p)
AddLog(Logs.Chats, {
Text = `[MUTED] {p.Name}: {filtered}`;
Desc = tostring(filtered);
Player = p;
})
service.Events.MutedPlayerChat_Filtered:Fire(p, filtered)
end
elseif not didPassRate and RateLimit(p, "RateLog") then
Anti.Detected(p, "Log", string.format("Chatting too quickly (>Rate: %s/sec)", curRate))
warn(string.format("%s is chatting too quickly (>Rate: %s/sec)", p.Name, curRate))
end
end;
--[==[
LogService = function(Message, Type)
--service.Events.Output:Fire(Message, Type)
end;
ErrorMessage = function(Message, Trace, Script)
--[[if Running then
service.Events.ErrorMessage:Fire(Message, Trace, Script)
if Message:lower():find("adonis") or Message:find(script.Name) then
logError(Message)
end
end--]]
end;
]==]
PlayerAdded = function(p)
AddLog("Script", `Doing PlayerAdded Event for {p.Name}`)
local key = tostring(p.UserId)
local keyData = {
Player = p;
Key = service.HttpService:GenerateGUID(false);
Cache = {};
Sent = 0;
Received = 0;
LastUpdate = os.time();
FinishedLoading = false;
LoadingStatus = "WAITING_FOR_KEY";
--Special = Core.MockClientKeys and Core.MockClientKeys.Special;
--Module = Core.MockClientKeys and Core.MockClientKeys.Module;
}
Core.UpdatePlayerConnection(p)
Core.PlayerData[key] = nil
Remote.Clients[key] = keyData
local ran, err = Pcall(function()
task.spawn(function()
if Anti.UserSpoofCheck(p) then
Remote.Clients[key] = nil;
Anti.Detected(p, "kick", "Username Spoofing");
end
end)
local PlayerData = Core.GetPlayer(p)
local level = Admin.GetLevel(p)
local banned, reason = Admin.CheckBan(p)
if banned then
Remote.Clients[key] = nil;
p:Kick(string.format("%s | Reason: %s", Variables.BanMessage, (reason or "No reason provided")))
return "REMOVED"
end
if Variables.ServerLock and level < 1 then
Remote.Clients[key] = nil;
p:Kick(Variables.LockMessage or "::Adonis:: Server Locked")
return "REMOVED"
end
if Variables.Whitelist.Enabled then
local listed = false
local CheckTable = Admin.CheckTable
for listName, list in Variables.Whitelist.Lists do
if CheckTable(p, list) then
listed = true
break;
end
end
if not listed and level == 0 then
Remote.Clients[key] = nil;
p:Kick(Variables.LockMessage or "::Adonis:: Whitelist Enabled")
return "REMOVED"
end
end
do
local Removed = false
local success, err = pcall(function()
for filter,func in pairs(server.Variables.PlayerJoinFilters) do
local success, res, message = pcall(func, p, PlayerData)
if success and res == false then
p:Kick(`::Adonis:: {message or Settings.CustomJoinFilterKickMessage or "You are not allowed to join this experience"}`)
Logs.AddLog(server.Logs.Script, `{tostring(p)} failed the join filter {filter}`)
Removed = true
break
elseif not success then
Logs.AddLog(server.Logs.Errors, `{filter} failed for {res}`)
end
end
end)
if Removed then
return "REMOVED"
end
end
end)
if not ran then
AddLog("Errors", `{p.Name} PlayerAdded Failed: {err}`)
warn("~! :: Adonis :: SOMETHING FAILED DURING PLAYERADDED:")
warn(tostring(err))
end
if Remote.Clients[key] then
Core.HookClient(p)
AddLog("Script", {
Text = `{p.Name} loading started`;
Desc = `{p.Name} successfully joined the server`;
})
AddLog("Joins", {
Text = service.FormatPlayer(p);
Desc = `{p.Name} joined the server`;
Player = p;
})
--// Get chats
p.Chatted:Connect(function(msg)
local ran, err = TrackTask(`{p.Name}Chatted`, Process.Chat, false, p, msg)
if not ran then
logError(err);
end
end)
--// Character added
p.CharacterAdded:Connect(function(...)
local ran, err = TrackTask(`{p.Name}CharacterAdded`, Process.CharacterAdded, false, p, ...)
if not ran then
logError(err);
end
end)
task.delay(600, function()
if p.Parent and Core.PlayerData[key] and Remote.Clients[key] and Remote.Clients[key] == keyData and keyData.LoadingStatus ~= "READY" then
AddLog("Script", {
Text = `{p.Name} Failed to Load`,
Desc = `{keyData.LoadingStatus}: Client failed to load in time (10 minutes?)`,
Player = p;
});
--Anti.Detected(p, "kick", "Client failed to load in time (10 minutes?)");
end
end)
elseif ran and err ~= "REMOVED" then
Anti.RemovePlayer(p, ":: Adonis :: Loading Error [Missing player, keys, or removed]")
end
end;
PlayerRemoving = function(p, r)
local data = Core.GetPlayer(p)
local key = tostring(p.UserId)
service.Events.PlayerRemoving:Fire(p)
task.delay(1, function()
if not service.Players:GetPlayerByUserId(p.UserId) then
Core.PlayerData[key] = nil
end
end)
AddLog("Script", {
Text = string.format("Triggered PlayerRemoving for %s", p.Name);
Desc = "Player left the game (PlayerRemoving)";
Player = p;
})
local reasons = {
["Unknown"] = "Unknown Reason",
["PlatformKick"] = "Kicked by Roblox",
["CreatorKick"] = "Kicked by Creator"
}
local reason = reasons[r.Name] or r.Name
AddLog("Leaves", {
Text = service.FormatPlayer(p);
Desc = `{p.Name} left the server ({reason})`;
Player = p;
})
for _,rateLimit in RateLimiter do
if not rateLimit.Caches then
continue
end
rateLimit.Caches[p.UserId] = nil
end
Core.SavePlayerData(p, data)
if Settings.ReJail then
for i,v in pairs(Variables.Jails) do
if v.Mod == p then
if service.Players:FindFirstChild(v.Name) then
Pcall(function()
for _, tool in v.Tools do
tool.Parent = v.Player.Backpack
end
end)
Pcall(function() v.Jail:Destroy() end)
Variables.Jails[i] = nil
else
local ind = v.Index
service.StopLoop(`{ind}JAIL`)
Pcall(function() v.Jail:Destroy() end)
Variables.Jails[ind] = nil
end
end
end
end
Variables.TrackingTable[p.Name] = nil
if Variables.ReturnPoints[p] then
Variables.ReturnPoints[p] = nil
end
for otherPlrName, trackTargets in Variables.TrackingTable do
if trackTargets[p] then
trackTargets[p] = nil
local otherPlr = service.Players:FindFirstChild(otherPlrName)
if otherPlr then
task.defer(Remote.RemoveLocal, otherPlr, `{p.Name}_Tracker`)
end
end
end
if Commands.UnDisguise then
Commands.UnDisguise.Function(p, {"me"})
end
Variables.IncognitoPlayers[p] = nil
end;
FinishLoading = function(p)
local PlayerData = Core.GetPlayer(p)
local level, rank = Admin.GetLevel(p)
local key = tostring(p.UserId)
--// Fire player added
service.Events.PlayerAdded:Fire(p)
AddLog("Script", {
Text = string.format("%s finished loading", p.Name);
Desc = "Client finished loading";
})
--// Run OnJoin commands
for i,v in Settings.OnJoin do
TrackTask(`Thread: OnJoin_Cmd: {v}`, Admin.RunCommandAsPlayer, false, v, p)
AddLog("Script", {
Text = `OnJoin: Executed {v}`;
Desc = `Executed OnJoin command; {v}`
})
end
--// Start keybind listener
Remote.Send(p, "Function", "KeyBindListener", PlayerData.Keybinds or {})
-- // Send server variables to client
Remote.Send(p, "SetVariables", {
TopBarShift = Settings.TopBarShift,
NightlyMode = server.Data.NightlyMode or server.Data.ModuleID == 8612978896,
G_Access_Key = Remote._globalAccessHash
})
--// Load some playerdata stuff
if type(PlayerData.Client) == "table" then
if PlayerData.Client.CapesEnabled == true or PlayerData.Client.CapesEnabled == nil then
Remote.Send(p, "Function", "MoveCapes")
end
Remote.Send(p, "SetVariables", PlayerData.Client)
else
Remote.Send(p, "Function", "MoveCapes")
end
--// Load all particle effects that currently exist
Functions.LoadEffects(p)
--// Load admin or non-admin specific things
if level < 1 then
if Settings.AntiSpeed and Settings.AllowClientAntiExploit then
Remote.Send(p, "LaunchAnti", "Speed", {
Speed = tostring(60.5 + math.random(9e8)/9e8)
})
end
if Settings.Detection and Settings.AllowClientAntiExploit then
Remote.Send(p, "LaunchAnti", "MainDetection")
Remote.Send(p, "LaunchAnti", "AntiAntiIdle", {
Enabled = (Settings.AntiAntiIdle ~= false or Settings.AntiClientIdle ~= false)
})
--if Settings.ExploitGuiDetection and Settings.AllowClientAntiExploit then
-- Remote.Send(p, "LaunchAnti", "AntiCoreGui")
--end
end
if Settings.AntiBuildingTools and Settings.AllowClientAntiExploit then
Remote.Send(p, "LaunchAnti", "AntiTools", {BTools = true})
end
end
if Settings.AntiLeak and Settings.AllowClientAntiExploit then
Remote.Send(p, "LaunchAnti", "AntiLeak", {
Enabled = (Settings.AntiLeak ~= false)
})
end
--// Finish things up
if Remote.Clients[key] then
Remote.Clients[key].FinishedLoading = true
if p.Character and p.Character.Parent == workspace then
local ran, err = TrackTask(`{p.Name} CharacterAdded`, Process.CharacterAdded, false, p, p.Character, {FinishedLoading = true})