Lol yeah I saw that code and was about to say... yeah...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...arul said:Well, I need really sleep
Code:public override bool ShowFameTitle { get { return !GetFlag( PlayerFlag.ShowFame ); } }
arul said:Mobile.ShowFameTitle doesn't have overridable set accessor, thus we need the slave setter...
I doubt that, you don't need to cast anything properly since the code with added set accessor isn't even going to compile...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.
public override bool ShowFameTitle
{
get
{
return true;
}
set
{
}
}
For example to be able to set fame title independently on any item.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.
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); } }
XxSP1DERxX said:You would create an interface... like
INoFameTitle
public interface INoFameTitle
{
}
public class HalloweenMask : HornedTribalMask, INoFameTitle
public class HalloweenMask : HornedTribalMask, INoFameTitle
{
public class PlayerMobile : Mobile
{
public interface INoFameTitle
{
}
- 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?)
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 )
{
}
public interface INoFameTitle
{
}
public class PlayerMobile : Mobile
{
Notice the part in REDXxSP1DERxX 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); } }
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
- Error: Scripts\Custom\New\Halloween 2005\HalloweenMask.cs: CS0115: (line 19,
column 24) 'Server.Items.HalloweenMask.ShowFameTitle': no suitable method found
to override
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 ?