RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

trying to duplicate a large script...

Kenko

Page
oh, sorry, I didn't see your last post, ok.

first, change
Code:
public BlacksmithPlayerVendor(){}
public BlacksmithPlayerVendor(Serial s){}
to
Code:
public BlacksmithPlayerVendor( Mobile owner, BaseHouse house ) : base( owner, house ){}
public BlacksmithPlayerVendor(Serial s):base(s){}

and then.
actually what you should do is something like
Code:
public override bool OnDragDrop( Mobile from, Item item )
{
from.SendMessage( "Do you like my blacksmith player vendor? Sure do." );
base.OnDragDrop( from, item );
}
 
Yay, it compiles!! Thank you so much for your help!! I should be able to do what I want to do with this script from here on out. I really appreciate your efforts.
 
Okay i guess i lied, i still need help.... I hate to keep asking for help, but i'm once again really stumped!!

Changing the OnDragDrop method of playervendor.cs does not seem to determine what items can be put on the vendor.

To test this method i just put return false; as the first line in this method and I was still able to drop items in the vendor's pack.

Any ideas?
 
I pretty much give up, here is my code, it compiles but i get warnings about serialization....which i dont understand. here's my code, it would be much appreciated if someone could get it to do what its supposed to, if not i give up and wont ask again. thanks.

Code:
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Gumps;
using Server.Prompts;
using Server.Targeting;
using Server.Misc;
using Server.Multis;
using Server.ContextMenus;

public class BlacksmithPlayerVendor : PlayerVendor
{
	public class BlacksmithVendorBackpack :VendorBackpack
	{
		public override bool CheckHold( Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight )
		{
			if ((item.ItemID != 5121) || //Kryss
				(item.ItemID != 3932) || //Mace
				(item.ItemID != 3938) || //Spear
				(item.ItemID != 5179) || //Maul
				(item.ItemID != 5123) || //ShortSpear
				(item.ItemID != 5177) || //WarHammer
				(item.ItemID != 5125) || //WarFork
				(item.ItemID != 5127)) //WarMace
			{return false;}
			if ( !base.CheckHold( m, item, message, checkItems, plusItems, plusWeight ) )
				return false;

			if ( !BaseHouse.NewVendorSystem && Parent is PlayerVendor )
			{
				BaseHouse house = ((PlayerVendor)Parent).House;

				if ( house != null && house.IsAosRules && !house.CheckAosStorage( 1 + item.TotalItems + plusItems ) )
				{
					if ( message )
						m.SendLocalizedMessage( 1061839 ); // This action would exceed the secure storage limit of the house.

					return false;
				}
			}

			return true;
		}
	}


