//the following is taken and modified from Commands.cs from tdsm.core source. Thanks guys!!! ;) public bool highlightsearch(Player player, string nameOrID) { ItemInfo[] itemlist = DefinitionManager.FindItem(nameOrID); if (itemlist != null && itemlist.Length > 0) { if (itemlist.Length > 1) { player.SendMessage("There were " + itemlist.Length + " Items found regarding the specified name"); return(false); } ItemInfo item = itemlist[0]; highlightID = item.NetId; //todo: might be item.Id...... } else { player.SendMessage("There were no Items found regarding the specified Item Id/Name"); return(false); } return(true); }
/// <summary> /// Gives specified item to the specified player. /// </summary> /// <param name="sender">Sending player</param> /// <param name="args">Arguments sent with command</param> public void Give(ISender sender, ArgumentList args) { // /give <stack> <item> [prefix] [player] var index = 0; int stack = args.GetInt(index++); string name = args.GetString(index++); // var max = Tools.AvailableItemSlots; //Perhaps remove a few incase of new drops // if (stack > max) // { // stack = max; // Set to Tools.AvailableItemSlots because number given was larger than this. // } int id; var results = Int32.TryParse(name, out id) ? DefinitionManager.FindItem(id) : DefinitionManager.FindItem(name); if (results != null && results.Length > 0) { if (results.Length > 1) { throw new CommandError(String.Format("More than 1 item found, total is: {0}", results.Length)); } var item = results[0]; string prefix; if (args.TryGetString(index, out prefix)) { try { Affix afx; if (Enum.TryParse(prefix, out afx)) { item.Prefix = (int)afx; index++; } } catch (ArgumentException) { throw new CommandError(String.Format("Error, the Prefix you entered was not found: {0}", args.GetString(3))); } } Player receiver; if (!args.TryGetOnlinePlayer(index, out receiver)) { if (sender is Player) { receiver = sender as Player; } else { throw new CommandError("Expected an online player"); } } receiver.GiveItem(item.Id, stack, item.MaxStack, item.NetId, item.Prefix); } else { throw new CommandError(String.Format("No item known by: {0}", name)); } }