source: binary-improvements/CoppisAdditions/src/Commands/PlayerChatMaxLength.cs@ 293

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

fixes 8_10_13_1

File size: 1.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using AllocsFixes.PersistentData;
4using System.Threading;
5using UnityEngine;
6
7namespace CoppisAdditions.CustomCommands
8{
9 public class PlayerChatMaxLength : ConsoleCmdAbstract
10 {
11 public override string GetDescription ()
12 {
13 return "set the maximum number of characters a player can write in a single message";
14 }
15
16 public override string GetHelp ()
17 {
18 return "Set the maximum number of characters a player can write in a single message." +
19 "Usage:\n" +
20 " pcml <steam id/player name/entity id> <chat length>\n";
21 }
22
23 public override string[] GetCommands ()
24 {
25 return new string[] { "playerchatmaxlength", "pcml" };
26 }
27
28 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
29 {
30 try {
31 if (_params.Count != 2) {
32 SdtdConsole.Instance.Output ("Wrong number of arguments, expected 2, found " + _params.Count + ".");
33 SdtdConsole.Instance.Output (" ");
34 SdtdConsole.Instance.Output (GetHelp ());
35 return;
36 }
37
38 string steamid = PersistentContainer.Instance.Players.GetSteamID (_params [0], true);
39 if (steamid == null) {
40 SdtdConsole.Instance.Output ("Playername or entity/steamid id not found.");
41 return;
42 }
43
44 int maxLen = int.MinValue;
45 int.TryParse (_params [1], out maxLen);
46
47 if (maxLen == int.MinValue || maxLen < 1) {
48 SdtdConsole.Instance.Output ("the parameter \"chat length\" must be an integer equal or greater than 1");
49 return;
50 }
51
52
53 Player p = PersistentContainer.Instance.Players [steamid, false];
54 if (p != null) {
55 p.MaxChatLength = maxLen;
56 SdtdConsole.Instance.Output (p.Name + ": max chat length changed to " + maxLen);
57 }
58
59 } catch (Exception e) {
60 Log.Out ("Error in PlayerChatMaxLength: " + e);
61 }
62 }
63 }
64}
Note: See TracBrowser for help on using the repository browser.