Full Version : GingerBreadHouseAddon Question
xmlspawner >>Scripting Support >>GingerBreadHouseAddon Question
<< Prev | Next >>
Erica- 11-16-2007
Hi ArteGordon was wondering if theres a way that whenyou add this house from the deed that when you click on house it would say the name cause i added the name part of it but when its added from the deed and you click on it wont say the name Gingerbread House heres the script.

CODE
using System; using Server; using Server.Items; namespace Server.Items {
public class GingerbreadHouseAddon : BaseAddon
{
public override BaseAddonDeed Deed
{
get
{
return new GingerbreadHouseAddonDeed();
}
}
[ Constructable ]
public GingerbreadHouseAddon()
{
Name = "Gingerbread House";
AddComponent( new AddonComponent( 11237 ), 0, 1, 0 );
AddComponent( new AddonComponent( 11238 ), 1, 1, 0 );
AddComponent( new AddonComponent( 11239 ), 1, 0, 0 );
}
public GingerbreadHouseAddon( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 ); // Version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
public class GingerbreadHouseAddonDeed : BaseAddonDeed
{
public override BaseAddon Addon
{
get
{
return new GingerbreadHouseAddon();
}
}
[Constructable]
public GingerbreadHouseAddonDeed()
{
Name = "A Gingerbread House Deed";
LootType = LootType.Blessed;
}
public GingerbreadHouseAddonDeed( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 ); // Version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
}

ArteGordon- 11-20-2007
The issue is that when you click on it, you are actually clicking on the addoncomponents, and those do not have names.
You can name each component when you add it.

CODE
[ Constructable ] public GingerbreadHouseAddon() { Name = "Gingerbread House"; AddonComponent c = new AddonComponent( 11237 );
c.Name = Name;
AddComponent( c, 0, 1, 0 );
c = new AddonComponent( 11238 );
c.Name = Name;
AddComponent( c, 1, 1, 0 );
c = new AddonComponent( 11239 );
c.Name = Name;
AddComponent( c, 1, 0, 0 );
}

or add a method to do that for you, like this

CODE
private AddonComponent NamedComponent(int itemID, string name) { AddonComponent c = new AddonComponent( itemID); c.Name = name; return c;
}
[ Constructable ]
public GingerbreadHouseAddon()
{
Name = "Gingerbread House";
AddComponent( NamedComponent(11237, Name), 0, 1, 0 );
AddComponent( NamedComponent(11238, Name), 1, 1, 0 );
AddComponent( NamedComponent(11239, Name), 1, 0, 0 );
}