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

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

Fixes

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