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 hide FameTitle with an item.

Joeku

Lord
arul said:
Well, I need really sleep ;)
Code:
public override bool ShowFameTitle
        {
            get
            {
                return !GetFlag( PlayerFlag.ShowFame );
            }
        }
Lol yeah I saw that code and was about to say... yeah...
 

Kamron

Knight
arul said:
Mobile.ShowFameTitle doesn't have overridable set accessor, thus we need the slave setter...

Not to insult your knowledge of coding, but if you had known how inheretence works, you would know that you can add a set accessor to a property which does not have one, although to use it you must cast properly to that class. That plays into my previous post, which you did not understand properly. And in regards to slave setters, they are a bad coding practice/habit.

I do not suggest this method at all, regardless of the ability to override with a set accessor, the ability to use a slave set accessor, etc. You should use the interface method, or rewrite the core to support a set access and have the set accessor simply be empty in the core. Then you can save it in the PlayerMobile if you really wanted to.
 

arul

Sorceror
XxSP1DERxX said:
Not to insult your knowledge of coding, but if you had known how inheretence works, you would know that you can add a set accessor to a property which does not have one, although to use it you must cast properly to that class. That plays into my previous post, which you did not understand properly. And in regards to slave setters, they are a bad coding practice/habit.

I do not suggest this method at all, regardless of the ability to override with a set accessor, the ability to use a slave set accessor, etc. You should use the interface method, or rewrite the core to support a set access and have the set accessor simply be empty in the core. Then you can save it in the PlayerMobile if you really wanted to.
I doubt that, you don't need to cast anything properly since the code with added set accessor isn't even going to compile...
Just try this and you'll see...
Code:
        public override bool ShowFameTitle
        {
            get
            {
                return true;
            }
            set
            {
            }
        }
 

Kamron

Knight
Yeah I checked MSDN since I am not home and you are right... however, I still maintain the idea that a slave set accessor is bad habit of coding.

An interface is considered reusable code as well as a slave set accessor, and you don't have to add extra code to actually set it and serialize.

I don't understand why you need to make more work for yourself.
 

arul

Sorceror
XxSP1DERxX said:
Yeah I checked MSDN since I am not home and you are right... however, I still maintain the idea that a slave set accessor is bad habit of coding.

An interface is considered reusable code as well as a slave set accessor, and you don't have to add extra code to actually set it and serialize.

I don't understand why you need to make more work for yourself.
For example to be able to set fame title independently on any item.

Packer:
Whats the error message you got or what exactly doesn't work ?
 

Packer898

Knight
Well it wont allow the fame to be overriden still with the return ! get part. but when I take that out then no one shows it. When I add it in then it still shows the lord/lady titles
 

Kamron

Knight
Packer, my method works, and I explained how to get it to work with multiple items...

XxSP1DERxX said:
You would create an interface... like

INoFameTitle

then you would make all of the items have that interface, and change the property to

public override bool ShowFameTitle{ get{ return !(FindItemOnLayer( Layer.Helm ) is INoFameTitle); } }
 

Kamron

Knight
Code:
public interface INoFameTitle
{
}

then in your HalloweenMask, and any other item, you would change it to

Code:
public class HalloweenMask : HornedTribalMask, INoFameTitle

Interfaces allow you to reference object(s) or class(es) with one type. You can also specify methods or properties in the interface which all of the objects or classes share.
 

Packer898

Knight
ok... like this...
Code:
	public interface INoFameTitle
	{
		ShowFameTitle title { get; set; }
		object RootParent{ get; }
		void Delete();
	}

Maybe I need to do some more reading real fast. Never touched this before so totally unfamiliar with it.
 

Kamron

Knight
In your case, you don't need any properties or methods. The reason is because you are just using it to identify items which will not show their fame title, thats all.
 

Packer898

Knight
Ok what did I screw up?
Code:
	public class HalloweenMask : HornedTribalMask, INoFameTitle
	{

in playermobile.cs:
Code:
	public class PlayerMobile : Mobile
	{
		public interface INoFameTitle
		{
		}

Error:
Code:
 - Error: Scripts\Custom\New\Halloween 2005\HalloweenMask.cs: CS0246: (line 17,
column 49) The type or namespace name 'INoFameTitle' could not be found (are you
 missing a using directive or an assembly reference?)
 

Packer898

Knight
Thanks Khaz. You were right about that. GOt it added and compiled but still doesnt work. I fail to see how this would work with only the code im using though . lol anyway here's what I got so far.

Code:
using System;
using Server;
using Server.Items;
using Server.Mobiles;

namespace Server.Items
{
	public class HalloweenMask : HornedTribalMask, INoFameTitle
	{
		[Constructable]
		public HalloweenMask() : base( 0x1549)
		{
			Hue = 1358;
			Name = "Trick or Treat";
			LootType = LootType.Blessed;
			Weight = 1.0;
		}
		
		public HalloweenMask( Serial serial ) : base( serial )
		{
		}

Playermobile.cs:
Code:
	public interface INoFameTitle
	{
	}

	public class PlayerMobile : Mobile
	{

Compiles but still shows the Lord/Lady titles.
 

Kamron

Knight
You were missing the last part that I gave you... and that was the override in PlayerMobile.cs

XxSP1DERxX said:
You would create an interface... like

INoFameTitle

then you would make all of the items have that interface, and change the property to

public override bool ShowFameTitle{ get{ return !(FindItemOnLayer( Layer.Helm ) is INoFameTitle); } }
Notice the part in RED
 

Packer898

Knight
XxSP1DERxX said:
You were missing the last part that I gave you... and that was the override in PlayerMobile.cs


Notice the part in RED

I did add that in but it gave me an error... Ill retry again real fast and post the error.

Edit - Here is the error...
Code:
 - Error: Scripts\Custom\New\Halloween 2005\HalloweenMask.cs: CS0115: (line 19,
column 24) 'Server.Items.HalloweenMask.ShowFameTitle': no suitable method found
to override
 

Kamron

Knight
arul said:
For example to be able to set fame title independently on any item.

Packer:
Whats the error message you got or what exactly doesn't work ?

You can with the interface method... just add the interface if you want it, otherwise, don't. Since the property is on the player, your method, nor mine, gives versatility to the title independency in-game.
 
Top