Full Version : Carpet Addons SVN
xmlspawner >>Scripting Support >>Carpet Addons SVN
<< Prev | Next >>
Lord Hog Fred- 01-07-2007
Right well with the latest SVN I got some problems with a couple of carpet addons I got as well.
Errors are:

CODE
+ Custom/Items/Addons/VariableCarpetAddon/CarpetAddonDeed.cs: CS1502: Line 145: The best overloaded method match for 'Server.Items.BaseAdd on.CouldFit(Server.IPoint3D, Server.Map, Server.Mobile, ref Server.Multis.BaseHo use)' has some invalid arguments
CS1503: Line 145: Argument '4': cannot convert from 'ref System.Collections.
Generic.List<Server.Multis.BaseHouse>' to 'ref Server.Multis.BaseHouse'
+ Custom/Items/Addons/VariableCarpetAddon/VariableCarpetAddonDeed.cs:
CS1502: Line 156: The best overloaded method match for 'Server.Items.BaseAdd
on.CouldFit(Server.IPoint3D, Server.Map, Server.Mobile, ref Server.Multis.BaseHo
use)' has some invalid arguments
CS1503: Line 156: Argument '4': cannot convert from 'ref System.Collections.
Generic.List<Server.Multis.BaseHouse>' to 'ref Server.Multis.BaseHouse'

The CarpetDeedAddon:

