Full Version : puting items in a box
xmlspawner >>Scripting Support >>puting items in a box


<< Prev | Next >>

ozzy- 01-13-2007
Here is a diff script Im workin on. I think Im missing a using directive, but i may have just coded it wrong. here is the script.

CODE

using System;
using Server;
using Server.Items;

namespace Server.Items
{
public class TreasureChestOfOzzyStuff : Container
{

    public override int DefaultGumpID{ get{ return 0x42; } }
 public override int DefaultDropSound{ get{ return 0x42; } }

 public override Rectangle2D Bounds
 {
  get{ return new Rectangle2D( 20, 105, 150, 180 ); }
 }
 
 [Constructable]
 public TreasureChestOfOzzyStuff() : base( 0xE41 )
 {
  Name = "Treasure Chest Of Ozzy's Stuff";
  Hue = 1266;
  PlaceItemIn( cont, 16, 51, new TreasureChestOfOzzyArmor() );
  PlaceItemIn( cont, 28, 51, new TreasureChestOfOzzyWeaponsandShields() );
 }

 public TreasureChestOfOzzyStuff( Serial serial ) : base( serial )
 {
 }

 public override void Serialize( GenericWriter writer )
 {
  base.Serialize( writer );

  writer.Write( (int) 0 ); // version
 }

 public override void Deserialize( GenericReader reader )
 {
  base.Deserialize( reader );

  int version = reader.ReadInt();
 }
}
}



Here is the error i come up with.

CODE

- Error: Scripts\New Stuff\TreasureChestOfOzzyStuff.cs: CS0103: (line 24, colum
n 17) The name 'cont' does not exist in the class or namespace 'Server.Items.Tre
asureChestOfOzzyStuff'
- Error: Scripts\New Stuff\TreasureChestOfOzzyStuff.cs: CS0103: (line 24, colum
n 4) The name 'PlaceItemIn' does not exist in the class or namespace 'Server.Ite
ms.TreasureChestOfOzzyStuff'
- Error: Scripts\New Stuff\TreasureChestOfOzzyStuff.cs: CS0103: (line 25, colum
n 17) The name 'cont' does not exist in the class or namespace 'Server.Items.Tre
asureChestOfOzzyStuff'
- Error: Scripts\New Stuff\TreasureChestOfOzzyStuff.cs: CS0103: (line 25, colum
n 4) The name 'PlaceItemIn' does not exist in the class or namespace 'Server.Ite
ms.TreasureChestOfOzzyStuff'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.




ozzy- 01-13-2007
I Changed this.

CODE

PlaceItemIn( cont, 16, 51, new TreasureChestOfOzzyArmor() );
PlaceItemIn( cont, 28, 51, new TreasureChestOfOzzyWeaponsandShields() );
[CODE]


To this.


PlaceItemIn( this, 16, 51, new TreasureChestOfOzzyArmor() );
PlaceItemIn( this, 28, 51, new TreasureChestOfOzzyWeaponsandShields() );
CODE



Then added this.


using Server.Misc;
CODE



I still get these 2 errors thow.


- Error: Scripts\New Stuff\TreasureChestOfOzzyStuff.cs: CS0103: (line 25, colum
n 4) The name 'PlaceItemIn' does not exist in the class or namespace 'Server.Ite
ms.TreasureChestOfOzzyStuff'
- Error: Scripts\New Stuff\TreasureChestOfOzzyStuff.cs: CS0103: (line 26, colum
n 4) The name 'PlaceItemIn' does not exist in the class or namespace 'Server.Ite
ms.TreasureChestOfOzzyStuff'
[CODE]

What am i missing here?

ozzy- 01-13-2007
I changed it some more so It looks like this now.

CODE

//=========================Created By Ozzy===================================//
using System;
using Server;
using Server.Gumps;
using Server.Items;

namespace Server.Items
{
public class TreasureChestOfOzzyStuff : Container
{

    public override int DefaultGumpID{ get{ return 0x42; } }
 public override int DefaultDropSound{ get{ return 0x42; } }

 public override Rectangle2D Bounds
 {
  get{ return new Rectangle2D( 20, 105, 150, 180 ); }
 }
 
 [Constructable]
 public TreasureChestOfOzzyStuff() : base( 0xE41 )
 {
  Name = "Treasure Chest Of Ozzy's Stuff";
  Container cont;
  Hue = 1266;
  this( cont, 16, 51, new TreasureChestOfOzzyArmor() );
  this( cont, 28, 51, new TreasureChestOfOzzyWeaponsandShields() );
 }

 public TreasureChestOfOzzyStuff( Serial serial ) : base( serial )
 {
 }

 public override void Serialize( GenericWriter writer )
 {
  base.Serialize( writer );

  writer.Write( (int) 0 ); // version
 }

 public override void Deserialize( GenericReader reader )
 {
  base.Deserialize( reader );

  int version = reader.ReadInt();
 }
}
}


and I get these errors

CODE

- Error: Scripts\New Stuff\TreasureChestOfOzzyStuff.cs: CS0149: (line 31, colum
n 4) Method name expected
- Error: Scripts\New Stuff\TreasureChestOfOzzyStuff.cs: CS0149: (line 32, colum
n 4) Method name expected


What am I doing wrong here?

ArteGordon- 01-13-2007
this is not valid code

CODE

 Container cont;
 Hue = 1266;
 this( cont, 16, 51, new TreasureChestOfOzzyArmor() );
 this( cont, 28, 51, new TreasureChestOfOzzyWeaponsandShields() );


You just need to use the AddItem method to add your items to your container.

CODE

Item armor = new TreasureChestOfOzzyArmor();
AddItem(armor);
armor.Location = new Point3D(16, 51, 0);

Item shield = new TreasureChestOfOzzyWeaponsandShields();
AddItem(shield );
shield .Location = new Point3D(28, 51, 0);


ozzy- 01-15-2007
I figured out hot to switch it over to 2d instead of 3d and it worked pretty well. Here is what I did.

CODE

private static void PlaceItemIn( Container parent, int x, int y, Item item )
 {
  parent.AddItem( item );
  item.Location = new Point3D( x, y, 0 );
 }
 
 [Constructable]
 public TreasureChestOfOzzysStuff() : base( 0xE41 )
 {
  Name = "Treasure Chest Of Ozzy's Stuff";
  Hue = 0;
  PlaceItemIn( this, 20, 105, new PouchOfOzzysPlateArmor() );
  PlaceItemIn( this, 35, 105, new PouchOfOzzysChainArmor() );
  PlaceItemIn( this, 50, 105, new PouchOfOzzysRingArmor() );
                }



Thanks for the help, im learning alot doing all this stuff lol.