	public BlacksmithPlayerVendor( Mobile owner, BaseHouse house ) : base( owner, house ){}
	public BlacksmithPlayerVendor(Serial s):base(s){}
	public override void Serialize(GenericWriter writer ){base.Serialize(writer);}
	public override void Deserialize(GenericReader reader ){base.Deserialize(reader);}
 
Scripts: Verifying...Warning: BlacksmithPlayerVendor+BlacksmithVendorBackpack
- No serialization constructor
- No Serialize() method
- No Deserialize() method
 

Kenko

Page
well... that pretty much says it.
First, you need the ctor, and ser deser/methods for the blacksmithvendorbackpack.
Second, you need the BlacksmithPlayerVendor to reference to a BlacksmithVendorBackpack (instead of a VendorBackpack), for this you will open the PlayerVendor script, search for all references to a vendorbackpack, and override them in your blacksmithplayervendor to reference a blacksmithvendorbackpakc.
 
Kenko said:
well... that pretty much says it.
First, you need the ctor, and ser deser/methods for the blacksmithvendorbackpack.
Second, you need the BlacksmithPlayerVendor to reference to a BlacksmithVendorBackpack (instead of a VendorBackpack), for this you will open the PlayerVendor script, search for all references to a vendorbackpack, and override them in your blacksmithplayervendor to reference a blacksmithvendorbackpakc.

Yeah i understood what the errors mean, but i just have no clue what the ser and deser methods are all about, how they work? I also haven't figured out what ctor means??

(im new to C#, but have C++ knowledge so this is kinda frustrating)
 
Kenko said:
Second, you need the BlacksmithPlayerVendor to reference to a BlacksmithVendorBackpack (instead of a VendorBackpack), for this you will open the PlayerVendor script, search for all references to a vendorbackpack, and override them in your blacksmithplayervendor to reference a blacksmithvendorbackpakc.

I should make BlacksmithPlayerVendor inherit BlacksmithVendorBackpack? Is that what you mean? That makes no sense to me, there is no blacksmithvendorbackpack to inherit. It doesn't exist until I defined it in this script. :confused:

If I'm inheriting vendorbackpack and for blacksmithvendorbackpack, why would i need to go through the playervendor script and find every single reference to vendorbackpack and override them all, when all i really want to modify is the checkhold method? :confused:

Code:
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Gumps;
using Server.Prompts;
using Server.Targeting;
using Server.Misc;
using Server.Multis;
using Server.ContextMenus;

public class BlacksmithPlayerVendor : PlayerVendor
{
	public class BlacksmithVendorBackpack : VendorBackpack
	{
		public override bool CheckHold( Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight )
		{
			if ((item.ItemID != 5121) || //Kryss
				(item.ItemID != 3932) || //Mace
				(item.ItemID != 3938) || //Spear
				(item.ItemID != 5179) || //Maul
				(item.ItemID != 5123) || //ShortSpear
				(item.ItemID != 5177) || //WarHammer
				(item.ItemID != 5125) || //WarFork
				(item.ItemID != 5127)) //WarMace
			{return false;}
			if ( !base.CheckHold( m, item, message, checkItems, plusItems, plusWeight ) )
				return false;

			if ( !BaseHouse.NewVendorSystem && Parent is PlayerVendor )
			{
				BaseHouse house = ((PlayerVendor)Parent).House;

				if ( house != null && house.IsAosRules && !house.CheckAosStorage( 1 + item.TotalItems + plusItems ) )
				{
					if ( message )
						m.SendLocalizedMessage( 1061839 ); // This action would exceed the secure storage limit of the house.

					return false;
				}
			}

			return true;
		}
		public BlacksmithVendorBackpack( Serial serial ) : base( serial ) {}
		public override void Serialize(GenericWriter writer ){base.Serialize(writer);}
		public override void Deserialize(GenericReader reader ){base.Deserialize(reader);}

	}


	public BlacksmithPlayerVendor( Mobile owner, BaseHouse house ) : base( owner, house ){}
	public BlacksmithPlayerVendor(Serial s):base(s){}
	public override void Serialize(GenericWriter writer ){base.Serialize(writer);}
	public override void Deserialize(GenericReader reader ){base.Deserialize(reader);}
}
 

Kenko

Page
because the checkhold method is in the vendorbackpack, not in the playervendor. therefore, you need to tell your new playervendor to target your new playerbackpack
 
Kenko said:
because the checkhold method is in the vendorbackpack, not in the playervendor. therefore, you need to tell your new playervendor to target your new playerbackpack


I researched and tried to find a solution for this, i tried adding the folowing to the top of the blacksmithplayervendor class:

Code:
	this.Backpack.Delete();
	this.Backpack = new BlacksmithPlayerVendorBackpack();

I got some error that didn't make sense, it seemed like it wanted me to add a } at the end but im reasonably sure that is not the problem... does that bit of code seem correct?
 

Kenko

Page
maybe something like:

Code:
if( Backpack != null && !Backpack.Deleted )
    Backpack.Delete();

AddItem( new BlacksmithPlayerVendorBackpack() );
 
Still getting strange errors, the exact errors are...

Invalid token 'if' in class, struct, or interface member declaration

Invalid token '!=' in class, struct, or interface member declaration

Invalid token ')' in class, struct, or interface member declaration

Invalid token '(' in class, struct, or interface member declaration

Class, struct, or interface method must have a return type

Type expected

Class, struct, or interface method must have a return type

; expected

Code:
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Gumps;
using Server.Prompts;
using Server.Targeting;
using Server.Misc;
using Server.Multis;
using Server.ContextMenus;

public class BlacksmithPlayerVendor : PlayerVendor
{

	if( Backpack != null && !Backpack.Deleted )
	Backpack.Delete();

	AddItem( new BlacksmithPlayerVendorBackpack() );

	public class BlacksmithVendorBackpack : VendorBackpack
	{


	public override bool CheckHold( Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight )
	{
		if ((item.ItemID != 5121) || //Kryss
			(item.ItemID != 3932) || //Mace
			(item.ItemID != 3938) || //Spear
			(item.ItemID != 5179) || //Maul
			(item.ItemID != 5123) || //ShortSpear
			(item.ItemID != 5177) || //WarHammer
			(item.ItemID != 5125) || //WarFork
			(item.ItemID != 5127)) //WarMace
		{return false;}
		if ( !base.CheckHold( m, item, message, checkItems, plusItems, plusWeight ) )
			return false;

		if ( !BaseHouse.NewVendorSystem && Parent is PlayerVendor )
		{
			BaseHouse house = ((PlayerVendor)Parent).House;

			if ( house != null && house.IsAosRules && !house.CheckAosStorage( 1 + item.TotalItems + plusItems ) )
			{
				if ( message )
					m.SendLocalizedMessage( 1061839 ); // This action would exceed the secure storage limit of the house.

				return false;
			}
		}

		return true;
	}

		public BlacksmithVendorBackpack( Serial serial ) : base( serial ) {}
		public override void Serialize(GenericWriter writer ){base.Serialize(writer);}
		public override void Deserialize(GenericReader reader ){base.Deserialize(reader);}

	}


	public BlacksmithPlayerVendor( Mobile owner, BaseHouse house ) : base( owner, house ){}
	public BlacksmithPlayerVendor(Serial s):base(s){}
	public override void Serialize(GenericWriter writer ){base.Serialize(writer);}
	public override void Deserialize(GenericReader reader ){base.Deserialize(reader);}
}
 

Kenko

Page
wtf..

add that code to the ctor, not whereever you want.

change:
Code:
	if( Backpack != null && !Backpack.Deleted )
	Backpack.Delete();

	AddItem( new BlacksmithPlayerVendorBackpack() );

to
Code:
    public class BlacksmithPlayerVendor( Mobile owner, BaseHouse house ) : base( owner, house )
	{
	if( Backpack != null && !Backpack.Deleted )
	    Backpack.Delete();

	AddItem( new BlacksmithPlayerVendorBackpack() );
        }

and then remove this code below
Code:
	public BlacksmithPlayerVendor( Mobile owner, BaseHouse house ) : base( owner, house ){}
 
When I do this, the following errors occur:


The type or namespace name 'BlacksmithPlayerVendorBackpack' could not be found (are you missing a using directive or an assembly reference?)

The best overloaded method match for 'Server.Mobile.AddItem(Server.Item)' has some invalid arguments

Argument '1': cannot convert from 'BlacksmithPlayerVendorBackpack to 'Server.Item'

Code:
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Gumps;
using Server.Prompts;
using Server.Targeting;
using Server.Misc;
using Server.Multis;
using Server.ContextMenus;

public class BlacksmithPlayerVendor : PlayerVendor
{

	public class BlacksmithVendorBackpack : VendorBackpack
	{


	public override bool CheckHold( Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight )
	{
		if ((item.ItemID != 5121) || //Kryss
			(item.ItemID != 3932) || //Mace
			(item.ItemID != 3938) || //Spear
			(item.ItemID != 5179) || //Maul
			(item.ItemID != 5123) || //ShortSpear
			(item.ItemID != 5177) || //WarHammer
			(item.ItemID != 5125) || //WarFork
			(item.ItemID != 5127)) //WarMace
		{return false;}
		if ( !base.CheckHold( m, item, message, checkItems, plusItems, plusWeight ) )
			return false;

		if ( !BaseHouse.NewVendorSystem && Parent is PlayerVendor )
		{
			BaseHouse house = ((PlayerVendor)Parent).House;

			if ( house != null && house.IsAosRules && !house.CheckAosStorage( 1 + item.TotalItems + plusItems ) )
			{
				if ( message )
					m.SendLocalizedMessage( 1061839 ); // This action would exceed the secure storage limit of the house.

				return false;
			}
		}

		return true;
	}

		public BlacksmithVendorBackpack( Serial serial ) : base( serial ) {}
		public override void Serialize(GenericWriter writer ){base.Serialize(writer);}
		public override void Deserialize(GenericReader reader ){base.Deserialize(reader);}

	}


	public BlacksmithPlayerVendor( Mobile owner, BaseHouse house ) : base( owner, house )
	{
		if( Backpack != null && !Backpack.Deleted )
			Backpack.Delete();

		AddItem( new BlacksmithPlayerVendorBackpack() );
	}
	public BlacksmithPlayerVendor(Serial s):base(s){}
	public override void Serialize(GenericWriter writer ){base.Serialize(writer);}
	public override void Deserialize(GenericReader reader ){base.Deserialize(reader);}
}
 
Top