CODE
using System; using System.Collections; using Server; using Server.Gumps; using Server.Items;
using Server.Network;
using Server.Targeting;
using System.Collections.Generic;
using Server.Multis;
namespace Server.Items
{
public class CarpetAddonDeed : BaseAddonDeed
{
public override BaseAddon Addon{ get{ return null; } }
[Constructable]
public CarpetAddonDeed()
{
Name = "carpet";
}
public CarpetAddonDeed( Serial serial ) : base( serial )
{
}
public override void OnDoubleClick( Mobile from )
{
if ( IsChildOf( from.Backpack ) )
BoundingBoxPicker.Begin( from, new BoundingBoxCallback( BoundingBox_Callback ), null );
else
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
private void BoundingBox_Callback( Mobile from, Map map, Point3D start, Point3D end, object state )
{
IPoint3D p = start as IPoint3D;
if ( p == null || map == null )
return;
int width = (end.X - start.X), height = (end.Y - start.Y);
if ( width < 2 || height < 2 )
from.SendMessage( "The bounding targets must be at least a 3x3 box." );
else if ( IsChildOf( from.Backpack ) )
from.SendGump( new CarpetGump( this, p, map, width, height ) );
else
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
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();
}
}
}
namespace Server.Gumps
{
public class CarpetGump : Gump
{
private const int EntryCount = 3;
private BaseAddonDeed m_Deed;
private IPoint3D m_P3D;
private Map m_Map;
private int m_Width;
private int m_Height;
public CarpetGump( BaseAddonDeed deed, IPoint3D p, Map map, int width, int height ) : base( 30, 30 )
{
m_Deed = deed;
m_P3D = p;
m_Map = map;
m_Width = width;
m_Height = height;
AddPage( 0 );
AddBackground( 0, 0, 450, 180, 9200 );
AddAlphaRegion( 12, 12, 381, 22 );
AddHtml( 13, 13, 379, 20, "<BASEFONT COLOR=WHITE>Choose a carpet type</BASEFONT>", false, false );
AddAlphaRegion( 398, 12, 40, 22 );
AddAlphaRegion( 12, 39, 426, 129 );
AddImage( 400, 16, 9766 );
AddImage( 420, 16, 9762 );
AddPage( 1 );
int page = 1;
for ( int i = 0, index = 0; i < CarpetInfo.Infos.Length; ++i, ++index )
{
if ( index >= EntryCount )
{
if ( (EntryCount * page) == EntryCount )
AddImage( 400, 16, 0x2626 );
AddButton( 420, 16, 0x15E1, 0x15E5, 0, GumpButtonType.Page, page + 1 );
++page;
index = 0;
AddPage( page );
AddButton( 400, 16, 0x15E3, 0x15E7, 0, GumpButtonType.Page, page - 1 );
if ( (CarpetInfo.Infos.Length - (EntryCount * page)) < EntryCount )
AddImage( 420, 16, 0x2622 );
}
CarpetInfo info = CarpetInfo.GetInfo( i );
for ( int j = 0; j < info.Entries.Length; ++j )
AddItem( 20 + (index * 140 ) + info.Entries[j].OffsetX, 46 + info.Entries[j].OffsetY, info.Entries[j].ItemID );
AddButton( 20 + (index * 140 ), 46, 1209, 1210, i+1, GumpButtonType.Reply, 0);
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
if ( info.ButtonID >= 1 )
{
BaseAddon addon = new CarpetAddon( info.ButtonID-1, m_Width, m_Height );
Server.Spells.SpellHelper.GetSurfaceTop( ref m_P3D );
List<BaseHouse> houses = null;
AddonFitResult res = addon.CouldFit( m_P3D, m_Map, from, ref houses );
if ( res == AddonFitResult.Valid )
addon.MoveToWorld( new Point3D( m_P3D ), m_Map );
else if ( res == AddonFitResult.Blocked )
from.SendLocalizedMessage( 500269 ); // You cannot build that there.
else if ( res == AddonFitResult.NotInHouse )
from.SendLocalizedMessage( 500274 ); // You can only place this in a house that you own!
else if ( res == AddonFitResult.DoorsNotClosed )
from.SendMessage( "You must close all house doors before placing this." );
if ( res == AddonFitResult.Valid )
{
m_Deed.Delete();
if ( houses != null )
{
foreach ( Server.Multis.BaseHouse h in houses )
h.Addons.Add( addon );
}
}
else
{
addon.Delete();
}
}
}
}
}

And the Variable Carpet Deed:

CODE
//================================================// // Based on winecrafting grounds created by // // dracana, modded by Manu from Splitterwelt.com // // for use with carpets // // Desc: For players to place carpets in their //
// houses. Especially useful for players //
// with non-custom housing. //
//================================================//
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Items;
using Server.Network;
using Server.Targeting;
using System.Collections.Generic;
using Server.Multis;
namespace Server.Items
{
public class VariableCarpetAddonDeed : BaseAddonDeed
{
public override BaseAddon Addon{ get{ return null; } }
[Constructable]
public VariableCarpetAddonDeed()
{
Name = "Variable Carpet Addon Deed";
}
public VariableCarpetAddonDeed( Serial serial ) : base( serial )
{
}
public override void OnDoubleClick( Mobile from )
{
if ( IsChildOf( from.Backpack ) )
BoundingBoxPicker.Begin( from, new BoundingBoxCallback( BoundingBox_Callback ), null );
else
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
private void BoundingBox_Callback( Mobile from, Map map, Point3D start, Point3D end, object state )
{
IPoint3D p = start as IPoint3D;
if ( p == null || map == null )
return;
int width = (end.X - start.X), height = (end.Y - start.Y);
if ( width < 2 || height < 2 )
from.SendMessage( "The carpet has to cover a minimum area of 3x3 tiles." );
else if ( IsChildOf( from.Backpack ) )
from.SendGump( new VariableCarpetGump( this, p, map, width, height ) );
else
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
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();
}
}
}
namespace Server.Gumps
{
public class VariableCarpetGump : Gump
{
private const int EntryCount = 3;
private BaseAddonDeed m_Deed;
private IPoint3D m_P3D;
private Map m_Map;
private int m_Width;
private int m_Height;
public VariableCarpetGump( BaseAddonDeed deed, IPoint3D p, Map map, int width, int height ) : base( 30, 30 )
{
m_Deed = deed;
m_P3D = p;
m_Map = map;
m_Width = width;
m_Height = height;
AddPage( 0 );
AddBackground( 0, 0, 450, 160, 9250 );
AddAlphaRegion( 12, 12, 381, 22 );
AddHtml( 13, 13, 379, 20, "<BASEFONT COLOR=WHITE>Choose your carpet</BASEFONT>", false, false );
AddAlphaRegion( 398, 12, 40, 22 );
AddAlphaRegion( 12, 39, 426, 109 );
AddImage( 400, 16, 9766 );
AddImage( 420, 16, 9762 );
AddPage( 1 );
int page = 1;
for ( int i = 0, index = 0; i < VariableCarpetInfo.Infos.Length; ++i, ++index )
{
if ( index >= EntryCount )
{
if ( (EntryCount * page) == EntryCount )
AddImage( 400, 16, 0x2626 );
AddButton( 420, 16, 0x15E1, 0x15E5, 0, GumpButtonType.Page, page + 1 );
++page;
index = 0;
AddPage( page );
AddButton( 400, 16, 0x15E3, 0x15E7, 0, GumpButtonType.Page, page - 1 );
if ( (VariableCarpetInfo.Infos.Length - (EntryCount * page)) < EntryCount )
AddImage( 420, 16, 0x2622 );
}
VariableCarpetInfo info = VariableCarpetInfo.GetInfo( i );
for ( int j = 0; j < info.Entries.Length; ++j )
{
if (info.Entries[j].OffsetX >= 0 && info.Entries[j].OffsetY >= 0 )
AddItem( 20 + (index * 140 ) + info.Entries[j].OffsetX, 46 + info.Entries[j].OffsetY, info.Entries[j].ItemID );
}
AddButton( 20 + (index * 140 ), 46, 1209, 1210, i+1, GumpButtonType.Reply, 0);
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
if ( info.ButtonID >= 1 )
{
BaseAddon addon = new VariableCarpetAddon( info.ButtonID-1, m_Width, m_Height );
Server.Spells.SpellHelper.GetSurfaceTop( ref m_P3D );
List<BaseHouse> houses = null;
AddonFitResult res = addon.CouldFit( m_P3D, m_Map, from, ref houses );
if ( res == AddonFitResult.Valid )
addon.MoveToWorld( new Point3D( m_P3D ), m_Map );
else if ( res == AddonFitResult.Blocked )
from.SendLocalizedMessage( 500269 ); // You cannot build that there.
else if ( res == AddonFitResult.NotInHouse )
from.SendLocalizedMessage( 500274 ); // You can only place this in a house that you own!
else if ( res == AddonFitResult.DoorsNotClosed )
from.SendMessage( "All doors must be closed!" );
if ( res == AddonFitResult.Valid )
{
m_Deed.Delete();
if ( houses != null )
{
foreach ( Server.Multis.BaseHouse h in houses )
h.Addons.Add( addon );
from.SendGump( new VariableCarpetPlacedGump( m_Deed ) );
}
}
else
{
addon.Delete();
}
}
}
}
public class VariableCarpetPlacedGump : Gump
{
private BaseAddonDeed m_Deed;
public VariableCarpetPlacedGump( BaseAddonDeed deed ) : base( 30, 30 )
{
m_Deed = deed;
AddPage( 0 );
AddBackground( 0, 0, 450, 250, 9250 );
AddAlphaRegion( 12, 12, 426, 22 );
AddHtml( 13, 13, 379, 20, "<BASEFONT COLOR=WHITE>Carpet successfully placed</BASEFONT>", false, false );
AddAlphaRegion( 12, 39, 426, 199 );
AddHtml( 15, 50, 420, 185, "<BODY>" +
"<BASEFONT COLOR=YELLOW>Your carpet has been placed!<BR>" +
"<BASEFONT COLOR=YELLOW>You may remove this carpet again easily. " +
"<BASEFONT COLOR=YELLOW>Simply use an axe on the carpet.<BR>" +
"<BASEFONT COLOR=YELLOW>*Notice* You have to be within 3 tiles of the west corner of the addon to remove it.<BR><BR>" +
"</BODY>", false, false );
AddButton( 190, 210, 0xF7, 0xF8, 0, GumpButtonType.Reply, 0 );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
switch ( info.ButtonID )
{
case 0: //Case uses the ActionIDs defined above. Case 0 defines the actions for the button with the action id 0
{
//Cancel
from.SendMessage( "Enjoy your new carpet." );
break;
}
}
}
}
}

Hope someone can help out
Thanks ,
ArteGordon- 01-07-2007
I think that is the same as the error here
http://xmlspawner.15.forumer.com/index.php?showtopic=1032
Lord Hog Fred- 01-08-2007
Ah thanks that's sorted now