source: binary-improvements/7dtd-server-fixes/src/TelnetCommands/ListItems.cs@ 128

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

Fixes

File size: 882 bytes
RevLine 
[128]1using System;
2using System.Collections.Generic;
3
4public class ListItems : ConsoleCommand
5{
6 public ListItems (ConsoleSdtd cons) : base(cons)
7 {
8 }
9
10 public override string Description ()
11 {
12 return "lists all items that contain the given substring";
13 }
14
15 public override string[] Names ()
16 {
17 return new string[] { "listitems", "li" };
18 }
19
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;
26 }
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 }
40 }
41}
42
Note: See TracBrowser for help on using the repository browser.