forked from PapaCharlie9/voteban
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCVoteBan.cs
1989 lines (1752 loc) · 82 KB
/
CVoteBan.cs
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;
using System.IO;
using System.Text;
using System.Threading;
using System.Timers;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Text.RegularExpressions;
using System.Net;
using System.Web;
using PRoCon.Core;
using PRoCon.Core.Plugin;
using PRoCon.Core.Plugin.Commands;
using PRoCon.Core.Players;
using PRoCon.Core.Players.Items;
using PRoCon.Core.Battlemap;
using PRoCon.Core.Maps;
namespace PRoConEvents
{
public class CVoteBan : PRoConPluginAPI, IPRoConPluginInterface
{
private enumBoolYesNo enableVoteBan;
private int voteBanThreshold;
private int startVoteNumber;
private int votePercentageRequired;
private int voteDuration;
private int voteProgressNumber;
private string banType;
private string banDuration;
private int banLength;
private string banDisplayReason;
private enumBoolYesNo enableVoteKick;
private int voteKickThreshold;
private int startKickVoteNumber;
private int voteKickPercentageRequired;
private int voteKickDuration;
private int voteKickProgressNumber;
private enumBoolYesNo enableHackCry;
private int hackCriesNeeded;
private string hackCryResponse;
private List<string> additionalTriggers;
private List<string> privilegedUsers;
private List<string> privilegedTags;
private string whitelistActionTaken;
private int whitelistBanLength;
private List<string> banCommand;
private List<string> kickCommand;
private List<string> yesCommand;
private List<string> noCommand;
private List<string> cancelVoteCommand;
private int maxVoters;
private int yesVotesNeeded;
private int yesVotes;
private int noVotes;
private int hackCryCount;
private string resetMessages;
private List<string> inGameMessages;
private string votedVictim;
private string votedVictimGUID;
private string votedVictimIP;
private string votedVictimPbGuid;
private string currentSpeaker;
private string currentVotedPlayer;
private string currentVoteType;
private string currentVoteReason;
private string voteType;
private string voteReason;
private string currentVoteTypeForThreshold;
private string currentSpeakerForThreshold;
private string currentMessageForThreshold;
private CPrivileges currentPrivileges;
private List<string> alreadyVoted;
private List<string> playerBeingVotedReason;
private List<string> playerBeingVoted;
private List<string> playerBeingKickVoted;
private List<int> playerBeingVotedCount;
private List<int> playerBeingKickVotedCount;
private Dictionary<string, string> voteeVoters;
private Dictionary<string, string> voteeVotersForKick;
private List<string> suggestedPlayerName;
private List<string> suggestedPlayerNameForKick;
private List<string> awaitedConfirmationPlayer;
private List<string> awaitedConfirmationPlayerForKick;
private List<string> awaitedConfirmationPlayerReason;
private bool voteIsInProgress;
private bool needPlayerCount;
private bool needPlayerCountForThreshold;
private bool needVotedVictimInfo;
private bool banningPlayerByGUID;
private bool banningPlayerByIP;
private bool banningPlayerByName;
private bool banningPlayerByPbGuid;
private bool kickingPlayer;
private bool processingVote;
private bool foundvotedVictim;
private bool pluginEnabled;
private System.Timers.Timer voteInProgress;
private System.Timers.Timer voteProgressDisplay;
private BattlelogClient blClient;
public CVoteBan()
{
this.enableVoteBan = enumBoolYesNo.No;
this.voteBanThreshold = 0;
this.startVoteNumber = 3;
this.votePercentageRequired = 40;
this.voteDuration = 3;
this.voteProgressNumber = 15;
this.banType = "GUID";
this.banDuration = "Permanent";
this.banLength = 1440;
this.banDisplayReason = "Banned by player Vote Ban - %player% (Reason: %reason%)";
this.enableVoteKick = enumBoolYesNo.No;
this.voteKickThreshold = 0;
this.startKickVoteNumber = 3;
this.voteKickPercentageRequired = 40;
this.voteKickDuration = 3;
this.voteKickProgressNumber = 15;
this.enableHackCry = enumBoolYesNo.No;
this.hackCriesNeeded = 3;
this.hackCryResponse = "Is there a hacker on? Type %vbcommand% <player_name> to initiate a Vote Ban!";
this.additionalTriggers = new List<string>();
this.additionalTriggers.Add("aimbot");
this.privilegedUsers = new List<string>();
this.privilegedTags = new List<string>();
this.whitelistActionTaken = "None";
this.whitelistBanLength = 60;
this.banCommand = new List<string>();
this.kickCommand = new List<string>();
this.yesCommand = new List<string>();
this.noCommand = new List<string>();
this.cancelVoteCommand = new List<string>();
this.banCommand.Add("!voteban");
this.banCommand.Add("@voteban");
this.kickCommand.Add("!votekick");
this.kickCommand.Add("@votekick");
this.yesCommand.Add("!yes");
this.yesCommand.Add("@yes");
this.noCommand.Add("!no");
this.noCommand.Add("@no");
this.cancelVoteCommand.Add("!cancelvote");
this.cancelVoteCommand.Add("@cancelvote");
this.maxVoters = 64;
this.yesVotes = 0;
this.noVotes = 0;
this.hackCryCount = 0;
this.resetMessages = "...";
this.inGameMessages = new List<string>();
this.initInGameMessages();
this.alreadyVoted = new List<string>();
this.playerBeingVotedReason = new List<string>();
this.playerBeingVoted = new List<string>();
this.playerBeingKickVoted = new List<string>();
this.playerBeingVotedCount = new List<int>();
this.playerBeingKickVotedCount = new List<int>();
this.voteeVoters = new Dictionary<string, string>();
this.voteeVotersForKick = new Dictionary<string, string>();
this.suggestedPlayerName = new List<string>();
this.suggestedPlayerNameForKick = new List<string>();
this.awaitedConfirmationPlayer = new List<string>();
this.awaitedConfirmationPlayerForKick = new List<string>();
this.awaitedConfirmationPlayerReason = new List<string>();
this.voteIsInProgress = false;
this.needPlayerCount = false;
this.needPlayerCountForThreshold = false;
this.needVotedVictimInfo = false;
this.banningPlayerByGUID = false;
this.banningPlayerByIP = false;
this.banningPlayerByName = false;
this.banningPlayerByPbGuid = false;
this.kickingPlayer = false;
this.processingVote = false;
this.foundvotedVictim = false;
this.pluginEnabled = false;
}
public string GetPluginName()
{
return "Vote Ban";
}
public string GetPluginVersion()
{
return "2.0.1.0";
}
public string GetPluginAuthor()
{
return "TimSad";
}
public string GetPluginWebsite()
{
return "www.phogue.net/forumvb/showthread.php?3582";
}
public string GetPluginDescription()
{
return @"
<h2>Description</h2>
<p>This plugin allows players to start a vote to ban or kick another player on the server. This is particularly useful to work against all the hackers we have seen so much of lately.</p>
<h2>In-Game Commands</h2>
<blockquote><h4>!voteban <player_name></h4>Puts in a request to initiate a Vote Ban on the specified player.</blockquote>
<blockquote><h4>!votekick <player_name></h4>Puts in a request to initiate a Vote Kick on the specified player.</blockquote>
<blockquote><h4>!yes</h4>Votes YES to ban/kick the player who has a Vote Ban/Kick in progress on them.<br \>Also, agrees to the suggested name after misspelling a name when trying to Vote Ban or Vote Kick.</blockquote>
<blockquote><h4>!no</h4>Votes NO to ban/kick the player who has a Vote Ban/Kick in progress on them.<br \>Also, disagrees to the suggested name after misspelling a name when trying to Vote Ban or Vote Kick.</blockquote>
<blockquote><h4>!cancelvote</h4>Cancels the current vote in progress. This command is only available to players who have an account created and are able to connect to the Procon Layer.</blockquote>
<p><b>NOTE:</b> These commands may be redefined by you in the plugin settings.</p>
<h2>Settings</h2>
<h3>Vote Ban</h3>
<blockquote><h4>Enable Vote Ban?</h4>Allows you to enable or disable the ability for players to Vote Ban.</blockquote>
<blockquote><h4>Vote Ban Player Count Threshold</h4>The minimum number of players that must be on the server for Vote Banning to be enabled.</blockquote>
<blockquote><h4>Start Vote Ban Number</h4>The number of <b>!voteban</b> requests needed to initiate a Vote Ban on the specified player.</blockquote>
<blockquote><h4>Vote Ban Pass Percentage</h4>The percentage of YES votes of the total players needed for a Vote Ban to pass.</blockquote>
<blockquote><h4>Vote Ban Duration (in minutes)</h4>How long Vote Bans last before they are ended.</blockquote>
<blockquote><h4>Vote Ban Progress Display Interval (in seconds)</h4>The recurring number of seconds that the progress of the current Vote Ban is displayed in chat.</blockquote>
<blockquote><h4>Ban Type</h4>The type of ban (GUID, Name, IP, or PB GUID) that is issued upon a successful Vote Ban.</blockquote>
<blockquote><h4>Ban Duration</h4>How long bans last upon a successful Vote Ban.</blockquote>
<blockquote><h4>Ban Length (in minutes)</h4>If <b>Ban Duration</b> is set to Temporary, bans last for this length of time before they expire.</blockquote>
<blockquote><h4>Ban Reason Message</h4>Set this to whatever you would like the ban reason to be upon a successful Vote Ban. (Use <b>%player%</b> for the banned player and <b>%reason%</b> for the reason the players Vote Banned the player.)</blockquote>
<h3>Vote Kick</h3>
<blockquote><h4>Enable Vote Kick?</h4>Allows you to enable or disable the ability for players to Vote Kick.</blockquote>
<blockquote><h4>Vote Kick Player Count Threshold</h4>The minimum number of players that must be on the server for Vote Kicking to be enabled.</blockquote>
<blockquote><h4>Start Vote Kick Number</h4>The number of <b>!votekick</b> requests needed to initiate a Vote Kick on the specified player.</blockquote>
<blockquote><h4>Vote Kick Pass Percentage</h4>The percentage of YES votes of the total players needed for a Vote Kick to pass.</blockquote>
<blockquote><h4>Vote Kick Duration (in minutes)</h4>How long Vote Kicks last before they are ended.</blockquote>
<blockquote><h4>Vote Kick Progress Display Interval (in seconds)</h4>The recurring number of seconds that the progress of the current Vote Kick is displayed in chat.</blockquote>
<h3>Hack Cry Responder</h3>
<blockquote><h4>Enable Hack Cry Responder?</h4>Allows you to enable or disable the Hack Cry Responder.</blockquote>
<blockquote><h4>Hack Cry Trigger Number</h4>The number of times that the word ""hack"" needs to be said in chat, recurrently, to trigger the responder.</blockquote>
<blockquote><h4>Hack Cry Trigger Response</h4>The server message response sent when the responder is triggered. (Use <b>%vbcommand%</b> and <b>%vkcommand%</b> for your currently set Vote Ban and Vote Kick commands.)</blockquote>
<blockquote><h4>Additional Triggers</h4>Any additional words in chat that you would like to trigger the responder.</blockquote>
<h3>Whitelist</h3>
<p>This whitelist guards admins as well as additional players of your choice from being Vote Banned/Kicked. It recognizes players as admins if they have an account created and are able to connect to the Procon Layer.</p>
<blockquote><h4>In-Game Names</h4>Allows you to add additional players to the whitelist.</blockquote>
<blockquote><h4>Clan Tags</h4>Allows you to add Clan Tags to protect the wearer of any tag from being Vote Banned/Kicked.</blockquote>
<blockquote><h4>Action Taken</h4>The action taken (None, Kill, Kick, Temporarily Ban, Permanently Ban) against a player that tries to Vote Ban/Kick a player in the whitelist.</blockquote>
<blockquote><h4>Temporary Ban Length (in minutes)</h4>If <b>Action Taken</b> is set to Temporarily Ban, bans last for this length of time before they expire.</blockquote><br />
<h3>In-Game Commands</h3>
<p>These allow you to customize the in-game commands for this plugin.</p>
<blockquote><h4>Vote Ban Commands</h4>The commands used to initiate a Vote Ban.</blockquote>
<blockquote><h4>Vote Kick Commands</h4>The commands used to initiate a Vote Kick.</blockquote>
<blockquote><h4>Yes Commands</h4>The commands used to vote yes to the vote in progress. (Also used to confirm a suggested player name.)</blockquote>
<blockquote><h4>No Commands</h4>The commands used to vote no to the vote in progress. (Also used to deny a suggested player name.)</blockquote>
<blockquote><h4>Cancel Vote Commands</h4>The commands used to cancel the vote in progress.</blockquote>
<h3>In-Game Messages</h3>
<p>This allows you to customize all the messages that this plugin sends to the server.</p>
<blockquote><h4>Reset Messages?</h4>Use this to retrieve the default list of messages. This is useful when you may have made a mistake and messages start to not show up.</blockquote>
<blockquote><h4>Message List</h4>The list containing all the messages that this plugin sends to the server. Be careful not to delete any lines otherwise things will go wrong!</blockquote>
";
}
public void OnPluginLoaded(string strHostName, string strPort, string strPRoConVersion)
{
this.RegisterEvents(this.GetType().Name,
"OnGlobalChat",
"OnTeamChat",
"OnSquadChat",
"OnListPlayers",
"OnRoundOver",
"OnPunkbusterPlayerInfo",
"OnPunkbusterEndPlayerInfo",
"OnPlayerLeft",
"OnLevelLoaded"
);
}
public void OnPluginEnable()
{
this.pluginEnabled = true;
this.ExecuteCommand("procon.protected.pluginconsole.write", "^bVote Ban ^2Enabled!");
}
public void OnPluginDisable()
{
this.pluginEnabled = false;
// If a vote is in progress, cancel it
if (voteIsInProgress)
{
cancelVote("PLUGIN-Disabled");
}
OnRoundOver(0); // Reset everything, so on next enable make everything like the class was just constructed
this.ExecuteCommand("procon.protected.pluginconsole.write", "^bVote Ban ^1Disabled =(");
}
public List<CPluginVariable> GetDisplayPluginVariables()
{
List<CPluginVariable> lstReturn = new List<CPluginVariable>();
lstReturn.Add(new CPluginVariable("Vote Ban|Enable Vote Ban?", typeof(enumBoolYesNo), enableVoteBan));
if (enableVoteBan == enumBoolYesNo.Yes)
{
lstReturn.Add(new CPluginVariable("Vote Ban|Vote Ban Player Count Threshold", voteBanThreshold.GetType(), voteBanThreshold));
lstReturn.Add(new CPluginVariable("Vote Ban|Start Vote Ban Number", startVoteNumber.GetType(), startVoteNumber));
lstReturn.Add(new CPluginVariable("Vote Ban|Vote Ban Pass Percentage", votePercentageRequired.GetType(), votePercentageRequired));
lstReturn.Add(new CPluginVariable("Vote Ban|Vote Ban Duration (in minutes)", voteDuration.GetType(), voteDuration));
lstReturn.Add(new CPluginVariable("Vote Ban|Vote Ban Progress Display Interval (in seconds)", voteProgressNumber.GetType(), voteProgressNumber));
lstReturn.Add(new CPluginVariable("Vote Ban|Ban Type", "enum.BanType(GUID|IP|Name|PB GUID)", banType));
lstReturn.Add(new CPluginVariable("Vote Ban|Ban Duration", "enum.BanDuration(Permanent|Temporary)", banDuration));
if (banDuration == "Temporary")
lstReturn.Add(new CPluginVariable("Vote Ban|Ban Length (in minutes)", banLength.GetType(), banLength));
lstReturn.Add(new CPluginVariable("Vote Ban|Ban Reason Message", banDisplayReason.GetType(), banDisplayReason));
}
lstReturn.Add(new CPluginVariable("Vote Kick|Enable Vote Kick?", typeof(enumBoolYesNo), enableVoteKick));
if (enableVoteKick == enumBoolYesNo.Yes)
{
lstReturn.Add(new CPluginVariable("Vote Kick|Vote Kick Player Count Threshold", voteKickThreshold.GetType(), voteKickThreshold));
lstReturn.Add(new CPluginVariable("Vote Kick|Start Vote Kick Number", startKickVoteNumber.GetType(), startKickVoteNumber));
lstReturn.Add(new CPluginVariable("Vote Kick|Vote Kick Pass Percentage", voteKickPercentageRequired.GetType(), voteKickPercentageRequired));
lstReturn.Add(new CPluginVariable("Vote Kick|Vote Kick Duration (in minutes)", voteKickDuration.GetType(), voteKickDuration));
lstReturn.Add(new CPluginVariable("Vote Kick|Vote Kick Progress Display Interval (in seconds)", voteKickProgressNumber.GetType(), voteKickProgressNumber));
}
lstReturn.Add(new CPluginVariable("Hack Cry Responder|Enable Hack Cry Responder?", typeof(enumBoolYesNo), enableHackCry));
if (enableHackCry == enumBoolYesNo.Yes)
{
lstReturn.Add(new CPluginVariable("Hack Cry Responder|Hack Cry Trigger Number", hackCriesNeeded.GetType(), hackCriesNeeded));
lstReturn.Add(new CPluginVariable("Hack Cry Responder|Hack Cry Trigger Response", hackCryResponse.GetType(), hackCryResponse));
lstReturn.Add(new CPluginVariable("Hack Cry Responder|Additional Triggers", typeof(string[]), additionalTriggers.ToArray()));
}
lstReturn.Add(new CPluginVariable("Whitelist|In-Game Names", typeof(string[]), privilegedUsers.ToArray()));
lstReturn.Add(new CPluginVariable("Whitelist|Clan Tags", typeof(string[]), privilegedTags.ToArray()));
lstReturn.Add(new CPluginVariable("Whitelist|Action Taken", "enum.ActionTaken(None|Kill|Kick|Temporarily Ban|Permanently Ban)", whitelistActionTaken));
if (whitelistActionTaken == "Temporarily Ban")
lstReturn.Add(new CPluginVariable("Whitelist|Temporary Ban Length (in minutes)", whitelistBanLength.GetType(), whitelistBanLength));
lstReturn.Add(new CPluginVariable("In-Game Commands|Vote Ban Commands", typeof(string[]), banCommand.ToArray()));
lstReturn.Add(new CPluginVariable("In-Game Commands|Vote Kick Commands", typeof(string[]), kickCommand.ToArray()));
lstReturn.Add(new CPluginVariable("In-Game Commands|Yes Commands", typeof(string[]), yesCommand.ToArray()));
lstReturn.Add(new CPluginVariable("In-Game Commands|No Commands", typeof(string[]), noCommand.ToArray()));
lstReturn.Add(new CPluginVariable("In-Game Commands|Cancel Vote Commands", typeof(string[]), cancelVoteCommand.ToArray()));
lstReturn.Add(new CPluginVariable("In-Game Messages|Reset Messages?", "enum.resetMessages(...|Do it!)", resetMessages));
lstReturn.Add(new CPluginVariable("In-Game Messages|Message List", typeof(string[]), inGameMessages.ToArray()));
return lstReturn;
}
public List<CPluginVariable> GetPluginVariables()
{
List<CPluginVariable> lstReturn = new List<CPluginVariable>();
lstReturn.Add(new CPluginVariable("Enable Vote Ban?", typeof(enumBoolYesNo), enableVoteBan));
lstReturn.Add(new CPluginVariable("Vote Ban Player Count Threshold", voteBanThreshold.GetType(), voteBanThreshold));
lstReturn.Add(new CPluginVariable("Start Vote Ban Number", startVoteNumber.GetType(), startVoteNumber));
lstReturn.Add(new CPluginVariable("Vote Ban Pass Percentage", votePercentageRequired.GetType(), votePercentageRequired));
lstReturn.Add(new CPluginVariable("Vote Ban Duration (in minutes)", voteDuration.GetType(), voteDuration));
lstReturn.Add(new CPluginVariable("Vote Ban Progress Display Interval (in seconds)", voteProgressNumber.GetType(), voteProgressNumber));
lstReturn.Add(new CPluginVariable("Ban Type", "enum.BanType(GUID|IP|Name|PB GUID)", banType));
lstReturn.Add(new CPluginVariable("Ban Duration", "enum.BanDuration(Permanent|Temporary)", banDuration));
lstReturn.Add(new CPluginVariable("Ban Length (in minutes)", banLength.GetType(), banLength));
lstReturn.Add(new CPluginVariable("Ban Reason Message", banDisplayReason.GetType(), banDisplayReason));
lstReturn.Add(new CPluginVariable("Enable Vote Kick?", typeof(enumBoolYesNo), enableVoteKick));
lstReturn.Add(new CPluginVariable("Vote Kick Player Count Threshold", voteKickThreshold.GetType(), voteKickThreshold));
lstReturn.Add(new CPluginVariable("Start Vote Kick Number", startKickVoteNumber.GetType(), startKickVoteNumber));
lstReturn.Add(new CPluginVariable("Vote Kick Pass Percentage", voteKickPercentageRequired.GetType(), voteKickPercentageRequired));
lstReturn.Add(new CPluginVariable("Vote Kick Duration (in minutes)", voteKickDuration.GetType(), voteKickDuration));
lstReturn.Add(new CPluginVariable("Vote Kick Progress Display Interval (in seconds)", voteKickProgressNumber.GetType(), voteKickProgressNumber));
lstReturn.Add(new CPluginVariable("Enable Hack Cry Responder?", typeof(enumBoolYesNo), enableHackCry));
lstReturn.Add(new CPluginVariable("Hack Cry Trigger Number", hackCriesNeeded.GetType(), hackCriesNeeded));
lstReturn.Add(new CPluginVariable("Hack Cry Trigger Response", hackCryResponse.GetType(), hackCryResponse));
lstReturn.Add(new CPluginVariable("Additional Triggers", typeof(string[]), additionalTriggers.ToArray()));
lstReturn.Add(new CPluginVariable("In-Game Names", typeof(string[]), privilegedUsers.ToArray()));
lstReturn.Add(new CPluginVariable("Clan Tags", typeof(string[]), privilegedTags.ToArray()));
lstReturn.Add(new CPluginVariable("Action Taken", "enum.ActionTaken(None|Kill|Kick|Temporarily Ban|Permanently Ban)", whitelistActionTaken));
lstReturn.Add(new CPluginVariable("Temporary Ban Length (in minutes)", whitelistBanLength.GetType(), whitelistBanLength));
lstReturn.Add(new CPluginVariable("Vote Ban Commands", typeof(string[]), banCommand.ToArray()));
lstReturn.Add(new CPluginVariable("Vote Kick Commands", typeof(string[]), kickCommand.ToArray()));
lstReturn.Add(new CPluginVariable("Yes Commands", typeof(string[]), yesCommand.ToArray()));
lstReturn.Add(new CPluginVariable("No Commands", typeof(string[]), noCommand.ToArray()));
lstReturn.Add(new CPluginVariable("Cancel Vote Commands", typeof(string[]), cancelVoteCommand.ToArray()));
lstReturn.Add(new CPluginVariable("Reset Messages?", "enum.resetMessages(...|Do it!)", resetMessages));
lstReturn.Add(new CPluginVariable("Message List", typeof(string[]), inGameMessages.ToArray()));
return lstReturn;
}
public void SetPluginVariable(string strVariable, string strValue)
{
if (strVariable.CompareTo("Enable Vote Ban?") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
{
enableVoteBan = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
}
else if (strVariable.CompareTo("Vote Ban Player Count Threshold") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
voteBanThreshold = valueAsInt;
}
else if (strVariable.CompareTo("Start Vote Ban Number") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
startVoteNumber = valueAsInt;
}
else if (strVariable.CompareTo("Vote Ban Pass Percentage") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
votePercentageRequired = valueAsInt;
}
else if (strVariable.CompareTo("Vote Ban Duration (in minutes)") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
voteDuration = valueAsInt;
}
else if (strVariable.CompareTo("Vote Ban Progress Display Interval (in seconds)") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
voteProgressNumber = valueAsInt;
}
else if (strVariable.CompareTo("Ban Type") == 0)
{
banType = strValue;
}
else if (strVariable.CompareTo("Ban Duration") == 0)
{
banDuration = strValue;
//this.ExecuteCommand("procon.protected.pluginconsole.write", "^3^b[Vote Ban] ^n^0DEBUG: Ban Duration set to: ^b" + banDuration);
}
else if (strVariable.CompareTo("Ban Length (in minutes)") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
banLength = valueAsInt;
}
else if (strVariable.CompareTo("Ban Reason Message") == 0)
{
if (strValue == "")
banDisplayReason = "Banned by player Vote Ban - %player% (Reason: %reason%)";
else
banDisplayReason = strValue;
}
else if (strVariable.CompareTo("Enable Vote Kick?") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
{
enableVoteKick = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
}
else if (strVariable.CompareTo("Vote Kick Player Count Threshold") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
voteKickThreshold = valueAsInt;
}
else if (strVariable.CompareTo("Start Vote Kick Number") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
startKickVoteNumber = valueAsInt;
}
else if (strVariable.CompareTo("Vote Kick Pass Percentage") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
voteKickPercentageRequired = valueAsInt;
}
else if (strVariable.CompareTo("Vote Kick Duration (in minutes)") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
voteKickDuration = valueAsInt;
}
else if (strVariable.CompareTo("Vote Kick Progress Display Interval (in seconds)") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
voteKickProgressNumber = valueAsInt;
}
else if (strVariable.CompareTo("Enable Hack Cry Responder?") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
{
enableHackCry = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
}
else if (strVariable.CompareTo("Hack Cry Trigger Number") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
hackCriesNeeded = valueAsInt;
}
else if (strVariable.CompareTo("Hack Cry Trigger Response") == 0)
{
if (strValue == "")
hackCryResponse = "Is there a hacker on? Type %vbcommand% <player_name> to initiate a Vote Ban!";
else
hackCryResponse = strValue;
}
else if (strVariable.CompareTo("Additional Triggers") == 0)
{
additionalTriggers = new List<string>(CPluginVariable.DecodeStringArray(strValue));
}
else if (strVariable.CompareTo("In-Game Names") == 0)
{
privilegedUsers = new List<string>(CPluginVariable.DecodeStringArray(strValue));
}
else if (strVariable.CompareTo("Clan Tags") == 0)
{
privilegedTags = new List<string>(CPluginVariable.DecodeStringArray(strValue));
}
else if (strVariable.CompareTo("Action Taken") == 0)
{
whitelistActionTaken = strValue;
}
else if (strVariable.CompareTo("Temporary Ban Length (in minutes)") == 0)
{
int valueAsInt;
int.TryParse(strValue, out valueAsInt);
whitelistBanLength = valueAsInt;
}
else if (strVariable.CompareTo("Vote Ban Commands") == 0)
{
banCommand = new List<string>(CPluginVariable.DecodeStringArray(strValue));
if (banCommand.Count == 1 && banCommand[0] == "")
{
banCommand[0] = "!voteban";
banCommand.Add("@voteban");
}
}
else if (strVariable.CompareTo("Vote Kick Commands") == 0)
{
kickCommand = new List<string>(CPluginVariable.DecodeStringArray(strValue));
if (kickCommand.Count == 1 && kickCommand[0] == "")
{
kickCommand[0] = "!votekick";
kickCommand.Add("@votekick");
}
}
else if (strVariable.CompareTo("Yes Commands") == 0)
{
yesCommand = new List<string>(CPluginVariable.DecodeStringArray(strValue));
if (yesCommand.Count == 1 && yesCommand[0] == "")
{
yesCommand[0] = "!yes";
kickCommand.Add("@yes");
}
}
else if (strVariable.CompareTo("No Commands") == 0)
{
noCommand = new List<string>(CPluginVariable.DecodeStringArray(strValue));
if (noCommand.Count == 1 && noCommand[0] == "")
{
noCommand[0] = "!no";
noCommand.Add("@no");
}
}
else if (strVariable.CompareTo("Cancel Vote Commands") == 0)
{
cancelVoteCommand = new List<string>(CPluginVariable.DecodeStringArray(strValue));
if (cancelVoteCommand.Count == 1 && cancelVoteCommand[0] == "")
{
cancelVoteCommand[0] = "!cancelvote";
cancelVoteCommand.Add("@cancelvote");
}
}
else if (strVariable.CompareTo("Reset Messages?") == 0)
{
if (strValue == "Do it!")
{
inGameMessages.Clear();
initInGameMessages();
this.ExecuteCommand("procon.protected.pluginconsole.write", "^3^b[Vote Ban] ^n^0Message list reset to default!");
}
}
else if (strVariable.CompareTo("Message List") == 0)
{
inGameMessages = new List<string>(CPluginVariable.DecodeStringArray(strValue));
///// Adding messages to Message List. (version 1.3.0 - 1.5.0) /////
if (!(inGameMessages.Count >= 79))
{
inGameMessages.Add("---------- %1% = voter %2% = Vote Ban player count threshold ----------");
inGameMessages.Add("say \"Vote Ban is currently disabled! There must be at least %2% players for Vote Ban to be enabled.\" all");
inGameMessages.Add("---------- %1% = voter %2% = Vote Kick player count threshold ----------");
inGameMessages.Add("say \"Vote Kick is currently disabled! There must be at least %2% players for Vote Kick to be enabled.\" all");
}
}
}
private void initInGameMessages()
{
inGameMessages.Add("///// Here, you can modify each message that this plugin sends /////");
inGameMessages.Add("///// to the server. Keep each message here on their current line. /////");
inGameMessages.Add("///// Format is crucial so please try not to violate the rules of /////");
inGameMessages.Add("///// the following format including spaces... If you do, your /////");
inGameMessages.Add("///// message won't appear. If needed, you can reset everything /////");
inGameMessages.Add("///// here back to default with the \"Reset Messages?\" option. /////");
inGameMessages.Add("//////////////////////////////////////////////////////////////////////");
inGameMessages.Add("///// Format: messagetype \"message\" directive seconds(yell only) /////");
inGameMessages.Add("///// messagetype = 'say' or 'yell' /////");
inGameMessages.Add("///// message = your message (in quotes) /////");
inGameMessages.Add("///// directive = 'all' or 'player' (sends to relevant player) /////"); // 10
inGameMessages.Add("///// seconds = number of seconds for yell message type to stay up /////");
inGameMessages.Add("/////////////////////////////////////////////////////////////////////");
inGameMessages.Add("/////////////////////////////////////////////////////////////////////");
inGameMessages.Add("---------- %1% = voted player %2% = suggested name %3% = yes command %4% = no command ----------");
inGameMessages.Add("say \"Player %1% does not exist. Did you mean %2%? Type %3% or %4%...\" player");
inGameMessages.Add("---------- %1% = voter %2% = vote type %3% = voted player ----------");
inGameMessages.Add("say \"Player %1% has been killed as a result of attempting a vote to %2% immune player %3%!\" all");
inGameMessages.Add("say \"Player %1% has been kicked as a result of attempting a vote to %2% immune player %3%!\" all");
inGameMessages.Add("say \"Player %1% has been banned as a result of attempting a vote to %2% immune player %3%!\" all");
inGameMessages.Add("---------- %1% = voted player ----------"); // 20
inGameMessages.Add("----- WARNING! No relevant player for 'player' directive -----");
inGameMessages.Add("yell \"The vote to ban %1% has expired!\" all");
inGameMessages.Add("yell \"The vote to kick %1% has expired!\" all");
inGameMessages.Add("---------- %1% = yes votes %2% = no votes ----------");
inGameMessages.Add("----- WARNING! No relevant player for 'player' directive -----");
inGameMessages.Add("----- WARNING! Don't set this next message AND the previous 2 messages to yell as they happen simultaneously! -----");
inGameMessages.Add("say \"The summary of the vote was - Yes Votes: %1% No Votes: %2%\" all");
inGameMessages.Add("say \"Vote Progress - Yes Votes: %1% No Votes: %2%\" all");
inGameMessages.Add("---------- %1% = remaining yes votes needed %2% = vote type (kick or ban) %3% = voted player ----------");
inGameMessages.Add("----- WARNING! No relevant player for 'player' directive -----"); // 30
inGameMessages.Add("----- WARNING! Don't set this next message AND the previous message to yell as they happen simultaneously! -----");
inGameMessages.Add("say \"%1% more Yes votes needed to %2% %3% ...\" all");
inGameMessages.Add("---------- %1% = admin canceling vote %2% = vote type (kick or ban) %3% = voted player ----------");
inGameMessages.Add("----- WARNING! No relevant player for 'player' directive -----");
inGameMessages.Add("yell \"%1% has canceled the vote to %2% %3%!\" all"); // 35
inGameMessages.Add("---------- %1% = voted player %2% = reason for vote ban ----------");
inGameMessages.Add("----- WARNING! No relevant player for 'player' directive -----");
inGameMessages.Add("yell \"Vote Ban successful! Banning %1% for %2%...\" all");
inGameMessages.Add("---------- %1% = voted player ----------");
inGameMessages.Add("----- WARNING! No relevant player for 'player' directive -----"); // 40
inGameMessages.Add("yell \"Vote Kick successful! Kicking %1%...\" all");
inGameMessages.Add("---------- %1% = voter ----------");
inGameMessages.Add("say \"Your vote has been registered as YES!\" player");
inGameMessages.Add("say \"Your vote has been registered as NO!\" player");
inGameMessages.Add("say \"%1% has already voted!\" all");
inGameMessages.Add("---------- %1% = ban command %2% = kick command %3% = voter ----------");
inGameMessages.Add("say \"There is no vote in progress! Type %1% <player_name> or %2% <player_name> to put in a request.\" player");
inGameMessages.Add("---------- %1% = voted player %2% = yes command %3% = no command %4% = reason for vote ban ----------");
inGameMessages.Add("----- WARNING! No relevant player for 'player' directive -----");
inGameMessages.Add("yell \"The vote to ban %1% for \"%4%\" has COMMENCED! Type %2% or %3% in chat to vote!\" all 30"); // 50
inGameMessages.Add("---------- %1% = voted player %2% = yes command %3% = no command ----------");
inGameMessages.Add("----- WARNING! No relevant player for 'player' directive -----");
inGameMessages.Add("yell \"The vote to kick %1% has COMMENCED! Type %2% or %3% in chat to vote!\" all 30");
inGameMessages.Add("---------- %1% = voter %2% = vote ban command %3% = voted player %4% = remaining votes needed ----------");
inGameMessages.Add("say \"%1% has put in a %2% request to initiate a Vote Ban on %3%! %4% more needed!\" all");
inGameMessages.Add("---------- %1% = voter %2% = voted player ----------");
inGameMessages.Add("say \"%1% has ALREADY put in a request to initiate a Vote Ban on %2%!\" all");
inGameMessages.Add("---------- %1% = voter %2% = vote kick command %3% = voted player %4% = remaining votes needed ----------");
inGameMessages.Add("say \"%1% has put in a %2% request to initiate a Vote Kick on %3%! %4% more needed!\" all");
inGameMessages.Add("---------- %1% = voter %2% = voted player ----------"); // 60
inGameMessages.Add("say \"%1% has ALREADY put in a request to initiate a Vote Kick on %2%!\" all");
inGameMessages.Add("---------- %1% = voter ----------");
inGameMessages.Add("say \"%1% - A vote is already in progress...\" all");
inGameMessages.Add("---------- %1% = yes command %2% = no command %3% = voter ----------");
inGameMessages.Add("say \"%3% - Awaiting %1% or %2% confirmation on your last Vote Ban suggested player name!\" player");
inGameMessages.Add("say \"%3% - Awaiting %1% or %2% confirmation on your last Vote Kick suggested player name!\" player");
inGameMessages.Add("---------- %1% = voter %2% = voted player ----------");
inGameMessages.Add("say \"%1% - Player %2% is protected from being Vote Banned!\" all");
inGameMessages.Add("---------- %1% = voter %2% = vote ban command ----------");
inGameMessages.Add("say \"%1% - The first %2% request must include the reason... %2% <player_name> <reason>\" all"); // 70
inGameMessages.Add("---------- %1% = voter -----");
inGameMessages.Add("say \"%1% - You have declined the suggested player name...\" player");
inGameMessages.Add("---------- %1% = voter %2% = voted player ----------");
inGameMessages.Add("say \"%1% - Player %2% is protected from being Vote Kicked!\" all");
inGameMessages.Add("---------- %1% = player canceling vote ----------");
inGameMessages.Add("say \"%1% - You do not have the priveleges to cancel a vote!\" all");
inGameMessages.Add("say \"%1% - There is no vote in progress to cancel!\" player");
inGameMessages.Add("---------- %1% = voter %2% = Vote Ban player count threshold ----------");
inGameMessages.Add("say \"Vote Ban is currently disabled! There must be at least %2% players for Vote Ban to be enabled.\" all");
inGameMessages.Add("---------- %1% = voter %2% = Vote Kick player count threshold ----------"); // 80
inGameMessages.Add("say \"Vote Kick is currently disabled! There must be at least %2% players for Vote Kick to be enabled.\" all");
}
private void processMessage(int messageLine, params object[] items)
{
int messageStartIndex = 0;
int messageEndIndex = 0;
for (int i = 0; i < inGameMessages[messageLine].Length; i++)
{
if (inGameMessages[messageLine][i] == '"')
{
if (messageStartIndex == 0)
messageStartIndex = i;
else
messageEndIndex = i;
}
}
string message = inGameMessages[messageLine].Substring(messageStartIndex + 1, messageEndIndex - messageStartIndex - 1);
for (int i = 1; i < items.Length; i++)
{
message = message.Replace("%" + i.ToString() + "%", items[i].ToString());
}
string paramaters = inGameMessages[messageLine].Remove(messageStartIndex, messageEndIndex - messageStartIndex + 2);
string[] paramatersAsArray = paramaters.Split(' ');
if (paramatersAsArray[0] == "say")
{
if (paramatersAsArray[1] == "player")
this.ExecuteCommand("procon.protected.send", "admin.say", message, "player", items[0].ToString());
else if (paramatersAsArray[1] == "all")
this.ExecuteCommand("procon.protected.send", "admin.say", message, "all");
}
else if (paramatersAsArray[0] == "yell")
{
if (paramatersAsArray[1] == "player")
{
if (paramatersAsArray.Length >= 3)
this.ExecuteCommand("procon.protected.send", "admin.yell", message, paramatersAsArray[2], "player", items[0].ToString());
else
this.ExecuteCommand("procon.protected.send", "admin.yell", message, "10", "player", items[0].ToString());
}
else if (paramatersAsArray[1] == "all")
{
if (paramatersAsArray.Length >= 3)
this.ExecuteCommand("procon.protected.send", "admin.yell", message, paramatersAsArray[2]);
else
this.ExecuteCommand("procon.protected.send", "admin.yell", message);
}
}
}
private void getPlayerCount()
{
needPlayerCount = true;
this.ExecuteCommand("procon.protected.send", "admin.listPlayers", "all");
}
private string getSuggestedPlayerName(List<CPlayerInfo> player, string currentVotedPlayer, ref bool forcePlayer)
{
string suggestedName = player[0].SoldierName; // suggested player name initialized with the first player in the list
List<string> transformedPlayerNames = new List<string>();
string transformedCurrentVotedPlayer;
List<int> votedProbability = new List<int>(); // paired against List of current players for number highest probability with greatest number
int highestProbabilityNumber = 0; // used and assigned to determine which element in votedProbability list is highest
transformedCurrentVotedPlayer = currentVotedPlayer.Replace('I', 'l');
transformedCurrentVotedPlayer = transformedCurrentVotedPlayer.ToLower();
for (int i = 0; i < player.Count; i++)
transformedPlayerNames.Add(player[i].SoldierName);
for (int i = 0; i < transformedPlayerNames.Count; i++)
{
transformedPlayerNames[i] = transformedPlayerNames[i].Replace('I', 'l');
transformedPlayerNames[i] = transformedPlayerNames[i].ToLower();
}
// if currentVotedPlayer matches a substring of a player from the player list, use that player (return that player string) and skip everything else
for (int i = 0; i < transformedPlayerNames.Count; i++)
{
if (transformedPlayerNames[i].Contains(transformedCurrentVotedPlayer))
{
forcePlayer = true;
return player[i].SoldierName;
}
}
// initializes votedProbability List to be of proportional size to players List
for (int i = 0; i < transformedPlayerNames.Count; i++)
votedProbability.Add(0);
for (int indexStart = 0; indexStart < transformedCurrentVotedPlayer.Length - 1; indexStart++)
{
for (int currSubStrSize = 1; currSubStrSize <= transformedCurrentVotedPlayer.Length - indexStart; currSubStrSize++)
{
for (int i = 0; i < transformedPlayerNames.Count; i++)
{
if (transformedPlayerNames[i].Contains(transformedCurrentVotedPlayer.Substring(indexStart, currSubStrSize)))
{
if (votedProbability[i] < currSubStrSize)
votedProbability[i] = currSubStrSize;
}
}
}
}
for (int i = 0; i < transformedPlayerNames.Count; i++)
{
if (votedProbability[i] > highestProbabilityNumber)
highestProbabilityNumber = votedProbability[i];
}
// takes player from List proportional to first instance (could be multiple of the same highest number) in votedProbability List with the the highest number
for (int i = 0; i < votedProbability.Count; i++)
{
if (votedProbability[i] == highestProbabilityNumber)
suggestedName = player[i].SoldierName;
}
processMessage(15, currentSpeaker, currentVotedPlayer, suggestedName, yesCommand[0], noCommand[0]);
return suggestedName;
}
private void storeVotedVictimInfo()
{
needVotedVictimInfo = true;
if (banType == "GUID")
this.ExecuteCommand("procon.protected.send", "admin.listPlayers", "all");
else
this.ExecuteCommand("procon.protected.send", "punkBuster.pb_sv_command pb_sv_plist");
}
private void banPlayerByName()
{
banningPlayerByName = true;
this.ExecuteCommand("procon.protected.send", "admin.listPlayers", "all");
}
private void banPlayerByGuid()
{
foundvotedVictim = false;
banningPlayerByGUID = true;
this.ExecuteCommand("procon.protected.send", "admin.listPlayers", "all");
}
private void banPlayerByIp()
{
foundvotedVictim = false;
banningPlayerByIP = true;
this.ExecuteCommand("procon.protected.send", "punkBuster.pb_sv_command pb_sv_plist");
}
private void banPlayerByPbGuid()
{
foundvotedVictim = false;
banningPlayerByPbGuid = true;
this.ExecuteCommand("procon.protected.send", "punkBuster.pb_sv_command pb_sv_plist");
}
private void kickPlayer()
{
kickingPlayer = true;
this.ExecuteCommand("procon.protected.send", "admin.listPlayers", "all");
}
private void processVote(string speaker, string playerVoted, string voteType)
{
processingVote = true;
currentSpeaker = speaker;
currentVotedPlayer = playerVoted;
currentVoteType = voteType;
if (voteType == "ban")
currentVoteReason = voteReason;
this.ExecuteCommand("procon.protected.send", "admin.listPlayers", "all");
}
private void processVote(string speaker, string playerVoted, string voteType, string voteReason)
{
processingVote = true;
currentSpeaker = speaker;
currentVotedPlayer = playerVoted;
currentVoteType = voteType;
if (voteType == "ban")
currentVoteReason = voteReason;
this.ExecuteCommand("procon.protected.send", "admin.listPlayers", "all");
}
private void whitelistActionHandler(string speaker, string votedPlayer)
{
if (whitelistActionTaken == "Kill")
{
this.ExecuteCommand("procon.protected.send", "admin.killPlayer", speaker);
processMessage(17, speaker, speaker, currentVoteType, votedPlayer);
}
else if (whitelistActionTaken == "Kick")
{
this.ExecuteCommand("procon.protected.send", "admin.kickPlayer", speaker, "Kicked for attempting a vote to " + currentVoteType + " immune player " + votedPlayer + "!");
processMessage(18, speaker, speaker, currentVoteType, votedPlayer);
}
else if (whitelistActionTaken == "Temporarily Ban")
{
this.ExecuteCommand("procon.protected.send", "banList.add", "name", speaker, "seconds", (whitelistBanLength * 60).ToString(), "Banned for attempting a vote to " + currentVoteType + " immune player " + votedPlayer + "!");
processMessage(19, speaker, speaker, currentVoteType, votedPlayer);
this.ExecuteCommand("procon.protected.send", "banList.save");
this.ExecuteCommand("procon.protected.send", "banList.list");
}
else if (whitelistActionTaken == "Permanently Ban")
{
this.ExecuteCommand("procon.protected.send", "banList.add", "name", speaker, "perm", "Banned for attempting a vote to " + currentVoteType + " immune player " + votedPlayer + "!");
processMessage(19, speaker, speaker, currentVoteType, votedPlayer);
this.ExecuteCommand("procon.protected.send", "banList.save");
this.ExecuteCommand("procon.protected.send", "banList.list");
}
}
private bool hasTriggerWord(string message)
{
// Don't trigger if trigger word is in a voteban or votekick reason
if (isVoteBan(message) || isVoteKick(message))
return false;
if (message.Contains("hack"))
return true;
for (int i = 0; i < additionalTriggers.Count; i++)
if (message.Contains(additionalTriggers[i].ToLower()))
return true;
return false;
}
private bool isAdmin(string speaker)
{
bool isAdmin = false;
currentPrivileges = GetAccountPrivileges(speaker);
if (currentPrivileges != null)
{
if (currentPrivileges.CanLogin)
isAdmin = true;
}
return isAdmin;
}
private bool isImmunePlayer(string votedPlayer)
{
currentPrivileges = GetAccountPrivileges(votedPlayer);
if (currentPrivileges != null)
{
if (currentPrivileges.CanLogin)
return true;
}
if (privilegedUsers.Contains(votedPlayer))
{
return true;
}
if (privilegedTags.Count >= 1 && privilegedTags[0] != "")
{
this.blClient = new BattlelogClient();
if (privilegedTags.Contains(this.blClient.getClanTag(votedPlayer)))
{
return true;
}
}
return false;
}
private bool isVoteBan(string message)
{
for (int i = 0; i < banCommand.Count; i++)
{
if (message.StartsWith(banCommand[i]))
return true;
}
return false;
}
private bool isVoteKick(string message)
{
for (int i = 0; i < kickCommand.Count; i++)
{
if (message.StartsWith(kickCommand[i]))
return true;
}
return false;
}