-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathChris's Public Lua - !start !stop and More.lua
6297 lines (5749 loc) · 149 KB
/
Chris's Public Lua - !start !stop and More.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
slot0 = require("ffi")
slot1 = require("gamesense/csgo_weapons")
slot2 = require("gamesense/http")
slot4 = require("gamesense/panorama_events")
slot5 = require("gamesense/clipboard")
slot6 = panorama.open()
slot7 = slot6["$"]
slot8 = slot6.CompetitiveMatchAPI
slot9 = slot6.GameStateAPI
slot10 = slot6.FriendsListAPI
slot11 = slot6.GameTypesAPI
slot12 = slot6.PartyListAPI
slot13 = slot6.MyPersonaAPI
slot14 = slot6.LobbyAPI
slot15 = slot6.SteamOverlayAPI
slot16 = slot6.TeammatesAPI
slot17 = require("gamesense/steamworks").ISteamFriends
slot18 = {
items = {},
new = function (slot0, slot1)
slot2 = {
name = slot0,
state = slot1,
state = false
}
if uv0[slot0] then
-- Nothing
end
uv1.items[slot0] = slot2
return slot2
end,
get = function (slot0)
return uv0.items[slot0].state
end
}
slot19 = database.read("cplua_overrides") or {}
slot18.new("Panorama Libraries", true)
slot18.new("LiveCheck Library", true)
slot18.new("Delayed Auto Accept", true)
slot18.new("Delayed Connect", true)
slot18.new("Auto Accept Detection", true)
slot18.new("Auto Derank Score", true)
slot18.new("Auto Open CsgoStats.gg", false)
slot18.new("Auto Invite Recents", true)
slot18.new("Match Start Beep", true)
slot18.new("Custom Clantag Builder", true)
slot18.new("Custom Killsay Builder", true)
slot18.new("Report Enemy Tool", true)
slot18.new("Account Checkers", true)
slot18.new("Crack Checker", false)
slot18.new("Faceit Checker", true)
slot18.new("Game Value", true)
slot18.new("Inventory Value", true)
slot18.new("Banned Friends", true)
slot18.new("Name History", true)
slot18.new("CSGOStats.gg", true)
slot18.new("Whitelist Friends on Key", true)
slot18.new("Playerlist Additions", true)
slot18.new("Highlight Targets", true)
slot18.new("Dev Report Bot", true)
slot18.new("Party Chat Utils", true)
slot18.new("Chat Commands", true)
slot18.new("Raw Chat Print", true)
slot18.new("User Data Saving", true)
slot20 = nil
slot21 = {}
slot22 = {
debugMode = false
}
if slot18.get("Panorama Libraries") then
CPPanoramaMainMenu = panorama.loadstring([[
$.Schedule(5, $.Msg, 'test')
// Lobby Chat Utils
let Prefix = '!';
let MsgSteamID = false;
let MySteamID = MyPersonaAPI.GetXuid();
let UserData = {};
let MuteUsers = [];
const Utilities = {};
Utilities.IsBlacklisted = (SteamXUID) => {
UserData.blacklist = UserData.blacklist || [0];
return UserData.blacklist.includes(SteamXUID)
}
Utilities.SayParty = (Message) => {
let FilteredMessage = Message.split(' ').join('\u{00A0}');
PartyListAPI.SessionCommand('Game::Chat', `run all xuid ${MySteamID} chat ${FilteredMessage}`);
}
let Keys = [
'5DA40A4A4699DEE30C1C9A7BCE84C914',
'5970533AA2A0651E9105E706D0F8EDDC',
'2B3382EBA9E8C1B58054BD5C5EE1C36A'
];
let KeyIndex = 0
Utilities.RandomWebKey = () => {
if ( KeyIndex >= Keys.length ) KeyIndex = 0;
return Keys[KeyIndex++]
}
/*
function resolveVanityURL(vanityurl, callback)
http.get('https://api.steampowered.com/ISteamUser/ResolveVanityURL/v1?key=' .. Utilities.RandomWebKeyhttp .. '&vanityurl=' .. vanityurl, function(success, response)
if not success or response.status ~= 200 then return callback(false) end
local data = json.parse(response.body)
if data then
if not data.response.success == 1 or not data.response.steamid then return callback(false) end
return callback(data.response.steamid)
end
return callback(false)
end)
end
*/
Utilities.resolveVanityURL = (vanityurl, callback) => {
$.AsyncWebRequest('https://api.steampowered.com/ISteamUser/ResolveVanityURL/v1?key=' + Utilities.RandomWebKey() + '&vanityurl=' + vanityurl, {
type:"GET",
complete:function(e){
if ( e.status != 200 ) return;
let Response = e.responseText.substring(0, e.responseText.length-1);
let Data = JSON.parse(Response);
if ( Data.response.success ) {
callback(Data.response.steamid)
}
}
});
}
Utilities.FindPlayer = (str, NoOutput, callback) => {
let FoundXUID = false;
// Type Checks
let regex_steamid64 = /(765\d{14})/i;
let regex_steamid3 = / /i; // idk yet bud, maths is dumb
let regex_friendcode = /(\w{5}-\w{4})/i;
let regex_lobbyindex = /\d{1}$/i
let regex_url = /steamcommunity.com\/id\/(.+)$/i;
if ( regex_steamid64.test(str) ) {
FoundXUID = str.match(regex_steamid64)[0];
} else if ( regex_steamid3.test(str) ) {
} else if ( regex_friendcode.test(str) ) {
FoundXUID = FriendsListAPI.GetXuidFromFriendCode(str.match(regex_friendcode)[0]);
} else if ( regex_lobbyindex.test(str) ) {
let LobbyIndex = str.match(regex_lobbyindex)[0]
FoundXUID = PartyListAPI.GetXuidByIndex(LobbyIndex - 1);
} else if ( regex_url.test(str) && callback ) {
let vanityURL = str.match(regex_url)[1].replace(/\/$/, "")
Utilities.resolveVanityURL(vanityURL, (steamid)=>{
callback(steamid)
});
} else if ( typeof str == 'string' ) {
let TempID;
let TempCount = 0;
for ( i=0; i<PartyListAPI.GetCount(); i++ ) {
let MemberSteamID = PartyListAPI.GetXuidByIndex(i);
let MemberName = PartyListAPI.GetFriendName(MemberSteamID);
if ( MemberName.toLowerCase().indexOf(str.toLowerCase()) == 0 ) {
TempID = MemberSteamID;
TempCount++;
}
}
if ( TempCount == 1 ) {
FoundXUID = TempID;
} else if ( !NoOutput ) {
Utilities.SayParty(`Found ${TempCount} matches for "${str}", try being more specific!`)
}
}
if ( FoundXUID ) {
if ( callback ) callback(FoundXUID);
return FoundXUID
}
}
Utilities.MessageHistory = [];
function AttachHistory() {
let elInput = $.GetContextPanel().FindChildTraverse('ChatInput');
let ChatPanelContainer = $.GetContextPanel().FindChildTraverse('ChatPanelContainer');
if ( ChatPanelContainer && elInput ) {
let Root = ChatPanelContainer.GetParent();
elInput.ClearPanelEvent('oninputsubmit');
elInput.SetPanelEvent( 'onfocus', ()=>{
});
Utilities.ClearMessageIndex = ()=>{
Utilities.MessageIndex = Utilities.MessageHistory.length;
}
elInput.SetPanelEvent( 'oninputsubmit', ()=>{
let Msg = elInput.text;
if ( Msg != '' ) {
Utilities.MessageHistory.push(Msg);
Utilities.ClearMessageIndex();
}
elInput.text = Msg.replace(/@[0-9\w-]+/ig, (match, capture)=>{
let FoundXUID = Utilities.FindPlayer(match.substring(1), true)
if ( FoundXUID ) {
return PartyListAPI.GetFriendName(FoundXUID)
}
return match
});
Root.SubmitChatText()
elInput.text = "";
});
}
}
AttachHistory()
$.RegisterForUnhandledEvent("PanoramaComponent_Lobby_MatchmakingSessionUpdate", function(state){
if(state == 'updated' && PartyListAPI.IsPartySessionActive()){
AttachHistory();
}
});
let PartyChatCommands = [];
PartyChatCommands.push({
title: 'Help (!\u{200B}help)',
cmds: ['help', 'h'],
timeout: 2500,
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
if ( args.length == 0 ) {
for ( i=1; i<PartyChatCommands.length; i++ ) {
let ChatCommand = PartyChatCommands[i];
if (ChatCommand.cmds[0] == 'sus')
continue;
const Title = `» ${ChatCommand.title}`;
const Alias = ChatCommand.cmds;
Utilities.SayParty(Title);
}
} else {
for ( i=1; i<PartyChatCommands.length; i++ ) {
let ChatCommand = PartyChatCommands[i];
if (ChatCommand.cmds[0] == 'sus')
continue;
const Alias = ChatCommand.cmds;
const FoundAlias = Alias.find(item => item == args[0]);
if ( FoundAlias ) {
const AliasString = Alias.join(', ');
const Title = `» List of Alias's: ${AliasString}`;
Utilities.SayParty(Title);
break;
}
}
}
}
});
PartyChatCommands.push({
title: 'Test (!\u{200B}test)',
cmds: ['test'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
Utilities.SayParty(`Test successful, sender info: ${sender} | ${steamid}`)
}
});
PartyChatCommands.push({
title: 'Sus (!\u{200B}Displays a sus Lua Coder)',
cmds: ['sus'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
// todo: sus stuff below
Utilities.SayParty(`${sender} did you know csmit is a sussy baka? >w<`)
}
});
PartyChatCommands.push({
title: 'Start Queue (!\u{200B}startq)',
cmds: ['start', 'startq', 'startqueue', 'queue', 'q'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
if ( !LobbyAPI.BIsHost() ) return;
LobbyAPI.StartMatchmaking( MyPersonaAPI.GetMyOfficialTournamentName(),
MyPersonaAPI.GetMyOfficialTeamName(),
'',
''
);
}
});
PartyChatCommands.push({
title: 'Stop Queue (!\u{200B}stopq)',
cmds: ['stop', 'stopq', 'stopqueue', 'sq', 's'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
LobbyAPI.StopMatchmaking()
}
});
PartyChatCommands.push({
title: 'Restart Queue (!\u{200B}restartq)',
cmds: ['restart', 'restartq', 'restartqueue', 'rs'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
if ( !LobbyAPI.BIsHost() ) return;
LobbyAPI.StopMatchmaking()
$.Schedule(1, ()=>{
/*let settings = LobbyAPI.IsSessionActive() ? LobbyAPI.GetSessionSettings() : null;
let stage = '';
if ( settings && settings.game && settings.options
&& settings.options.server !== 'listen'
&& settings.game.mode === 'competitive'
&& settings.game.mapgroupname.includes( 'mg_lobby_mapveto' ) ) {
stage = '';
}*/
LobbyAPI.StartMatchmaking( MyPersonaAPI.GetMyOfficialTournamentName(),
MyPersonaAPI.GetMyOfficialTeamName(),
'',
''
);
});
}
});
PartyChatCommands.push({
title: 'Posts a random chuck norris fact (!\u{200B}chucknorris)',
cmds: ['cfact', 'fact', 'chucknorris'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
$.AsyncWebRequest('https://api.chucknorris.io/jokes/random', {
type:"GET",
complete:function(e){
if ( e.status != 200 ) return;
let Response = e.responseText.substring(0, e.responseText.length-1);
let Data = JSON.parse(Response);
if ( Data ) {
Utilities.SayParty(Data.value)
}
}
});
}
});
PartyChatCommands.push({
title: 'Reset Lobby (!\u{200B}resetlobby)',
cmds: ['resetlobby', 'relobby', 'rl'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
let Settings = LobbyAPI.GetSessionSettings();
let GameMode = Settings.game.mode;
let GameType = Settings.game.type;
let MapGroupName = Settings.game.mapgroupname;
let MySteamID = MyPersonaAPI.GetXuid();
if ( steamid != MySteamID ) return;
// Get Lobby Players
let SteamIDs = [];
for ( i=0; i<Settings.members.numMachines; i++ ) {
let Player = Settings.members[`machine${i}`];
let PlayerSteamID = Player.id;
if ( MySteamID != PlayerSteamID ) {
SteamIDs.push(PlayerSteamID)
}
}
LobbyAPI.CloseSession();
for ( i=0; i<SteamIDs.length; i++ ) {
FriendsListAPI.ActionInviteFriend(SteamIDs[i], '');
}
}
});
PartyChatCommands.push({
title: 'Maps (!\u{200B}maps dust2, safehouse)',
cmds: ['maps', 'map', 'setmaps', 'changemap', 'changemaps'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
if ( !UserData.mods.indexOf(steamid) ) return;
if ( !LobbyAPI.BIsHost() ) return;
let Config = GameTypesAPI.GetConfig();
let SessionSettings = LobbyAPI.GetSessionSettings();
let GameMode = SessionSettings.game.mode;
let GameType = SessionSettings.game.type;
let MapsInGroup = Config.gameTypes[GameType].gameModes[GameMode].mapgroupsMP;
let MapList = [];
if ( args[0] == 'all' ) {
delete MapsInGroup['mg_lobby_mapveto'];
MapList = Object.keys(MapsInGroup)
} else {
let Maps = args.join(',').split(',');
let FilteredMaps = [];
Maps.forEach((map, index)=>{
if ( map.trim() != '' ) {
FilteredMaps.push(map)
}
});
let FoundMaps = {};
FilteredMaps.forEach((SearchMap, key)=>{
for (Map in MapsInGroup) {
let MapName = GameTypesAPI.GetFriendlyMapName(Map.substr(3));
if ( Map.indexOf('scrimmage') == -1 && ( MapName.toLowerCase().indexOf(SearchMap.trim().toLowerCase()) != -1 || Map.toLowerCase().search(SearchMap.toLowerCase()) != -1 ) ) {
FoundMaps[Map] = true;
}
}
});
for ( Map in FoundMaps ) {
MapList.push(Map);
}
}
if ( MapList.length > 0 ) {
PartyListAPI.UpdateSessionSettings(`Update/Game/mapgroupname ${MapList}`);
}
}
});
PartyChatCommands.push({
title: 'Gamemode (!\u{200B}mode wm)',
cmds: ['mode', 'gm', 'gamemode', 'mm', 'wm'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
if ( !LobbyAPI.BIsHost() ) return;
let SessionSettings = LobbyAPI.GetSessionSettings();
let GameMode = SessionSettings.game.mode;
let GameType = SessionSettings.game.type;
let settings = { update : { Game: { } } }
// I would use a switch case, but I want to do regex
if ( cmd == 'mm' || ( args.length > 0 && /(comp.*|5(x|v)5|mm)/i.test(args[0]) ) ) {
settings.update.Game.mode = 'competitive'
settings.update.Game.type = 'classic'
} else if ( cmd == 'wm' || ( args.length > 0 && /(wing.*|2(x|v)2|wm)/i.test(args[0]) ) ) {
settings.update.Game.mode = 'scrimcomp2v2'
settings.update.Game.type = 'classic'
}
LobbyAPI.UpdateSessionSettings( settings );
}
});
PartyChatCommands.push({
title: 'clearchat (!\u{200B}clearchat)',
cmds: ['clearchat', 'clear', 'cc', 'cl', 'deletechat', 'delchat', 'deletechat'],
exec: (cmd, args, sender, steamid) => {
if ( steamid != MyPersonaAPI.GetXuid() ) return;
let party_chat = $.GetContextPanel().FindChildTraverse("PartyChat")
if(party_chat) {
let chat_lines = party_chat.FindChildTraverse("ChatLinesContainer")
if(chat_lines) {
//chat_lines.RemoveAndDeleteChildren();
}
}
}
});
PartyChatCommands.push({
title: 'Kick (!\u{200B}kick <partial:name>|<steamid>|<friendcode>)',
cmds: ['kick'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
if ( !LobbyAPI.BIsHost() ) return;
if ( steamid != LobbyAPI.GetHostSteamID() && !UserData.mods.indexOf(steamid) ) return;
UserData.mods = UserData.mods || [0];
if ( typeof args[0] != 'undefined' ) {
let KickXUID = Utilities.FindPlayer(args[0]);
if ( KickXUID && LobbyAPI.GetHostSteamID() != KickXUID && LobbyAPI.IsPartyMember(KickXUID) ) {
LobbyAPI.KickPlayer(KickXUID);
let Name = FriendsListAPI.GetFriendName(KickXUID);
Utilities.SayParty(`Kicked ${Name} (${KickXUID}) from the lobby!`);
} else if ( LobbyAPI.GetHostSteamID() == KickXUID ) {
Utilities.SayParty(`You are unable to kick the host!`);
}
}
}
});
RandNumber = 3
PartyChatCommands.push({
title: 'Roll a number between 1 and 6 (!\u{200B}roll)',
cmds: ['roll'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
let currentNumber = Math.floor(Math.random() * (6-1)) + 1;
if (currentNumber == 1 && currentNumber == RandNumber) {
Utilities.SayParty(`${sender} rolled a ${currentNumber} ... snake eyes!`)
} else {
Utilities.SayParty(`${sender} rolled a ${currentNumber}`)
}
RandNumber = currentNumber;
}
});
PartyChatCommands.push({
title: 'Am i gay?! (!\u{200B}gay)',
cmds: ['gay'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
let currentNumber = Math.floor(Math.random() * (2-0)) + 1;
if (currentNumber == 2) {
Utilities.SayParty(`${sender} is gay`)
} else {
Utilities.SayParty(`${sender} is not gay`)
}
RandNumber = currentNumber;
}
});
PartyChatCommands.push({
title: 'Invades Issue??',
cmds: ['invades'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
Utilities.SayParty(`issue`)
}
});
PartyChatCommands.push({
title: 'check how much the person loves you! (!\u{200B}lovecalc <partial:name>|<steamid>|<friendcode>)',
cmds: ['lovecalc', 'lc', 'love'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
UserData.mods = UserData.mods || [0];
if ( typeof args[0] != 'undefined' ) {
let LoveXUID = Utilities.FindPlayer(args[0]);
if ( LoveXUID && LobbyAPI.GetHostSteamID() ) {
let Name = FriendsListAPI.GetFriendName(LoveXUID);
let currentNumber = ((Number(LoveXUID.substr(3)) + Number(steamid.substr(3)) + 8) % 100) + 1;
if (currentNumber == 69 && RandNumber)
Utilities.SayParty(`${Name} loves ${sender} to ${currentNumber}% Nice, haha funny number!`);
else
Utilities.SayParty(`${Name} loves ${sender} to ${currentNumber}%`);
RandNumber = currentNumber;
}
}
}
});
PartyChatCommands.push({
title: 'check your pp size or someone elses! (!\u{200B}ppsize <partial:name>|<steamid>|<friendcode>)',
cmds: ['ppsize', 'pp'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
UserData.mods = UserData.mods || [0];
if ( typeof args[0] != 'undefined' ) {
let funnypp = Utilities.FindPlayer(args[0]);
if ( funnypp && LobbyAPI.GetHostSteamID() ) {
let Name = FriendsListAPI.GetFriendName(funnypp);
let currentNumber = Math.floor(Math.random() * (30-1)) +1;
if (currentNumber == 1 && RandNumber)
Utilities.SayParty(`${Name}'s pp is ${currentNumber}cm >w< so cute`);
else
Utilities.SayParty(`${Name}'s pp is ${currentNumber}cm long`);
RandNumber = currentNumber;
}
}
}
});
PartyChatCommands.push({
title: 'Check (!\u{200B}Check <steamid>|<friendcode>)',
cmds: ['check'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
if ( typeof args[0] != 'undefined' ) {
Utilities.FindPlayer(args[0], false, (steamid)=>{
let Name = FriendsListAPI.GetFriendName(steamid);
Utilities.SayParty('[LiveCheck] Please wait 5 seconds. Checking...');
LiveCheck.start(steamid, (data)=>{
let msg = '[LiveCheck] ';
if ( data ) {
msg += `${Name} is in-${data.state} `
if ( data.state == 'lobby' ) {
msg += 'queuing '
let Maps = data.mapgroupname.split(',');
let CleanMaps = [];
for ( i=0; i<Maps.length; i++ ) {
let TextClean = Maps[i].substr(3, Maps[i].length);
CleanMaps[i] = GameTypesAPI.GetFriendlyMapName(TextClean);
}
msg += CleanMaps.join(', ');
} else if ( data.state == 'game' ) {
msg += `playing ${data.map} - ${data.status}`
}
} else {
msg += ` Found no rich presence for ${steamid}`;
}
Utilities.SayParty(msg);
})
});
}
}
});
// CountryNames thanks to sapphryus
let CountryNames = {KW:"Kuwait",MA:"Morocco ",AF:"Afghanistan",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:"China",CX:"Christmas Island",CC:"Cocos (Keeling) Islands",CO:"Colombia",KM:"Comoros",CG:"Congo",CD:"Congo, the Democratic Republic of the",CK:"Cook Islands",CR:"Costa Rica",CI:"Cote D'Ivoire",HR:"Croatia",CU:"Cuba",CY:"Cyprus",CZ:"Czech Republic",DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:"Gambia",GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and Mcdonald Islands",VA:"Holy See (Vatican City State)",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran, Islamic Republic of",IQ:"Iraq",IE:"Ireland",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",KP:"North Korea",KR:"South Korea",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia, Federated States of",MD:"Moldova, Republic of",MC:"Monaco",MN:"Mongolia",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:"Netherlands",NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MK:"North Macedonia, Republic of",MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:"Palestinian Territory, Occupied",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:"Pitcairn",PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",RE:"Reunion",RO:"Romania",RU:"Russia",RW:"Rwanda",SH:"Saint Helena",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Eswatini",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:"Taiwan",TJ:"Tajikistan",TZ:"Tanzania, United Republic of",TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"USA",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela",VN:"Vietnam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe",AX:"Åland Islands",BQ:"Bonaire, Sint Eustatius and Saba",CW:"Curaçao",GG:"Guernsey",IM:"Isle of Man",JE:"Jersey",ME:"Montenegro",BL:"Saint Barthélemy",MF:"Saint Martin (French part)",RS:"Serbia",SX:"Sint Maarten (Dutch part)",SS:"South Sudan",XK:"Kosovo"}
PartyChatCommands.push({
title: 'Locate (!\u{200B}locate <partial:name>|<steamid>|<friendcode>)',
cmds: ['locate', 'locs', 'loc', 'locations', 'location'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
let XUID = 0;
if ( typeof args[0] != 'undefined' ) {
XUID = Utilities.FindPlayer(args[0])
}
let Settings = LobbyAPI.GetSessionSettings();
for ( i=0; i<Settings.members.numMachines; i++ ) {
let Player = Settings.members[`machine${i}`];
let PlayerSteamID = Player.id;
let PlayerName = Player.player0.name;
let Location = Player.player0.game.loc;
let LocationFull = CountryNames[Location];
if ( typeof args[0] == 'undefined' || PlayerSteamID == XUID ) {
Utilities.SayParty(`[LOCATION] ${PlayerName} is from ${LocationFull}!`);
}
}
}
});
PartyChatCommands.push({
title: 'Mods (!\u{200B}mod add <partial:name>|<steamid>|<friendcode>|<lobbyindex>)',
helpTitle: 'Type "!mod add <PartialName>", "!mod add <SteamID64>", "!mod add <FriendCode>", "!mod add <LobbyIndex>"',
helpExamples: 'Typing "!mod add 2" will mod the second person in the lobby, others are pretty easy like "!mod add csmit"!',
cmds: ['mod'],
exec: (cmd, args, sender, steamid) => {
if ( steamid == MyPersonaAPI.GetXuid() ) {
UserData.mods = UserData.mods || [0];
switch(args[0]) {
case 'add':
if ( typeof args[1] != 'undefined' ) {
let ModXUID = Utilities.FindPlayer(args[1]);
if ( ModXUID ) {
if ( UserData.mods.indexOf(ModXUID) == -1 ) {
UserData.mods.push(ModXUID);
let FriendName = FriendsListAPI.GetFriendName(ModXUID);
Utilities.SayParty(`Added ${FriendName}(${ModXUID}) as a moderator!`);
} else {
let FriendName = FriendsListAPI.GetFriendName(ModXUID);
Utilities.SayParty(`Cannot add ${FriendName}(${ModXUID}) as they are already a moderator!`)
}
} else {
Utilities.SayParty(`Sorry! I don't know how to decipher: ${args[1]}`)
}
}
break;
case 'list':
UserData.mods.forEach((steamid, index)=>{
if ( steamid ) {
let FriendName = FriendsListAPI.GetFriendName(steamid);
Utilities.SayParty(`[${index}] ${FriendName} - ${steamid}`);
}
})
break;
case 'remove':
if ( typeof args[1] != 'undefined' ) {
if ( typeof UserData.mods[ parseInt(args[1]) ] == 'undefined' ) {
let ModXUID = Utilities.FindPlayer(args[1]);
let FoundIndex = UserData.mods.indexOf(ModXUID);
if ( ModXUID && FoundIndex != -1 ) {
let FriendSteam = UserData.mods[FoundIndex];
let FriendName = FriendsListAPI.GetFriendName(FriendSteam);
Utilities.SayParty(`Removed ${FriendName} (${FriendSteam}) as a moderator!`);
delete UserData.mods[ FoundIndex ];
}
} else {
let FriendSteam = UserData.mods[ parseInt(args[1]) ];
let FriendName = FriendsListAPI.GetFriendName(FriendSteam);
Utilities.SayParty(`Removed ${FriendName} (${FriendSteam}) as a moderator!`);
delete UserData.mods[ parseInt(args[1]) ];
}
}
break;
case 'clear':
let TotalMods = UserData.mods.length || 0
Utilities.SayParty(`Cleared ${TotalMods} records (incl removed and existing mods)!`);
UserData.mods = [null];
break;
default:
if ( typeof args[0] != 'undefined' ) {
let ModXUID = Utilities.FindPlayer(args[0]);
if ( ModXUID && ModXUID != MySteamID ) {
if ( UserData.mods.indexOf(ModXUID) == -1 ) {
UserData.mods.push(ModXUID);
let FriendName = FriendsListAPI.GetFriendName(ModXUID);
Utilities.SayParty(`Added ${FriendName} (${ModXUID}) as a moderator!`);
} else {
let FoundIndex = UserData.mods.indexOf(ModXUID);
if ( FoundIndex != -1 ) {
let FriendSteam = UserData.mods[FoundIndex];
let FriendName = FriendsListAPI.GetFriendName(FriendSteam);
Utilities.SayParty(`Removed ${FriendName} (${FriendSteam}) as a moderator!`);
delete UserData.mods[ FoundIndex ];
}
}
} else if ( ModXUID == MySteamID ) {
Utilities.SayParty(`Nope! You cannot add yourself to the moderator!`)
} else {
Utilities.SayParty(`Sorry! I don't know how to decipher: ${args[0]}`)
}
}
}
}
}
});
PartyChatCommands.push({
title: 'Blacklist (!\u{200B}blacklist <partial:name>|<steamid>|<friendcode>|<lobbyindex>)',
helpTitle: 'Type "!blacklist add <PartialName>", "!blacklist add <SteamID64>", "!blacklist add <FriendCode>", "!blacklist add <LobbyIndex>"',
helpExamples: 'Typing "!blacklist add 2" will blacklist the second person in the lobby, others are pretty easy like "!blacklist add csmit"!',
cmds: ['blacklist', 'bl'],
exec: (cmd, args, sender, steamid) => {
if ( steamid == MyPersonaAPI.GetXuid() ) {
UserData.blacklist = UserData.blacklist || [0];
switch(args[0]) {
case 'add':
if ( typeof args[1] != 'undefined' ) {
let BlacklistXUID = Utilities.FindPlayer(args[1]);
if ( BlacklistXUID && BlacklistXUID != MySteamID ) {
if ( UserData.blacklist.indexOf(BlacklistXUID) == -1 ) {
UserData.blacklist.push(BlacklistXUID);
let FriendName = FriendsListAPI.GetFriendName(BlacklistXUID);
Utilities.SayParty(`Added ${FriendName} (${BlacklistXUID}) to blacklist!`);
} else {
let FriendName = FriendsListAPI.GetFriendName(BlacklistXUID);
Utilities.SayParty(`Cannot add ${FriendName}(${BlacklistXUID}) to blacklist!`)
}
} else if ( BlacklistXUID == MySteamID ) {
Utilities.SayParty(`Nope! You cannot add yourself to the blacklist!`)
} else {
Utilities.SayParty(`Sorry! I don't know how to decipher: ${args[1]}`)
}
}
break;
case 'list':
UserData.blacklist.forEach((steamid, index)=>{
if ( steamid ) {
let FriendName = FriendsListAPI.GetFriendName(steamid);
Utilities.SayParty(`[${index}] ${FriendName} - ${steamid}`);
}
})
break;
case 'remove':
if ( typeof args[1] != 'undefined' ) {
if ( typeof UserData.blacklist[ parseInt(args[1]) ] == 'undefined' ) {
let BlacklistXUID = Utilities.FindPlayer(args[1]);
let FoundIndex = UserData.blacklist.indexOf(BlacklistXUID);
if ( BlacklistXUID && FoundIndex != -1 ) {
let FriendSteam = UserData.blacklist[FoundIndex];
let FriendName = FriendsListAPI.GetFriendName(FriendSteam);
Utilities.SayParty(`Removed ${FriendName} (${FriendSteam}) from blacklist!`);
delete UserData.blacklist[ FoundIndex ];
}
} else {
let FriendSteam = UserData.blacklist[ parseInt(args[1]) ];
let FriendName = FriendsListAPI.GetFriendName(FriendSteam);
Utilities.SayParty(`Removed ${FriendName} (${FriendSteam}) from blacklist!`);
delete UserData.blacklist[ parseInt(args[1]) ];
}
}
break;
case 'clear':
let TotalBlacklist = UserData.blacklist.length || 0
Utilities.SayParty(`Cleared ${TotalBlacklist} records (incl removed and existing blacklists)!`);
UserData.blacklist = [0];
break;
default:
if ( typeof args[0] != 'undefined' ) {
let BlacklistXUID = Utilities.FindPlayer(args[0]);
if ( BlacklistXUID && BlacklistXUID != MySteamID ) {
if ( UserData.blacklist.indexOf(BlacklistXUID) == -1 ) {
UserData.blacklist.push(BlacklistXUID);
let FriendName = FriendsListAPI.GetFriendName(BlacklistXUID);
Utilities.SayParty(`Added ${FriendName} (${BlacklistXUID}) to blacklist!`);
} else {
let FoundIndex = UserData.blacklist.indexOf(BlacklistXUID);
if ( FoundIndex != -1 ) {
let FriendSteam = UserData.blacklist[FoundIndex];
let FriendName = FriendsListAPI.GetFriendName(FriendSteam);
Utilities.SayParty(`Removed ${FriendName} (${FriendSteam}) from blacklist!`);
delete UserData.blacklist[ FoundIndex ];
}
}
} else if ( BlacklistXUID == MySteamID ) {
Utilities.SayParty(`Nope! You cannot add yourself to the blacklist!`)
} else {
Utilities.SayParty(`Sorry! I don't know how to decipher: ${args[1]}`)
}
}
}
}
}
});
PartyChatCommands.push({
title: 'Invite (!\u{200B}invite <steamid>|<friendcode>)',
cmds: ['inv', 'invite', 'add'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
Utilities.FindPlayer(args[0], false, (steamid)=>{
FriendsListAPI.ActionInviteFriend(steamid, '')
})
}
});
PartyChatCommands.push({
title: 'WhoInvited (!\u{200B}who <steamid>|<friendcode>)',
cmds: ['who', 'whoinv', 'whoinvite', 'whoinvited'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
let XUID = 0;
if ( typeof args[0] != 'undefined' ) {
XUID = Utilities.FindPlayer(args[0])
}
if ( XUID != 0 ) {
let LobbyData = LobbyAPI.GetSessionSettings()
for ( i=0; i<LobbyData.members.numMachines; i++ ) {
let Machine = LobbyData.members[`machine${i}`]
if ( Machine && XUID == Machine.id ) {
let jfriend = Machine['player0'].game.jfriend
let jfriendName = FriendsListAPI.GetFriendName(jfriend);
let friendName = FriendsListAPI.GetFriendName(XUID);
if ( jfriend ) {
Utilities.SayParty(`${friendName} was invited by ${jfriendName} (${jfriend})!`);
} else {
Utilities.SayParty(`Couldn't find who invited ${friendName}!`);
}
}
}
}
}
});
PartyChatCommands.push({
title: 'Mute (!\u{200B}mute <steamid>|<friendcode>)',
cmds: ['mute', 'm', 'quiet', 'silence', 'ignore', 'block'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
let XUID = 0;
if ( typeof args[0] != 'undefined' ) {
XUID = Utilities.FindPlayer(args[0])
}
if ( XUID != 0 ) {
let friendName = FriendsListAPI.GetFriendName(XUID);
MuteUsers.push(XUID);
Utilities.SayParty(`${friendName} is now muted!`);
}
}
});
PartyChatCommands.push({
title: 'Ping (!\u{200B}ping <ping> [ <target> ] or !ping)',
cmds: ['ping', 'maxping', 'p'],
exec: (cmd, args, sender, steamid) => {
if ( Utilities.IsBlacklisted(steamid) ) return;
let BaseCMD = 'mm_dedicated_search_maxping'
let MyPing = GameInterfaceAPI.GetSettingString(BaseCMD);
if ( /((?:\d\s){3}\d)/.test(MyPing) ) {
MyPing = '> 1000'
} else {
MyPing = '< ' + Math.trunc(MyPing)
}
switch (args.length) {
case 0:
// Print current ping
Utilities.SayParty(`[PING] My ping is: ${MyPing}`);
break;
case 1:
// Set Ping to Arg0
let RequestedPing = Math.trunc(args[0]);
if ( RequestedPing == '0' ) {
RequestedPing = '0 0 0 4'
}
GameInterfaceAPI.ConsoleCommand(`${BaseCMD} ${RequestedPing}`)
Utilities.SayParty(`[PING] I set ping to: ${RequestedPing}`);
break;
case 2:
// If Arg1 == Me, set Ping to Arg0
let XUID = Utilities.FindPlayer(args[1]);
if ( XUID != 0 && XUID == MySteamID ) {
let RequestedPing = Math.trunc(args[0]);
if ( RequestedPing == '0' ) {
RequestedPing = '0 0 0 4'
}
GameInterfaceAPI.ConsoleCommand(`${BaseCMD} ${RequestedPing}`)
Utilities.SayParty(`[PING] I set ping to: ${RequestedPing}`);
}
break;
}
}
});
// Ignore Initial Chat
let PreprocessChat = () => {
let party_chat = $.GetContextPanel().FindChildTraverse("PartyChat")
if(party_chat) {
let chat_lines = party_chat.FindChildTraverse("ChatLinesContainer")
if(chat_lines) {
chat_lines.Children().reverse().forEach(el => {
let child = el.GetChild(0)
if ( child && child.BHasClass('left-right-flow') && child.BHasClass('horizontal-align-left') ) {
if ( child.GetChildCount() == 2 ) {
MsgSteamID = child.Children()[0].steamid;
}
if ( !child.BHasClass('cp_processed') ) {
child.AddClass('cp_processed');
}
}
})
}
}
}
PreprocessChat();
let ProcessChat = false;
let Shutdown = false;
let Timeouts = [];
let PartyChatLoop = ()=>{
let party_chat = $.GetContextPanel().FindChildTraverse("PartyChat")
if(party_chat) {
let chat_lines = party_chat.FindChildTraverse("ChatLinesContainer")
if(chat_lines) {
chat_lines.Children().forEach(el => {
let child = el.GetChild(0)
if ( child && child.BHasClass('left-right-flow') && child.BHasClass('horizontal-align-left') ) {
try {
if ( child.BHasClass('cp_processed') ) return false;
let InnerChild = child.GetChild(child.GetChildCount()-1);
if ( InnerChild && InnerChild.text ) {
let Sender = $.Localize('{s:player_name}', InnerChild);
let Message = $.Localize('{s:msg}', InnerChild);
//var Message = InnerChild.text.toLowerCase()
if (!Message.startsWith(Prefix)) return;
if ( child.GetChildCount() == 2 ) {
MsgSteamID = child.Children()[0].steamid;
}
if ( MuteUsers.includes(MsgSteamID) ) {
//return el.RemoveAndDeleteChildren();
}
const args = Message.slice(Prefix.length).trim().split(' ');
const command = args.shift().toLowerCase();
for ( index=0; index < PartyChatCommands.length; index++ ) {
const ChatCommand = PartyChatCommands[index];
for ( i=0; i<ChatCommand.cmds.length; i++ ) {
const Alias = ChatCommand.cmds[i];
if ( Alias == command ) {
if ( ChatCommand.timeout ) {
if ( Timeouts[ChatCommand] && Date.now() <= Timeouts[ChatCommand] ) {
break;
} else {
Timeouts[ChatCommand] = Date.now() + ChatCommand.timeout
}
}
ChatCommand.exec(command, args, Sender, MsgSteamID)
break;
}
}
}
}
} catch(err) {
$.Msg('CSLua: Error (probably irrelevent) ', err);
}
if ( child ) child.AddClass('cp_processed');
}
})
}
}
}