CODE |
foreach(XmlData x in alist) { if(x != null && !x.Deleted) { // do what you want } } |
QUOTE (Lord Hog Fred @ October 24, 2006 04:46 pm) |
Ah ok, I thought it would have something to do with an arraylist somewhere. Is there a way to scan for each attribute of the attachment such as the XmlData.Name? |
QUOTE |
public static ArrayList FindAttachments(object o) public static ArrayList FindAttachments(object o, Type type) public static ArrayList FindAttachments(object o, Type type, string name) |
QUOTE (ArteGordon @ October 24, 2006 09:05 pm) | ||||
ArrayList alist = XmlAttach.FindAttachments(from, typeof(XmlData),"thename"); These are the overloaded methods available
|
CODE |
public override void OnDoubleClick( Mobile from ) { ArrayList recipelist = XmlAttach.FindAttachments(from, typeof(XmlRecipe), this.RecipeName, this.RecipeID ); if ( !IsChildOf( from.Backpack ) ) from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it. else { foreach (XmlRecipe xmlrecipe in recipelist) { if (xmlrecipe.Name == this.RecipeName && xmlrecipe.ID == this.RecipeID) { from.SendMessage("You already know this recipe."); } else { XmlAttach.AttachTo( from, new XmlRecipe(this.RecipeName, this.RecipeID) ); from.SendMessage("You learn the recipe."); Delete(); } } } } |
CODE |
//Xml Recipes XmlRecipe xmlrecipe = (XmlRecipe)XmlAttach.FindAttachment(from, typeof(XmlRecipe)); //End //Xml Recipes if( this.Recipe == null || !(from is PlayerMobile) || (xmlrecipe.ID == this.Recipe.ID) || (xmlrecipe.ID == 9999999) ) //End |
CODE |
public override void OnDoubleClick(Mobile from) { if (!IsChildOf(from.Backpack)) from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. else { ArrayList recipelist = XmlAttach.FindAttachments(from, typeof(XmlRecipe), this.RecipeName); bool found = false; foreach (XmlRecipe xmlrecipe in recipelist) { if (xmlrecipe != null && !xmlrecipe.Deleted && xmlrecipe.ID == this.RecipeID) { from.SendMessage("You already know this recipe."); found = true; break; } } if (!found) { XmlAttach.AttachTo(from, new XmlRecipe(this.RecipeName, this.RecipeID)); from.SendMessage("You learn the recipe."); Delete(); } } } |