- Timestamp:
- Aug 26, 2014, 4:41:47 PM (10 years ago)
- Location:
- binary-improvements/7dtd-server-fixes/src/CustomCommands
- Files:
-
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/CustomCommands/ListItems.cs
r128 r130 2 2 using System.Collections.Generic; 3 3 4 public class ListItems : ConsoleCommand 4 namespace AllocsFixes.CustomCommands 5 5 { 6 public ListItems (ConsoleSdtd cons) : base(cons)6 public class ListItems : ConsoleCommand 7 7 { 8 } 8 public ListItems (ConsoleSdtd cons) : base(cons) 9 { 10 } 9 11 10 public override string Description ()11 {12 return "lists all items that contain the given substring";13 }12 public override string Description () 13 { 14 return "lists all items that contain the given substring"; 15 } 14 16 15 public override string[] Names ()16 {17 return new string[] { "listitems", "li" };18 }17 public override string[] Names () 18 { 19 return new string[] { "listitems", "li" }; 20 } 19 21 20 public override void Run (string[] _params) 21 { 22 try { 23 if (_params.Length != 1 || _params[0].Length == 0) { 24 m_Console.SendResult ("Usage: listitems <searchString>"); 25 return; 22 public override void Run (string[] _params) 23 { 24 try { 25 if (_params.Length != 1 || _params [0].Length == 0) { 26 m_Console.SendResult ("Usage: listitems <searchString>"); 27 return; 28 } 29 30 int n = 0; 31 foreach (ItemBase ib in ItemBase.list) { 32 if (ib.name != null && ib.name.ToLower ().Contains (_params [0].ToLower ())) { 33 m_Console.SendResult (" " + ib.name); 34 n++; 35 } 36 } 37 38 m_Console.SendResult ("Listed " + n + " matching items."); 39 } catch (Exception e) { 40 Log.Out ("Error in ListItems.Run: " + e); 26 41 } 27 28 int n = 0;29 foreach (ItemBase ib in ItemBase.list) {30 if (ib.name != null && ib.name.ToLower().Contains(_params[0].ToLower())) {31 m_Console.SendResult (" " + ib.name);32 n++;33 }34 }35 36 m_Console.SendResult ("Listed " + n + " matching items.");37 } catch (Exception e) {38 Log.Out ("Error in ListItems.Run: " + e);39 42 } 40 43 } 41 44 } 42
Note:
See TracChangeset
for help on using the changeset viewer.