I'm creating custom clothing for veterans that doesn't conform to the traditional 3 physical resist vet clothing system. However, I'm having a hard time coding it so that characters with accounts that do not meet the required Veteran Age cannot wear the clothing. In the code of the item's file, I currently have:

C#:
public override bool CanEquip(Mobile m)
        {
            if (!base.CanEquip(m))
                return false;

            if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(m, this, null))
            {
                m.SendLocalizedMessage(1071936); // You cannot equip that.
                return false;
            }

            return true;
        }

I checked the ethereals.cs code as a reference to get an idea of how it works, but it appears that characters can now ride any ethereal at any age too. To test my code, I have a veteran account that claims the clothing, and a brand new account (1 day old). However I code it though, either both characters can wear the clothing, or both characters cannot wear it, which means that the code is not accounting for the account age. For the classic veteran clothing it recognizes the item by it's hue and it's label; but I am currently not using those in my RewardSystem.cs file for my new clothing. The current code for that, looks like this:

C#:
new RewardList(RewardInterval, 1, new RewardEntry[]

                {

                    new RewardEntry(cloaksAndRobes, "New Veteran Cloak", typeof(NewVeteranCloak)),

                }),

Any suggestions or help on this would be much appreciated.
 
Take a look at the OnDoubleClick method in CharacterStatue.cs. I think it will get you where your wanting to go.
 
Take a look at the OnDoubleClick method in CharacterStatue.cs. I think it will get you where your wanting to go.
So I sort of found the problem... It wasn't just the custom scripts that weren't checking for the vet status of an account, it was the entire first reward entry. Meaning, a new account couldn't wear any of the clothing when it was set to the second, third, or any thereafter reward entries, but could wear clothing from the first entry. The account is still only 2 days old, so I have no clue what's doing this. There's nothing in the code like if (rewardlevel < 1) rewardlevel = 1; only if rewardlevel < 0 rewardlevel = 0. Also, the "startinglevel" on my script and my vetrewards.cfg scripts are both set to 0. Any ideas?
 
A lot of rewards are usable by younger accounts in UO they changed it this way several years ago. The reason I pointed out CharacterStatue's OnDoubleClick is because it contains code that could be added to the item your wanting to prevent them from using's OnEquip method to prevent younger accounts from equipping the item.

C#:
Account acct = from.Account as Account;

            if (acct != null && from.IsPlayer())
            {
                TimeSpan time = TimeSpan.FromDays(RewardSystem.RewardInterval.TotalDays * 6) - (DateTime.UtcNow - acct.Created);

                if (time > TimeSpan.Zero)
                {
                    from.SendLocalizedMessage(1008126, true, Math.Ceiling(time.TotalDays / RewardSystem.RewardInterval.TotalDays).ToString()); // Your account is not old enough to use this item. Months until you can use this item :
                    return;
                }
            }

In the new items your making you could add the following CanEquip method to the clothing to prevent use until the account was the correct age.
The variable TotalDays = 30 unless it's been modified so the 6 would make it 6 months, you can change it to whatever you want.
The scripts will also have to have:
using Server.Accounting;
added to the using block at the top

C#:
public override bool CanEquip(Mobile m)
        {
            if (!base.CanEquip(m))
                return false;

            Account acct = m.Account as Account;

            if (acct != null && m.IsPlayer())
            {
                TimeSpan time = TimeSpan.FromDays(RewardSystem.RewardInterval.TotalDays * 6) - (DateTime.UtcNow - acct.Created);

                if (time > TimeSpan.Zero)
                {
                    m.SendLocalizedMessage(1008126, true, Math.Ceiling(time.TotalDays / RewardSystem.RewardInterval.TotalDays).ToString()); // Your account is not old enough to use this item. Months until you can use this item :
                    return false;
                }
            }

            return !IsRewardItem || RewardSystem.CheckIsUsableBy(m, this, new object[] { Hue, m_LabelNumber });
        }
 
Back