forked from PenisBlistashiq/Rust-plugins-236-240-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFriends.cs
More file actions
2020 lines (1887 loc) · 93.9 KB
/
Copy pathFriends.cs
File metadata and controls
2020 lines (1887 loc) · 93.9 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
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System;
using Facepunch.Extend;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using ProtoBuf;
using UnityEngine;
using Pool = Facepunch.Pool;
namespace Oxide.Plugins
{
[Info("Friends", "LAGZYA", "4.0.3")]
public class Friends : RustPlugin
{
#region [DATA&CONFIG]
private Dictionary<ulong, FriendData> friendData = new Dictionary<ulong, FriendData>();
private Dictionary<ulong, ulong> playerAccept = new Dictionary<ulong, ulong>(); //fixed by setfps for MAGIX
private static Configs cfg { get; set; }
private class FriendData
{
[JsonProperty(Eng ? "Nickname" : "Ник")] public string Name;
[JsonProperty(Eng ? "Friend-List" : "Список друзей")]
public Dictionary<ulong, FriendAcces> friendList = new Dictionary<ulong, FriendAcces>();
public class FriendAcces
{
[JsonProperty(Eng ? "Nickname" : "Ник")] public string name;
[JsonProperty(Eng ? "Friendly fire" : "Урон по человеку")] public bool Damage;
[JsonProperty(Eng ? "Turret-auth" : "Авторизациия в турелях")]
public bool Turret;
[JsonProperty(Eng ? "Door-auth" : "Авторизациия в дверях")]
public bool Door;
[JsonProperty(Eng ? "AirDef-auth" : "Авторизациия в пво")] public bool Sam;
[JsonProperty(Eng ? "TC auth" : "Авторизациия в шкафу")] public bool bp;
}
}
private const bool Eng = false;
private class Configs
{
[JsonProperty(Eng ? "Enable save during map save?" : "Включить сохранение во время сейва карты?")]
public bool serversave = true;
[JsonProperty(Eng ? "Enable auto-authorization in single locks?" : "Включить авто-авторизацию в одинчных замках?")]
public bool odinlock = true;
[JsonProperty(Eng ? "Disable air defense attack on a copter without a pilot?" : "Отключить атаку пво на коптер без пилота?")]
public bool targetPilot = true;
[JsonProperty(Eng ? "Enable turret auto-authorization setting?" : "Включить настройку авто авторизации турелей?")]
public bool Turret;
[JsonProperty(Eng ? "Enable friendly damage setting?" : "Включить настройку урона по своим?")]
public bool Damage;
[JsonProperty(Eng ? "Enable auto authorization setting in doors?" : "Включить настройку авто авторизации в дверях?")]
public bool Door;
[JsonProperty(Eng ? "Enable auto authorization setting in air defense?" : "Включить настройку авто авторизации в пво?")]
public bool Sam;
[JsonProperty(Eng ? "Enable auto authorization setting in the TC?" : "Включить настройку авто авторизации в шкафу?")]
public bool build;
[JsonProperty(Eng ? "What is the maximum number of people you can be friends with?" : "Сколько максимум людей может быть в друзьях?")]
public int MaxFriends;
[JsonProperty(Eng ? "Default friendly-fire setting" : "Урон по человеку(По стандрату у игрока включена?)")]
public bool SDamage;
[JsonProperty(Eng ? "Default turret-auth setting" : "Авторизациия в турелях(По стандрату у игрока включена?)")]
public bool STurret;
[JsonProperty(Eng ? "Default door-auth setting" : "Авторизациия в дверях(По стандрату у игрока включена?)")]
public bool SDoor;
[JsonProperty(Eng ? "Default air defense setting" : "Авторизациия в пво(По стандрату у игрока включена?)")]
public bool SSam;
[JsonProperty(Eng ? "Default TC auth" : "Авторизациия в шкафу(По стандрату у игрока включена?)")]
public bool bp;
[JsonProperty(Eng ? "Friend request response timeout (in seconds)" : "Время ожидания ответа на запроса в секнудах")]
public int otvet;
[JsonProperty(Eng ? "Enable air defense settings?" : "Вообще включать пво настройку?")]
public bool SSamOn;
public static Configs GetNewConf()
{
var newconfig = new Configs();
newconfig.Damage = true;
newconfig.Door = true;
newconfig.build = true;
newconfig.Turret = true;
newconfig.Sam = true;
newconfig.MaxFriends = 5;
newconfig.SDamage = false;
newconfig.SDoor = true;
newconfig.STurret = true;
newconfig.SSam = true;
newconfig.SSamOn = true;
newconfig.otvet = 10;
return newconfig;
}
}
protected override void LoadDefaultConfig() => cfg = Configs.GetNewConf();
protected override void SaveConfig() => Config.WriteObject(cfg);
protected override void LoadConfig()
{
base.LoadConfig();
try
{
cfg = Config.ReadObject<Configs>();
}
catch
{
LoadDefaultConfig();
}
NextTick(SaveConfig);
}
protected override void LoadDefaultMessages()
{
var ru = new Dictionary<string, string>();
foreach (var rus in new Dictionary<string, string>()
{
["SYNTAX"] = "/fmenu - Открыть меню друзей\n/f(riend) add - Добавить в друзья\n/f(riend) remove - Удалить из друзей\n/f(riend) list - Список друзей\n/f(riend) team - Пригласить в тиму всех друзей онлайн\n/f(riend) set - Настройка друзей по отдельности\n/f(riend) setall - Настройка друзей всех сразу",
["NPLAYER"] = "Игрок не найден!",
["CANTADDME"] = "Нельзя добавить себя в друзья!",
["ONFRIENDS"] = "Игрок уже у вас в друзьях!",
["MAXFRIENDSPLAYERS"] = "У игрока максимальное кол-во друзей!",
["MAXFRIENDYOU"] = "У вас максимальное кол-во друзей!",
["HAVEINVITE"] = "Игрок уже имеет запрос в друзья!",
["SENDADD"] = "Вы отправили запрос, ждем ответа!",
["YOUHAVEINVITE"] = "Вам пришел запрос в друзья напишите /f(riend) accept",
["TIMELEFT"] = "Вы не ответили на запрос!",
["HETIMELEFT"] = "Вам не ответили на запрос!",
["DONTHAVE"] = "У вас нет запросов!",
["ADDFRIEND"] = "Успешное добавление в друзья!",
["DENYADD"] = "Отклонение запроса в друзья!",
["PLAYERDHAVE"] = "У тебя нету такого игрока в друзьях!",
["REMOVEFRIEND"] = "Успешное удаление из друзей!",
["LIST"] = "Список пуст!",
["LIST2"] = "Список друзей",
["SYNTAXSET"] = "/f(riend) set damage [Name] - Урон по человеку\n/f(riend) set door [NAME] - Авторизация в дверях для человека\n/f(riend) set turret [NAME] - Авторизация в турелях для человека\n/f(riend) set sam [NAME] - Авторизация в пво для человека",
["SETOFF"] = "Настройка отключена",
["DAMAGEOFF"] = "Урон по игроку {0} выключен!",
["DAMAGEON"] = "Урон по игроку {0} включен!",
["AUTHDOORON"] = "Авторизация в дверях для {0} включена!",
["AUTHDOOROFF"] = "Авторизация в дверях для {0} выключена!",
["AUTHTURRETON"] = "Авторизация в турелях для {0} включена!",
["AUTHTURRETOFF"] = "Авторизация в турелях для {0} выключена!",
["AUTHBUILDON"] = "Авторизация в шкафу для {0} включена!",
["AUTHBUILDOFF"] = "Авторизация в шкафу для {0} выключена!",
["AUTHSAMON"] = "Авторизация в ПВО для {0} включена!",
["AUTHSAMOFF"] = "Авторизация в ПВО для {0} выключена!",
["SYNTAXSETALL"] = "/f(riend) setall damage 0/1 - Урон по всех друзей\n/f(riend) setall door 0/1 - Авторизация в дверях для всех друзей\n/f(riend) setall turret 0/1 - Авторизация в турелях для всех друзей\n/f(riend) setall sam 0/1 - Авторизация в пво для всех друзей",
["DAMAGEOFFALL"] = "Урон по всем друзьям выключен!",
["DAMAGEONALL"] = "Урон по всем друзьям включен!",
["AUTHDOORONALL"] = "Авторизация в дверях для всех друзей включена!",
["AUTHDOOROFFALL"] = "Авторизация в дверях для всех друзей выключена!",
["AUTHBUILDONALL"] = "Авторизация в шкафу для всех друзей включена!",
["AUTHBUILDOFFALL"] = "Авторизация в шкафу для всех друзей выключена!",
["AUTHTURRETONALL"] = "Авторизация в турелях для всех друзей включена!",
["AUTHTURRETOFFALL"] = "Авторизация в турелях для всех друзей выключена!",
["AUTHSAMONALL"] = "Авторизация в ПВО для всех друзей включена!",
["AUTHSAMOFFALL"] = "Авторизация в ПВО для всех друзей выключена!",
["SENDINVITETEAM"] = "Приглашение отправлено: ",
["SENDACCEPTFRIENDS"] = "ЗАПРОС В ДРУЗЬЯ ОТ {0}",
["SENDINVITE"] = "Вам пришло приглашение в команду от",
["DAMAGE"] = "Нельзя аттаковать {0} это ваш друг!",
["SYSTEMFRIENDS"] = "СИСТЕМА ДРУЗЕЙ",
["UIREMOVEFRIEND"] = "Удалить из друзей",
["UISETTINGS"] = "НАСТРОЙКА",
["UIDAMAGE"] = "Урон по игрокам",
["UIDOOR"] = "Доступ к дверям",
["UIBUILD"] = "Доступ к шкафу",
["UITURRET"] = "Доступ к турелям",
["UISAM"] = "Доступ к пво",
["FRIENDINFO"] = "Информация об",
["LISTFRIEND"] = "Список друзей",
["NOTFOUNS"] = "Нет в базе",
["NOFRIEND"] = "Нет друзей",
["UIFIND"] = "Поиск",
["UIINFOPLAYER"] = "ВВЕДИТЕ НИК/STEAMID"
}) ru.Add(rus.Key, rus.Value);
lang.RegisterMessages(ru, this, "ru");
var eu = new Dictionary<string, string>()
{
["SYNTAX"] = "/fmenu - Open friends menu\n" +
"/f(riend) add - Add friend\n" +
"/f(riend) remove - Remove friend\n" +
"/f(riend) list - Friend list\n" +
"/f(riend) team - Add all team to friends\n" +
"/f(riend) set - Set up friends individually\n" +
"/f(riend) setall - Setting up friends all at once",
["NPLAYER"] = "Player not found!",
["CANTADDME"] = "you cant add yourself!!",
["ONFRIENDS"] = "The player is already your friend!",
["MAXFRIENDSPLAYERS"] = "The player has a lot of friends!",
["MAXFRIENDYOU"] = "You have the maximum number of friends!",
["HAVEINVITE"] = "The player already has a friend request!",
["SENDADD"] = "You sent a request, waiting for response!",
["YOUHAVEINVITE"] = "You received a friend request write /f(riend) accept",
["TIMELEFT"] = "You didn't answer the request!",
["HETIMELEFT"] = "Your request has not been answered!",
["DONTHAVE"] = "You have no requests!",
["ADDFRIEND"] = "Successful addition as a friend!",
["DENYADD"] = "Decline friend request!",
["PLAYERDHAVE"] = "You do not have such a player in your friends!",
["REMOVEFRIEND"] = "Successful unfriending!",
["LIST"] = "The list is empty!",
["LIST2"] = "Friend list",
["SYNTAXSET"] = "/f(riend) set damage [Name] - Damage per person\n" +
"/f(riend) set door [NAME] - Damage per person\n" +
"/f(riend) set turret [NAME] - Authorization in turrets for a person\n" +
"/f(riend) set sam [NAME] - Authorization in air defense for a person",
["SETOFF"] = "Setting disabled",
["DAMAGEOFF"] = "Damage to player {0} disabled!",
["DAMAGEON"] = "Damage to player {0} enabled!",
["AUTHDOORON"] = "Authorization in the doors for {0} is enabled!",
["AUTHDOOROFF"] = "Authorization in the doors for {0} is disabled!",
["AUTHTURRETON"] = "Authorization in turrets for {0} is enabled!",
["AUTHTURRETOFF"] = "Authorization in turrets for {0} is disabled!",
["AUTHBUILDOFF"] = "Authorization in the closet for {0} is disabled!",
["AUTHBUILDON"] = "Authorization in the closet for {0} is enabled!",
["AUTHSAMON"] = "Air defense authorization for {0} enabled!",
["AUTHSAMOFF"] = "Authorization in air defense for {0} is disabled!",
["SYNTAXSETALL"] = "/f(riend) setall damage 0/1 - Damage on all friends\n" +
"/f(riend) setall door 0/1 - Authorization in the door for all friends\n" +
"/f(riend) setall turret 0/1 - Authorization in turrets for all friends\n" +
"/f(riend) setall sam 0/1 - Authorization in air defense for all friends",
["DAMAGEOFFALL"] = "Damage to all friends is disabled!",
["DAMAGEONALL"] = "Damage to all friends is enabled!",
["AUTHDOORONALL"] = "Authorization in the door for all friends is enabled!",
["AUTHDOOROFFALL"] = "Authorization in the door for all friends is disabled!",
["AUTHBUILDONALL"] = "Locker authorization for all friends is enabled!",
["AUTHBUILDOFFALL"] = "Authorization in the closet for all friends is disabled!",
["AUTHTURRETONALL"] = "Authorization in the turrets for all friends is enabled!",
["AUTHTURRETOFFALL"] = "Authorization in the turrets for all friends is disabled!",
["AUTHSAMONALL"] = "Air defense authorization for all friends is enabled!",
["AUTHSAMOFFALL"] = "Air defense authorization for all friends is disabled!",
["SENDINVITETEAM"] = "Invitation sent: ",
["SENDINVITE"] = "You received an invitation to the team from",
["DAMAGE"] = "Can't attack {0} it's your friend!",
["SYSTEMFRIENDS"] = "SYSTEM FRIENDS",
["SENDACCEPTFRIENDS"] = "FRIEND REQUEST FROM {0}",
["UIREMOVEFRIEND"] = "Remove from friends",
["UISETTINGS"] = "SETTING",
["UIDAMAGE"] = "Damage to players",
["UIDOOR"] = "Access to door",
["UIBUILD"] = "Access to cupboard",
["UITURRET"] = "Access to turret",
["UISAM"] = "Access to SAM",
["FRIENDINFO"] = "Information about",
["LISTFRIEND"] = "Friend list",
["NOTFOUNS"] = "Not in base",
["NOFRIEND"] = "No friends",
["UIFIND"] = "Search",
["UIINFOPLAYER"] = "WRITE NAME/STEAMID"
};
lang.RegisterMessages(eu, this, "en");
}
#endregion
#region [Func]
private string PlugName = "<color=red>[FRIENDS]</color> ";
[ChatCommand("f")]
private void FriendCmd(BasePlayer player, string command, string[] arg)
{
if (player == null) return;
ulong ss;
FriendData player1;
FriendData targetPlayer;
if (!friendData.TryGetValue(player.userID, out player1))
{
return;
}
if (arg.Length < 1)
{
SendReply(player,
$"<size=22>{PlugName}</size>\n{lang.GetMessage("SYNTAX", this, player.UserIDString)}");
return;
}
switch (arg[0])
{
case "add":
if (arg.Length < 2)
{
SendReply(player, $"{PlugName}/f(riend) add [NAME or SteamID]");
return;
}
var argLists = arg.ToList();
argLists.RemoveRange(0, 1);
var name = string.Join(" ", argLists.ToArray()).ToLower();
var target = BasePlayer.Find(name);
if (target == null || !friendData.TryGetValue(target.userID, out targetPlayer))
{
SendReply(player, $"{PlugName}{lang.GetMessage("NPLAYER", this, player.UserIDString)}");
return;
}
if (target.userID == player.userID)
{
SendReply(player, $"{PlugName}{lang.GetMessage("CANTADDME", this, player.UserIDString)}");
return;
}
if (player1.friendList.Count >= cfg.MaxFriends)
{
SendReply(player, $"{PlugName}{lang.GetMessage("MAXFRIENDYOU", this, player.UserIDString)}");
return;
}
if (player1.friendList.ContainsKey(target.userID))
{
SendReply(player, $"{PlugName}{lang.GetMessage("ONFRIENDS", this, player.UserIDString)}");
return;
}
if (targetPlayer.friendList.Count >= cfg.MaxFriends)
{
SendReply(player, $"{PlugName}{lang.GetMessage("MAXFRIENDSPLAYERS", this, player.UserIDString)}");
return;
}
if (playerAccept.ContainsKey(target.userID))
{
SendReply(player, $"{PlugName}{lang.GetMessage("HAVEINVITE", this, player.UserIDString)}");
return;
}
playerAccept.Add(target.userID, player.userID);
SendReply(player, $"{PlugName}{lang.GetMessage("SENDADD", this, player.UserIDString)}");
SendReply(target, $"{PlugName}{lang.GetMessage("YOUHAVEINVITE", this, target.UserIDString)}");
InivteStart(player, target);
ss = target.userID;
timer.Once(cfg.otvet, () =>
{
if (!playerAccept.ContainsKey(target.userID) || !playerAccept.ContainsValue(player.userID)) return;
if (target != null)
{
CuiHelper.DestroyUi(target, LayerInvite);
SendReply(target, $"{PlugName}{lang.GetMessage("TIMELEFT", this, target.UserIDString)}");
}
SendReply(player, $"{PlugName}{lang.GetMessage("HETIMELEFT", this, player.UserIDString)}");
playerAccept.Remove(ss);
});
break;
case "accept":
if (!playerAccept.TryGetValue(player.userID, out ss))
{
SendReply(player, $"{PlugName}{lang.GetMessage("DONTHAVE", this, player.UserIDString)}");
return;
}
if (!friendData.TryGetValue(ss, out targetPlayer))
{
SendReply(player, $"{PlugName}{lang.GetMessage("NPLAYER", this, player.UserIDString)}");
return;
}
if (player1.friendList.Count >= cfg.MaxFriends)
{
SendReply(player, $"{PlugName}{lang.GetMessage("MAXFRIENDYOU", this, player.UserIDString)}");
return;
}
if (targetPlayer.friendList.Count >= cfg.MaxFriends)
{
SendReply(player, $"{PlugName}{lang.GetMessage("MAXFRIENDSPLAYERS", this, player.UserIDString)}!");
return;
}
target = BasePlayer.FindByID(ss);
player1.friendList.Add(target.userID,
new FriendData.FriendAcces()
{
name = target.displayName,
Damage = cfg.SDamage,
Door = cfg.SDoor,
Turret = cfg.STurret,
Sam = cfg.SSam,
bp = cfg.bp
});
targetPlayer.friendList.Add(player.userID,
new FriendData.FriendAcces()
{
name = player.displayName,
Damage = cfg.SDamage,
Door = cfg.SDoor,
Turret = cfg.STurret,
Sam = cfg.SSam,
bp = cfg.bp
});
SendReply(player, $"{PlugName}{lang.GetMessage("ADDFRIEND", this, player.UserIDString)}");
playerAccept.Remove(player.userID);
SendReply(target, $"{PlugName}{lang.GetMessage("ADDFRIEND", this, target.UserIDString)}");
if (cfg.bp) AuthBuild(target, player.userID);
CuiHelper.DestroyUi(player, LayerInvite);
break;
case "deny":
if (!playerAccept.TryGetValue(player.userID, out ss))
{
SendReply(player, $"{PlugName}{lang.GetMessage("DONTHAVE", this, player.UserIDString)}");
return;
}
if (!friendData.TryGetValue(ss, out targetPlayer))
{
SendReply(player, $"{PlugName}{lang.GetMessage("NPLAYER", this, player.UserIDString)}");
return;
}
target = BasePlayer.FindByID(ss);
playerAccept.Remove(player.userID);
SendReply(player, $"{PlugName}{lang.GetMessage("DENYADD", this, player.UserIDString)}");
SendReply(target, $"{PlugName}{lang.GetMessage("DENYADD", this, target.UserIDString)}");
CuiHelper.DestroyUi(player, LayerInvite);
break;
case "remove":
if (arg.Length < 2)
{
SendReply(player, $"{PlugName}/f(riend) remove [NAME or SteamID]");
return;
}
argLists = arg.ToList();
argLists.RemoveRange(0, 1);
name = string.Join(" ", argLists.ToArray()).ToLower();
ulong tt;
if (ulong.TryParse(arg[1], out tt)) { } else tt = player1.friendList.FirstOrDefault(p => p.Value.name.ToLower().Contains(name)).Key;
if (!player1.friendList.ContainsKey(tt))
{
SendReply(player, $"{PlugName}{lang.GetMessage("PLAYERDHAVE", this, player.UserIDString)}");
return;
}
if (!friendData.TryGetValue(tt, out targetPlayer))
{
SendReply(player, $"{PlugName}{lang.GetMessage("NPLAYER", this, player.UserIDString)}");
return;
}
player1.friendList.Remove(tt);
targetPlayer.friendList.Remove(player.userID);
SendReply(player, $"{PlugName}{lang.GetMessage("REMOVEFRIEND", this, player.UserIDString)}");
target = tt.IsSteamId() ? BasePlayer.FindByID(tt) : BasePlayer.Find(arg[1].ToLower());
if (target != null)
SendReply(target, $"{PlugName}{lang.GetMessage("REMOVEFRIEND", this, player.UserIDString)}");
if (cfg.build)
RemoveBuild(player, target.userID);
break;
case "list":
if (player1.friendList.Count < 1)
{
SendReply(player, $"{PlugName}{lang.GetMessage("LIST", this, player.UserIDString)}");
return;
}
var argList = player1.friendList;
var friendlist = $"{PlugName}{lang.GetMessage("LIST2", this, player.UserIDString)}\n";
foreach (var keyValuePair in argList)
friendlist += keyValuePair.Value.name + $"({keyValuePair.Key})\n";
SendReply(player, friendlist);
break;
case "set":
if (arg.Length < 3)
{
SendReply(player, $"<size=22>{PlugName}</size>\n{lang.GetMessage("SYNTAXSET", this, player.UserIDString)}");
return;
}
argLists = arg.ToList();
argLists.RemoveRange(0, 2);
name = string.Join(" ", argLists.ToArray()).ToLower();
FriendData.FriendAcces access;
if (ulong.TryParse(arg[2], out ss)) { } else ss = player1.friendList.FirstOrDefault(p => p.Value.name.ToLower().Contains(name)).Key;
if (!player1.friendList.TryGetValue(ss, out access))
{
SendReply(player, $"{PlugName}{lang.GetMessage("NPLAYER", this, player.UserIDString)}");
return;
}
switch (arg[1])
{
case "damage":
if (!cfg.Damage)
{
SendReply(player, $"{PlugName}{lang.GetMessage("SETOFF", this, player.UserIDString)}");
return;
}
if (access.Damage)
{
SendReply(player, $"{PlugName}{String.Format(lang.GetMessage("DAMAGEOFF", this, player.UserIDString), access.name)}");
access.Damage = false;
}
else
{
SendReply(player, $"{PlugName}{String.Format(lang.GetMessage("DAMAGEON", this, player.UserIDString), access.name)}");
access.Damage = true;
}
break;
case "build":
if (!cfg.build)
{
SendReply(player, $"{PlugName}{lang.GetMessage("SETOFF", this, player.UserIDString)}");
return;
}
if (access.bp)
{
SendReply(player,
$"{PlugName}{String.Format(lang.GetMessage("AUTHBUILDOFF", this, player.UserIDString), access.name)}");
access.bp = false;
RemoveBuild(player, ss);
}
else
{
SendReply(player, $"{PlugName}{String.Format(lang.GetMessage("AUTHBUILDON", this, player.UserIDString), access.name)}");
access.bp = true;
AuthBuild(player, ss);
}
break;
case "door":
if (!cfg.Door)
{
SendReply(player, $"{PlugName}{lang.GetMessage("SETOFF", this, player.UserIDString)}");
return;
}
if (access.Door)
{
SendReply(player,
$"{PlugName}{String.Format(lang.GetMessage("AUTHDOOROFF", this, player.UserIDString), access.name)}");
access.Door = false;
}
else
{
SendReply(player, $"{PlugName}{String.Format(lang.GetMessage("AUTHDOORON", this, player.UserIDString), access.name)}");
access.Door = true;
}
break;
case "turret":
if (!cfg.Turret)
{
SendReply(player, $"{PlugName}{lang.GetMessage("SETOFF", this, player.UserIDString)}");
return;
}
if (access.Turret)
{
SendReply(player,
$"{PlugName}{String.Format(lang.GetMessage("AUTHTURRETOFF", this, player.UserIDString), access.name)}");
access.Turret = false;
}
else
{
SendReply(player,
$"{PlugName}{String.Format(lang.GetMessage("AUTHTURRETON", this, player.UserIDString), access.name)}");
access.Turret = true;
}
break;
case "sam":
if (!cfg.SSamOn) return;
if (!cfg.Sam)
{
SendReply(player, $"{PlugName}{lang.GetMessage("SETOFF", this, player.UserIDString)}");
return;
}
if (access.Sam)
{
SendReply(player, $"{PlugName}{String.Format(lang.GetMessage("AUTHSAMOFF", this, player.UserIDString), access.name)}");
access.Sam = false;
}
else
{
SendReply(player, $"{PlugName}{String.Format(lang.GetMessage("AUTHSAMON", this, player.UserIDString), access.name)}");
access.Sam = true;
}
break;
}
break;
case "setall":
if (arg.Length < 3)
{
SendReply(player,
$"<size=22>{PlugName}</size>\n{lang.GetMessage("SYNTAXSETALL", this, player.UserIDString)}");
return;
}
switch (arg[1])
{
case "door":
if (!cfg.Door)
{
SendReply(player, $"{PlugName}{lang.GetMessage("SETOFF", this, player.UserIDString)}");
return;
}
if (arg[2] == "1")
{
foreach (var friends in player1.friendList)
{
friends.Value.Door = true;
}
SendReply(player, $"{PlugName}{lang.GetMessage("AUTHDOORONALL", this, player.UserIDString)}");
}
else
{
foreach (var friends in player1.friendList)
{
friends.Value.Door = false;
}
SendReply(player, $"{PlugName}{lang.GetMessage("AUTHDOOROFFALL", this, player.UserIDString)}");
}
break;
case "damage":
if (!cfg.Damage)
{
SendReply(player, $"{PlugName}{lang.GetMessage("SETOFF", this, player.UserIDString)}");
return;
}
if (arg[2] == "1")
{
foreach (var friends in player1.friendList)
{
friends.Value.Damage = true;
}
SendReply(player, $"{PlugName}{lang.GetMessage("DAMAGEONALL", this, player.UserIDString)}");
}
else
{
foreach (var friends in player1.friendList)
{
friends.Value.Damage = false;
}
SendReply(player, $"{PlugName}{lang.GetMessage("DAMAGEOFFALL", this, player.UserIDString)}");
}
break;
case "build":
if (!cfg.Turret)
{
SendReply(player, $"{PlugName}{lang.GetMessage("SETOFF", this, player.UserIDString)}");
return;
}
if (arg[2] == "1")
{
foreach (var friends in player1.friendList)
{
friends.Value.Turret = true;
}
SendReply(player, $"{PlugName}{lang.GetMessage("AUTHBUILDONALL", this, player.UserIDString)}");
}
else
{
foreach (var friends in player1.friendList)
{
friends.Value.Turret = false;
}
SendReply(player, $"{PlugName}{lang.GetMessage("AUTHBUILDOFFALL", this, player.UserIDString)}");
}
break;
case "turret":
if (!cfg.Turret)
{
SendReply(player, $"{PlugName}{lang.GetMessage("SETOFF", this, player.UserIDString)}");
return;
}
if (arg[2] == "1")
{
foreach (var friends in player1.friendList)
{
friends.Value.Turret = true;
}
SendReply(player, $"{PlugName}{lang.GetMessage("AUTHTURRETONALL", this, player.UserIDString)}");
}
else
{
foreach (var friends in player1.friendList)
{
friends.Value.Turret = false;
}
SendReply(player, $"{PlugName}{lang.GetMessage("AUTHTURRETOFFALL", this, player.UserIDString)}");
}
break;
case "sam":
if (!cfg.SSamOn) return;
if (!cfg.Sam)
{
SendReply(player, $"{PlugName}{lang.GetMessage("SETOFF", this, player.UserIDString)}");
return;
}
if (arg[2] == "1")
{
foreach (var friends in player1.friendList)
{
friends.Value.Sam = true;
}
SendReply(player, $"{PlugName}{lang.GetMessage("AUTHSAMONALL", this, player.UserIDString)}");
}
else
{
foreach (var friends in player1.friendList)
{
friends.Value.Sam = false;
}
SendReply(player, $"{PlugName}{lang.GetMessage("AUTHSAMOFFALL", this, player.UserIDString)}");
}
break;
}
break;
case "team":
RelationshipManager.PlayerTeam team = RelationshipManager.Instance.FindTeam(player.currentTeam);
if (team == null)
{
team = RelationshipManager.Instance.CreateTeam();
team.AddPlayer(player);
team.SetTeamLeader(player.userID);
}
var text = $"{PlugName}{lang.GetMessage("SENDINVITETEAM", this, player.UserIDString)}";
foreach (var ts in player1.friendList)
{
target = BasePlayer.Find(ts.Key.ToString());
if (target != null)
{
RelationshipManager.PlayerTeam Targetteam = RelationshipManager.Instance.FindTeam(target.currentTeam);
if (Targetteam == null)
{
team.SendInvite(target);
target.SendNetworkUpdate();
text += $"{target.displayName}[{target.userID}]\n";
SendReply(target,
$"{PlugName}{lang.GetMessage("SENDINVITE", this, player.UserIDString)} {player.displayName}[{player.userID}]");
}
}
}
SendReply(player, text);
break;
}
}
[ConsoleCommand("friendui2")]
private void FriendConsole(ConsoleSystem.Arg arg)
{
if (arg.Args == null || arg.Args.Length < 1) return;
FriendCmd(arg.Player(), "friend", arg.Args);
if (arg.Args[0] == "set")
{
NextTick(() => SettingInit(arg.Player(), ulong.Parse(arg.Args[2]), arg.Args[3]));
}
if (arg.Args[0] == "remove")
{
StartUi(arg.Player());
}
}
[ChatCommand("friend")]
private void FriendCmd2(BasePlayer player, string command, string[] arg)
{
if (player == null) return;
FriendCmd(player, command, arg);
}
#endregion
#region [Hooks]
private void OnEntitySpawned(BuildingPrivlidge entity)
{
FriendData fData;
if (!friendData.TryGetValue(entity.OwnerID, out fData)) return;
foreach (var ids in fData.friendList.Where(p => p.Value.bp == true))
{
entity.authorizedPlayers.Add(new PlayerNameID()
{
ShouldPool = true,
userid = ids.Key,
username = ids.Value.name
});
}
}
private List<ulong> hitPlayer = new List<ulong>();
[PluginReference] private Plugin TruePVE;
private object CanEntityTakeDamage(BaseEntity entity, HitInfo info)
{
if (entity == null || info == null) return null;
FriendData player1;
var targetplayer = entity as BasePlayer;
var attackerplayer = info.Initiator as BasePlayer;
if (attackerplayer == null || targetplayer == null) return null;
if (!friendData.TryGetValue(attackerplayer.userID, out player1)) return null;
FriendData.FriendAcces ss;
if (!player1.friendList.TryGetValue(targetplayer.userID, out ss)) return null;
if (ss.Damage) return null;
if (hitPlayer.Contains(attackerplayer.userID)) return false;
hitPlayer.Add(attackerplayer.userID);
timer.Once(5f, () =>
{
if (hitPlayer.Contains(attackerplayer.userID))
hitPlayer.Remove(attackerplayer.userID);
});
SendReply(attackerplayer, string.Format(lang.GetMessage("DAMAGE", this, attackerplayer.UserIDString), targetplayer.displayName));
return false;
}
private object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
{
if (TruePVE != null) return null;
return CanEntityTakeDamage(entity, info);
}
private object OnTurretTarget(AutoTurret turret, BaseCombatEntity entity)
{
if (entity == null || turret == null) return null;
FriendData targetPlayer;
var targetplayer = entity as BasePlayer;
if (targetplayer == null) return null;
if (!friendData.TryGetValue(turret.OwnerID, out targetPlayer)) return null;
FriendData.FriendAcces ss;
var owner = turret.authorizedPlayers.Exists(p => p.userid == turret.OwnerID);
if (!owner) return null;
if (!targetPlayer.friendList.TryGetValue(targetplayer.userID, out ss)) return null;
if (!ss.Turret) return null;
return false;
}
private object CanUseLockedEntity(BasePlayer player, BaseLock baseLock)
{
if (player == null || baseLock == null) return null;
FriendData targetPlayer2;
if (baseLock.ShortPrefabName == "lock.key" && !cfg.odinlock) return null;
if (!friendData.TryGetValue(baseLock.OwnerID, out targetPlayer2)) return null;
FriendData.FriendAcces ss;
if (!targetPlayer2.friendList.TryGetValue(player.userID, out ss)) return null;
if (!ss.Door) return null;
return true;
}
private bool TargetPilot(SamSite entity, BaseCombatEntity target)
{
var targetPlayer = (target as BaseVehicle)?.GetDriver();
return targetPlayer != null;
}
private object OnSamSiteTarget(SamSite entity, BaseCombatEntity target)
{
if (cfg.targetPilot && !TargetPilot(entity, target)) return false;
if (!cfg.SSamOn) return null;
if (entity == null || target == null) return null;
FriendData targetPlayer;
var targetpcopter = target as MiniCopter;
if (targetpcopter != null)
{
var build = entity.GetBuildingPrivilege();
if (build == null) return null;
if (!build.authorizedPlayers.Exists(p => p.userid == entity.OwnerID)) return null;
BasePlayer targePlayer = null;
if (targetpcopter != null) targePlayer = targetpcopter.mountPoints[0].mountable._mounted;
if (targePlayer == null) return false;
if (entity.OwnerID == targePlayer.userID) return false;
if (!friendData.TryGetValue(entity.OwnerID, out targetPlayer)) return null;
FriendData.FriendAcces ss;
if (!targetPlayer.friendList.TryGetValue(targePlayer.userID, out ss)) return null;
if (!ss.Sam) return null;
}
else
{
return null;
}
return false;
}
private void OnPlayerConnected(BasePlayer player)
{
FriendData t;
if (friendData.TryGetValue(player.userID, out t)) return;
friendData.Add(player.userID, new FriendData() { Name = player.displayName, friendList = { } });
}
private void OnServerInitialized()
{
permission.RegisterPermission("friends.checkplayer", this);
ServerConsole.PrintColoured(ConsoleColor.Blue, (object)$"{Name} [{Version}] ", (object)ConsoleColor.Blue, (object)"B", (object)ConsoleColor.Cyan, (object)"Y ", (object)ConsoleColor.Green, (object)"L", (object)ConsoleColor.Magenta, (object)"A", (object)ConsoleColor.Red, (object)"G", (object)ConsoleColor.Yellow, (object)"Z", (object)ConsoleColor.Cyan, (object)"Y", (object)ConsoleColor.DarkCyan, (object)"A");
if (ImageLibrary == null)
{
Interface.Oxide.UnloadPlugin(Name);
return;
}
if (!cfg.serversave)
Unsubscribe("OnServerSave");
friendData =
Interface.Oxide.DataFileSystem.ReadObject<Dictionary<ulong, FriendData>>("Friends/FriendData");
foreach (var basePlayer in BasePlayer.activePlayerList)
OnPlayerConnected(basePlayer);
}
void OnServerSave()
{
Interface.Oxide.DataFileSystem.WriteObject("Friends/FriendData", friendData);
Puts(Eng ? "Save Data!" : "Произошло сохранение даты!");
}
private void Unload()
{
Interface.Oxide.DataFileSystem.WriteObject("Friends/FriendData", friendData);
foreach (var basePlayer in BasePlayer.activePlayerList)
{
CuiHelper.DestroyUi(basePlayer, LayerInvite);
CuiHelper.DestroyUi(basePlayer, Layer);
}
}
#endregion
#region [UI]
private static string Layer = "UISoFriends";
private string Hud = "Hud";
private string Overlay = "Overlay";
private string regular = "robotocondensed-regular.ttf";
private static string Sharp = "assets/content/ui/ui.background.tile.psd";
private static string Blur = "assets/content/ui/uibackgroundblur.mat";
private static string radial = "assets/content/ui/ui.background.transparent.radial.psd";
private CuiPanel Fon = new CuiPanel()
{
RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" },
Image = {ImageType = UnityEngine.UI.Image.Type.Filled,
Png = "assets/standard assets/effects/imageeffects/textures/noise.png",
Sprite = "assets/content/ui/ui.background.transparent.radial.psd",
Color = HexToRustFormat("#303038F6"),
Material = "assets/icons/greyout.mat"}
};
private CuiPanel MainFon = new CuiPanel()
{
RectTransform =
{AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-1920 -1080", OffsetMax = "1920 1080"},
CursorEnabled = true,
Image = { Color = "0.24978750 0.2312312 0.312312312 0" }
};
private CuiPanel _searchPanel = new CuiPanel()
{
RectTransform = { AnchorMin = "0.3364583 0.3573457", AnchorMax = "0.6644097 0.6095061" },
Image = { Color = "0 0 0 0.42" }
};
private CuiButton _close = new CuiButton()
{
RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" },
Button = { Close = Layer, Color = "0.64 0.64 0.64 0" },