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...

trying to duplicate a large script...

Hello, I'm trying to duplicate playervendor.cs but im having no success..... since my definitions can not be the same as playervendor.cs i've been getting errors, i've been trying to change class definitions but ive had no success... can somebody who has copied a script before tell me what lines i need to change in my new specialplayervendor.cs to get it to compile with the old playervendor.cs? thank you.
 

Malaperth

Wanderer
Well, I'm a bit slow today, so bear with me, but to start with, you must change all the places in the script that says PlayerVendor to your new classname. If I'm not mistaken, even if there are static methods in there, as long as you rename all the PlayerVendor constructors, it should compile.
 

Kenko

Page
My advice on this is DONT copy the script, base off of it instead.

Code:
class SpecialPlayerVendor : PlayerVendor
 

Malaperth

Wanderer
If you inherit from PlayerVendor instead of copying it, you will have access to all public methods and members without having to copy anything. And any methods you need to change, can be overridden, as long as they are marked override (or virtual, but that isn't likely).
 
Malaperth said:
If you inherit from PlayerVendor instead of copying it, you will have access to all public methods and members without having to copy anything. And any methods you need to change, can be overridden, as long as they are marked override (or virtual, but that isn't likely).

Hmmm, well i dont know how to do this? Basically what im trying to do is use a playervendor but restrict what items it sells....so i'll actually need to change some of the methods...so i dont see how i can just inherit them.
 

Malaperth

Wanderer
Right, so if there's a method in PlayerVendor called DoSomething(), for example and it looks like this:

Code:
public override void DoSomething()
{
     StuffHere;
}

in your new class inheriting from PlayerVendor in the way that Kenko showed, all you need to do is add in:

Code:
public override void DoSomething()
{
     MyNewStuffHere;
}

your new method will be used and the original in the base class (PlayerVendor) will not be used unless you put in a line like this:

Code:
base.DoSomething();

and any other public method or variable can be used in your new class just like it was actually typed in your class since you inherit from PlayerVendor.
 
If im not mistaken, i need to edit

public override bool CheckHold(

which is inside of

public class VendorBackpack : Backpack



could somebody please show me how to inherit playervendor.cs and edit those portions of playervendor.cs to take effect in my new script?
 
OK here is my real code, im getting the error:

'Server.Mobiles.BlacksmithPlayerVendor.Checkhold(Server.Mobile, Server.Item, bool, bool, int, int)':no suitable method found to override.

so obviously im still not getting what you're saying. :(

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;

namespace Server.Mobiles
{
public class BlacksmithPlayerVendor : PlayerVendor
{
public override bool CheckHold( Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight )
{
//Check for allowed items
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 ( Ethics.Ethic.IsImbued( item, true ) )
{
if ( message )
m.SendMessage( "Imbued items may not be sold here." );

return false;
}

if ( !BaseHouse.NewVendorSystem && Parent is BlacksmithBlacksmithPlayerVendor )
{
BaseHouse house = ((BlacksmithPlayerVendor)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;
}

}
}
 

Kenko

Page
very roughly:

Code:
using Stuff;

public class SpecialPlayerVendor : PlayerVendor
{
    public override bool CheckHold{ return whateverYouWant; }

    public SpecialPlayerVendor(){}
    public SpecialPlayerVendor(Serial s){}
    public override void Serialize(GenericWriter writer ){base.Serialize(writer);}
    public override void Deserialize(GenericReader reader ){base.Deserialize(reader);}
}

that's if you want to do is Only to override methods in playervendor class.
 
Code:

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 override bool CheckHold( Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight )
	{
		//Check for allowed items
		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 ( Ethics.Ethic.IsImbued( item, true ) )
		{
			if ( message )
				m.SendMessage( "Imbued items may not be sold here." );

			return false;
		}

		if ( !BaseHouse.NewVendorSystem && Parent is BlacksmithBlacksmithPlayerVendor )
		{
			BaseHouse house = ((BlacksmithPlayerVendor)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(){}
public BlacksmithPlayerVendor(Serial s){}
public override void Serialize(GenericWriter writer ){base.Serialize(writer);}
public override void Deserialize(GenericReader reader ){base.Deserialize(reader);}

Error: 'BlacksmithPlayerVendor.Checkhold(Server.Mobile, Server.Item, bool, bool, int, int)': no suitable method found to override

I still dont understand, please help. :(
 

Malaperth

Wanderer
CheckHold doesn't do what you seem to think it does I don't think. All that method does is check to see if there is room in the pack or in the house the vendor is in to physically hold the items...
 
Crap, do you know if there's a method that does what I want? or how do i write my own?

EDIT: Wait, if this method does not allow a person to place an item on a vendor, should i still be able to accomplish my goal even if the method was not designed for this purpose?
 
directly pasting in an unchanged ondragdrop method gives me the following errors:

Server.Mobiles.PlayerVendor.OnItemGiven(Server.Mobile, Server.Item) is inacessible due to its protection level

No overload for method PlayerVendor takes 0 arguments

No overload for method PlayerVendor takes 0 arguments

Here is the code:

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 override bool OnDragDrop( Mobile from, Item item )
	{
		if ( !IsOwner( from ) )
		{
			SayTo( from, 503209 ); // I can only take item from the shop owner.
			return false;
		}

		if ( item is Gold )
		{
			if ( BaseHouse.NewVendorSystem )
			{
				if ( this.HoldGold < 1000000 )
				{
					SayTo( from, 503210 ); // I'll take that to fund my services.

					this.HoldGold += item.Amount;
					item.Delete();

					return true;
				}
				else
				{
					from.SendLocalizedMessage( 1062493 ); // Your vendor has sufficient funds for operation and cannot accept this gold.

					return false;
				}
			}
			else
			{
				if ( this.BankAccount < 1000000 )
				{
					SayTo( from, 503210 ); // I'll take that to fund my services.

					this.BankAccount += item.Amount;
					item.Delete();

					return true;
				}
				else
				{
					from.SendLocalizedMessage( 1062493 ); // Your vendor has sufficient funds for operation and cannot accept this gold.

					return false;
				}
			}
		}
		else
		{
			bool newItem = ( GetVendorItem( item ) == null );

			if ( this.Backpack != null && this.Backpack.TryDropItem( from, item, false ) )
			{
				if ( newItem )
					OnItemGiven( from, item );

				return true;
			}
			else
			{
				SayTo( from, 503211 ); // I can't carry any more.
				return false;
			}
		}
	}



public BlacksmithPlayerVendor(){}
public BlacksmithPlayerVendor(Serial s){}
public override void Serialize(GenericWriter writer ){base.Serialize(writer);}
public override void Deserialize(GenericReader reader ){base.Deserialize(reader);}
}
 

Kenko

Page
Is the method you are trying to override actually existant? Have you spelled correctly it's name?
Is the overload you are trying to override correct?

One of this must be false.. check in playervendor.cs (using search function on your code editor always helps)
 
Kenko said:
Is the method you are trying to override actually existant? Have you spelled correctly it's name?
Is the overload you are trying to override correct?

One of this must be false.. check in playervendor.cs (using search function on your code editor always helps)

I directly copied the function from playervendor.cs without editing it. So if it is not spelled correctly, I don't know how.

I do not know what an overload is.
 
Top