ExX

Member
So I am a bit picky and want my various staff to have colored robes like they are supposed to. I use the [gmbody command that gives each staff a "staffrobe". So I open the robe script up to add hues and I notice it is supposed to hue the robe every time they equip it to the properly define color for each accesslevel. I don't see an issue as to why it's not working. I did some searches and came up empty. I'm really surprised no one has reported this issue before. Here is the actual script if someone can see somehting I am over-looking. It looks fairly basic so I dont see the issue.

Code:
using System;

namespace Server.Items
{
    public class StaffRobe : BaseSuit
    {
        private int _DecoratorHue = 0x0;
        private int _OwnerHue, _CoOwnerHue = 0x481;
        private int _DeveloperHue = 0x497;
        private int _AdminHue = 0x47E;
        private int _SeerHue = 0x1D3;
        private int _GamemasterHue = 0x26;
        private int _CounselorHue, _SpawnerHue = 0x3;
        private int _PlayerHue = 0x0;
        [Constructable]
        public StaffRobe()
            : base(AccessLevel.Player, 0x0, 0x2683)
        {
            this.Name = "an elder robe";
        }

        public StaffRobe(Serial serial)
            : base(serial)
        {
        }

        [CommandProperty(AccessLevel.Owner)]
        public int OwnerHue
        {
            get
            {
                return this._OwnerHue;
            }
            set
            {
                this._OwnerHue = value;
            }
        }
        [CommandProperty(AccessLevel.CoOwner)]
        public int CoOwnerHue
        {
            get
            {
                return this._CoOwnerHue;
            }
            set
            {
                this._CoOwnerHue = value;
            }
        }
        [CommandProperty(AccessLevel.Developer)]
        public int DeveloperHue
        {
            get
            {
                return this._DeveloperHue;
            }
            set
            {
                this._DeveloperHue = value;
            }
        }
        [CommandProperty(AccessLevel.Administrator)]
        public int AdminHue
        {
            get
            {
                return this._AdminHue;
            }
            set
            {
                this._AdminHue = value;
            }
        }
        [CommandProperty(AccessLevel.Seer)]
        public int SeerHue
        {
            get
            {
                return this._SeerHue;
            }
            set
            {
                this._SeerHue = value;
            }
        }
        [CommandProperty(AccessLevel.GameMaster)]
        public int GamemasterHue
        {
            get
            {
                return this._GamemasterHue;
            }
            set
            {
                this._GamemasterHue = value;
            }
        }
        [CommandProperty(AccessLevel.Spawner)]
        public int SpawnerHue
        {
            get
            {
                return this._SpawnerHue;
            }
            set
            {
                this._SpawnerHue = value;
            }
        }
        [CommandProperty(AccessLevel.Decorator)]
        public int DecoratorHue
        {
            get
            {
                return this._DecoratorHue;
            }
            set
            {
                this._DecoratorHue = value;
            }
        }
        [CommandProperty(AccessLevel.Counselor)]
        public int CounselorHue
        {
            get
            {
                return this._CounselorHue;
            }
            set
            {
                this._CounselorHue = value;
            }
        }
        [CommandProperty(AccessLevel.GameMaster)]
        public int PlayerHue
        {
            get
            {
                return this._PlayerHue;
            }
            set
            {
                this._PlayerHue = value;
            }
        }
        public override void Serialize(GenericWriter writer)
        { // No need to serialize level hues, robe meant for staff only.
            base.Serialize(writer);

            writer.Write((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
        }

#if NEWPARENT
		public override void OnRemoved(IEntity parent)
#else
        public override void OnRemoved(object parent)
#endif
		{
			base.OnRemoved(parent);

            if (this.ItemID == 0x204F)
                this.ItemID = 0x2683;

            this.Hue = 0x0;
            this.Name = "An Elder Robe";
        }

        public override bool OnEquip(Mobile from)
        {
            if ((this.ItemID == 0x2683) && (from.IsStaff()))
                this.ItemID = 0x204F;

            switch (from.AccessLevel)
            {
                case AccessLevel.Owner:
                    this.Name = "The Owner Robe";
                    this.Hue = this._OwnerHue;
                    break;
                case AccessLevel.CoOwner:
                    this.Name = "A Co-Owner Robe";
                    break;
                case AccessLevel.Administrator:
                    this.Name = "An Administrator Robe";
                    this.Hue = this._AdminHue;
                    break;
                case AccessLevel.Developer:
                    this.Name = "a Developer robe";
                    this.Hue = this._DeveloperHue;
                    break;
                case AccessLevel.Seer:
                    this.Name = " a Seer Robe";
                    this.Hue = this._SeerHue;
                    break;
                case AccessLevel.GameMaster:
                    this.Name = "a GameMaster Robe";
                    this.Hue = this._GamemasterHue;
                    break;
                case AccessLevel.Counselor:
                    this.Name = "a Counselor Robe";
                    this.Hue = this._CounselorHue;
                    break;
                default:
                    this.Name = "an elder robe";
                    this.Hue = this._PlayerHue;
                    break;
            }

            return true;
        }
    }
}
 
Works fine for me as well, which is not to say no one else is having the same problem of course.
 
Very, just for the heck of it did you try to just add the staffrobe and then equip it- instead of using gmbody?
 
Strange, not sure what the change would be then :/ have you changed any thing with commands?
 
I haven't changed anything with the default commands. I try to keep the original files as default as possible using eventsinks when I can. I have added many new commands but looking at the ones in that script and what I have added there is none that would conflict. I just tried a default JustUO package and same results. It must be something they did in the server to conflict with this script. I just can't for the life of me figure out what that might be.

What's really odd is it names the robe properly. Just doesn't hue it.
 
@Exale
I just looked at mine and it's set up very different from what you posted. You can give these files a go...I can't guarantee they are going to be 100% compatible with what you've got as these are old files...but if they work, yay! LOL

There is the master BaseSuit.cs, then Admin, Counselor, GM and Seer robes.

EDIT: I also noticed at the top of my BaseSuit.cs I have:
Code:
 using Server;

and you don't have that.
 

Attachments

  • StaffRobes.zip
    2.2 KB · Views: 37
Thank you Tass but I just tracked the issue down. It seems it didn't like defining 2 integers. Example:

private int _OwnerHue, _CoOwnerHue = 0x481;
private int _CounselorHue, _SpawnerHue = 0x3;

I realized it after testing each access level and seeing that only owners and counselors were having the issue. So I split the integers up and it works fine. Here is the working script for anyone that may be having the same issue as myself.
 

Attachments

  • StaffRobe.cs
    5.6 KB · Views: 24
private int _OwnerHue, _CoOwnerHue = 0x481;

_OwnerHue is empty,
_CoOwnerHue is 0x481.

you could even go as crazy as:
private int a = 1, b = 2, c = 222, d = 4, e = -4;

But i do agree splitting them looks better.
private int a = 1;
private int b = 2;
private int c = 222;
private int d = 4;
private int e = -4;
 
I will try and explain what happen and why the above code did not work. This is purely for learning and explanation purposes:

When you declare a variable you can either initialize it or leave it un-initialized:

initialized is like so
Code:
private int someNumber = 3;
un-initialized is like so
Code:
private int someNumber;
It is always good to initialize your variables with a value your code should not reach. You can use that as an error checking tool in case you end up with a situation when you end up not assigning a new value to your variable

Code:
private int someNumber = 0; // expected values for this int will be > 0

{ some code }

// start the output from the above code

if (someNumber <= 0)
{
	console.Writeline("code produced a non-return set for int someNumber");
	return;
}
else
{
	// what you want to happen based on the new value of someNumber
}

When you declare several variables at the same time this is basically what we see versus what the computer sees

Code:
// we see this
private int someNumber, someDifferentNumber;

// what the computer sees
private int someNumber;
private int someDifferentNumber;

As a result any initialization that happens only happens on the last value because of the comma separation. The code from your robe basically looked like this to the computer

Code:
private int _OwnerHue;
private int _CoOwnerHue = 0x481;
private int _CounselorHue;
private int _SpawnerHue = 0x3;

This left the owner and counselor hue values un-initialized. In some languages the computer would return what ever was in the memory address previously when this happens. C# returns a default value for any un-initialized variables. For an int that is a 0 which to the uo emulators means un-hued.

I hope this makes sense and is helpful to other people.
 
Ooooh I get it. Thanks very much for the explanation both of you. Thought the double integer was so they both shared that value which is what I honestly think they intended to do. :)
 
Like, I don't understand why people do this... veering off-course for this long just to add an item that'll serve all staff member roles, instead of just adding individual robes for each level. Like, I get it, it'd doable but there's already so much to do.. and what effect does it provide really? no offense intended but I find that to be a waste of time.
 
no offense intended but I find that to be a waste of time.

Sort of like digging up a thread that is over a month old? ;)

There are loads of reasons to add automation like this to a shard, or any other software project. One of the biggest ones to me is to learn. The OP of this thread has learned a lot by trying this out and will be able to apply what they have learned to future projects. The second biggest in my opinion is less code to maintain.

If you never veer off then you will never find new things.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back