source: binary-improvements/CoppisAdditions/src/Commands/MutePlayerChat.cs@ 290

Last change on this file since 290 was 273, checked in by alloc, 9 years ago

fixes 8_10_13_1

File size: 2.0 KB
RevLine 
[273]1using System;
2using System.Collections.Generic;
3using AllocsFixes.PersistentData;
4using System.Threading;
5using UnityEngine;
6
7namespace CoppisAdditions.CustomCommands
8{
9 public class MutePlayerChat : ConsoleCmdAbstract
10 {
11 public override string GetDescription ()
12 {
13 return "mute a player on public chat";
14 }
15
16 public override string GetHelp ()
17 {
18 return "Mute a player on public chat." +
19 "Usage:\n" +
20 " mpc <steam id/player name/entity id> [true/false]\n" +
21 "If the optional parameter is not given the command will show the current status.";
22 }
23
24 public override string[] GetCommands ()
25 {
26 return new string[] { "muteplayerchat", "mpc" };
27 }
28
29 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
30 {
31 try {
32 if (_params.Count < 1 || _params.Count > 2) {
33 SdtdConsole.Instance.Output ("Wrong number of arguments, expected 1 or 2, found " + _params.Count + ".");
34 SdtdConsole.Instance.Output (" ");
35 SdtdConsole.Instance.Output (GetHelp ());
36 return;
37 }
38
39 string steamid = PersistentContainer.Instance.Players.GetSteamID (_params [0], true);
40 if (steamid == null) {
41 SdtdConsole.Instance.Output ("Playername or entity/steamid id not found.");
42 return;
43 }
44
45 Player p = PersistentContainer.Instance.Players [steamid, false];
46 if (p == null) {
47 SdtdConsole.Instance.Output ("Player not found.");
48 return;
49 }
50
51 if (_params.Count > 1) {
52 bool mute = false;
53 if (_params [1].ToLower () == "true") {
54 mute = true;
55 } else if (_params [1].ToLower () == "false") {
56 mute = false;
57 } else {
58 SdtdConsole.Instance.Output ("Wrong param 2. It must be \"true\" or \"false\"");
59 return;
60 }
61 p.IsChatMuted = mute;
62 }
63 SdtdConsole.Instance.Output (p.Name + " " + (p.IsChatMuted ? "muted" : "unmuted"));
64
65 } catch (Exception e) {
66 Log.Out ("Error in MutePlayerChat: " + e);
67 }
68 }
69 }
70}
Note: See TracBrowser for help on using the repository browser.