source: binary-improvements/7dtd-server-fixes/src/CustomCommands/ListItems.cs@ 210

Last change on this file since 210 was 197, checked in by alloc, 10 years ago

fixes

File size: 940 bytes
RevLine 
[128]1using System;
2using System.Collections.Generic;
3
[130]4namespace AllocsFixes.CustomCommands
[128]5{
[130]6 public class ListItems : ConsoleCommand
[128]7 {
[130]8 public ListItems (ConsoleSdtd cons) : base(cons)
9 {
10 }
[128]11
[130]12 public override string Description ()
13 {
14 return "lists all items that contain the given substring";
15 }
[128]16
[130]17 public override string[] Names ()
18 {
19 return new string[] { "listitems", "li" };
20 }
[128]21
[130]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 }
[128]29
[130]30 int n = 0;
[197]31 foreach (string s in ItemList.Instance.ItemNames) {
32 if (s.ToLower ().Contains (_params [0].ToLower ())) {
33 m_Console.SendResult (" " + s);
[130]34 n++;
35 }
[128]36 }
[130]37
38 m_Console.SendResult ("Listed " + n + " matching items.");
39 } catch (Exception e) {
40 Log.Out ("Error in ListItems.Run: " + e);
[128]41 }
42 }
43 }
44}
Note: See TracBrowser for help on using the repository browser.