Hi guys, how can create a restrictions on use , for example a player that has magery skill can't equip bows,plate,chain mail ecc .
Is possible to make it with xmlspawner2 ?
I'm using the advantagegate for caps ecc very cool :)

Thanks alway for your help ! :)



If can interest I'm looking for a scripter for my italian runuo server no stress no hurry :)
I'm building a old style server no bright colours or excessive , normal ingots/leathers with resistances ecc bloodrock,blackrock,mithriel, orc leather, serpent ecc ecc , class system you will not see a mage with a shield or plate or mage with a big axe! if interested contact me ;) !
 
There is an "OnEquip" and/or "CheckEquip" method in BaseRanged, BaseWeapon, Base...Etc.

Something like:

Code:
if (from.Skills[SkillName.Magery].Base > YourRestrictedValueHere) return false;
 
ok tnz Lokai!, so I will add that code to the baseweapon ecc, then to the item? for example bow.cs ?
[doublepost=1552232092][/doublepost]I putted it on
public override bool OnEquip( Mobile from )
end
public override bool CanEquip( Mobile from )
on basearmor.cs but I can equip a plate.. uhm
 
Last edited:
Your BaseArmor.cs does not have the code that I gave you. If you were going to use it in BaseArmor you would need to have a complete set of restrictions somewhere, and reference that somehow. You could put it in a separate script, and call it from the CanEquip and/or OnEquip methods. It might look something like this in BaseArmor:

Code:
        *SNIP*
        public override bool CanEquip(Mobile from)
        {
            if (!Ethics.Ethic.CheckEquip(from, this))
                return false;

            // Here is where you define the new check to see if they can wear it
            if (!YourNamespace.YourClassSystem.CheckEquip(from, this))
                return false;

            if (from.IsPlayer())
            {
           
            *SNIP*

Then in your new file, you can decide what types of items are restricted. It might look like this:

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

namespace YourNamespace
{
    public class YourClassSystem
    {
        public bool CanEquip(Mobile from, Item item)
        {
            if (item is BaseArmor)
            {
                // Here you can set up restrictions for wearing Armor
                if (your criteria here)
                {
                }
            }
            else if (item is BaseWeapon)
            {
                // Here you can set up restrictions for wielding Weapons
                if (your criteria here)
                {
                }
            }
            else if (item is BaseJewel)
            {
                // Here you can set up restrictions for wearing Jewelry
                if (your criteria here)
                {
                }
            }
        }
    }
}
 
Hi Lokay in "your criteria" goes this
if (from.Skills[SkillName.Magery].Base > YourRestrictedValueHere) return false; right ?

I can for example do that to a single item? , I can use that in inverse ? if the player has magery cna equip that to put return true ?

Thanks Lokai ^^ I will try
 
Last edited:
Yes. It depends if you want to restrict ALL armor, or just some. All armor would include shields, helmets, legs and bodies, but would not include cloth-based items like robes and cloaks. Yes, you could also place the check in individual scripts instead of BaseArmor or BaseWeapon, but you would have to do it in EVERY single piece of armor you have in your server, so it's easier to do it in one place. You could also put the check in places like BaseLegs, BaseShield, etc. but you would not need to if it was already in BaseArmor.
 
yes I understand so if I would like to put on the single item I should add this check

if (from.Skills[SkillName.Magery].Base> YourRestrictedValueHere) return false;

leaving free without the restriction the basearmors.cs , BUT with the new script that you have suggested Example;

Platechest.cs


using System;
using Server.Items;
namespace Server.Items
{
[FlipableAttribute( 0x1415, 0x1416 )]
public class PlateChest : BaseArmor
{
<<<if (from.Skills[SkillName.Magery].Base> YourRestrictedValueHere)return false;>>>

public override int BasePhysicalResistance{ get{ return 5; } }
public override int BaseFireResistance{ get{ return 0; } }
public override int BaseColdResistance{ get{ return 0; } }
public override int BasePoisonResistance{ get{ return 0; } }
public override int BaseEnergyResistance{ get{ return 0; } }

ecc ecc
}
}
}

I will try Lokai thanks for you help ;)
 
Like this:

Code:
namespace Server.Items
{
    [Alterable(typeof(DefBlacksmithy), typeof(GargishPlateChest))]
    [FlipableAttribute(0x1415, 0x1416)]
    public class PlateChest : BaseArmor
    {
        [Constructable]
        public PlateChest()
            : base(0x1415)
        {
            this.Weight = 10.0;
        }

        public PlateChest(Serial serial)
            : base(serial)
        {
        }       
       
        public override bool CanEquip(Mobile from)
        {
            if (from.Skills[SkillName.Magery].Base > 20) return false;
        }

        public override int BasePhysicalResistance
        {
            get
            {
                return 5;
            }
        }
 
Ok so I need to add all the code,
  1. public override bool CanEquip(Mobile from)
  2. {
  3. if (from.Skills[SkillName.Magery].Base > 20) return false;
  4. }
I was thinking if I would like to add 2 restrictions, for example a player if want equip a platechest must have Magery and Mace (I want to create a clerik class) .
Should be;

  • public override bool CanEquip(Mobile from)
  • {
  • if (from.Skills[SkillName.Magery].Base > 20) return true; (not false)
  • if (from.Skills[SkillName.Mace].Base > 20) return true; (not false)
  • else if (from.Skills[SkillName.Magery].Base > 20) return false;
  • }
  • Correct?
 
Close. More like this:

Code:
    public override bool CanEquip(Mobile from)
    {
        if (from.Skills[SkillName.Magery].Base > 20 && from.Skills[SkillName.Mace].Base > 20) return true; //(not false)
        else if (from.Skills[SkillName.Magery].Base > 20) return false;
    }
 
Hi Lokai I had some errors but because I had yet the section, I found my "restritions" section on basearmor i think is this ;
Maybe from here is more simple to resolve, I got this error certainly because the code is for ServUO? ;

CS0103: Line 646: The name 'from' does not exist in the current context.
CS0127: Line 646: integer 'Server.Items.BaseArmor.ValidateMobile (Server.Mobile)' returns a null value, a return keyword should not be considered by a written expression.


public static void ValidateMobile( Mobile m )
{
for ( int i = m.Items.Count - 1; i >= 0; --i )
{
if ( i >= m.Items.Count )
continue;
Item item = m.Items;
if ( item is BaseArmor )
{
BaseArmor armor = (BaseArmor)item;

if ( from.Skills[SkillName.Magery].Base > 20) return false; <<<<<<<<<<<<<<<<<<<!

if ( armor.RequiredRace != null && m.Race != armor.RequiredRace )
{
if( armor.RequiredRace == Race.Elf )
m.SendLocalizedMessage( 1072203 ); // Only Elves may use this.
else
m.SendMessage( "Only {0} may use this.", armor.RequiredRace.PluralName );
m.AddToBackpack( armor );
}

[doublepost=1552314170][/doublepost]
Close. More like this:

Code:
    public override bool CanEquip(Mobile from)
    {
        if (from.Skills[SkillName.Magery].Base > 20 && from.Skills[SkillName.Mace].Base > 20) return true; //(not false)
        else if (from.Skills[SkillName.Magery].Base > 20) return false;
    }

Ok I will try with the modification when you see the message above
 
If you are trying to catch people who already have it equipped by using the ValidateMobile method, you would need to change the test and result a bit like this:

Code:
        public static void ValidateMobile( Mobile m )
        {
            for ( int i = m.Items.Count - 1; i >= 0; --i )
            {
                if ( i >= m.Items.Count )
                    continue;

                Item item = m.Items[i];

                if ( item is BaseArmor )
                {
                    BaseArmor armor = (BaseArmor)item;

                    if( m.Skills[SkillName.Magery].Base > 20 )
                    {
                        m.SendMessage("Mages are not allowed to wear armor.");
                        m.AddToBackpack( armor );
                    }
                    else if( armor.RequiredRace != null && m.Race != armor.RequiredRace )
                    {
                        if( armor.RequiredRace == Race.Elf )
                            m.SendLocalizedMessage( 1072203 ); // Only Elves may use this.
                        else
                            m.SendMessage( "Only {0} may use this.", armor.RequiredRace.PluralName );

                        m.AddToBackpack( armor );
                    }
                    else if ( !armor.AllowMaleWearer && !m.Female && m.AccessLevel < AccessLevel.GameMaster )
                    {
                        if ( armor.AllowFemaleWearer )
                            m.SendLocalizedMessage( 1010388 ); // Only females can wear this.
                        else
                            m.SendMessage( "You may not wear this." );

                        m.AddToBackpack( armor );
                    }
                    else if ( !armor.AllowFemaleWearer && m.Female && m.AccessLevel < AccessLevel.GameMaster )
                    {
                        if ( armor.AllowMaleWearer )
                            m.SendLocalizedMessage( 1063343 ); // Only males can wear this.
                        else
                            m.SendMessage( "You may not wear this." );

                        m.AddToBackpack( armor );
                    }
                }
            }
        }
 
Ok yes now no errors, but my pg with 100 magery can equip the plates.. very strange… :| from here he should not equip that..
[doublepost=1552315187][/doublepost]wait wait I create a new pg and seems works :)
[doublepost=1552315220][/doublepost]wait wait I create a new pg and seems works :)
[doublepost=1552315327][/doublepost]nuhm not it's was the low dex :asd:
[doublepost=1552316488][/doublepost]Ok Loki now works

public override bool CanEquip( Mobile from )
{
if (from.Skills[SkillName.Magery].Base > 20) return false;
if ( !Ethics.Ethic.CheckEquip( from, this ) )
[doublepost=1552316535][/doublepost]do not go crazy !ehehe
[doublepost=1552317039][/doublepost]Ok now I will try with single piece of armors




*




[doublepost=1552317639][/doublepost]Ok I'm tried to put it to the PlateChest.cs

errors:

+ Items / Armor / Plate / PlateChest.cs:
CS0161: Line 38: 'Server.Items.PlateChest.CanEquip (Server.Mobile)': not all code paths return a value.

namespace Server.Items
{
[FlipableAttribute( 0x1415, 0x1416 )]
public class PlateChest : BaseArmor
{
public override int BasePhysicalResistance{ get{ return 5; } }
public override int BaseFireResistance{ get{ return 0; } }
public override int BaseColdResistance{ get{ return 0; } }
public override int BasePoisonResistance{ get{ return 0; } }
public override int BaseEnergyResistance{ get{ return 0; } }

public override int InitMinHits{ get{ return 50; } }
public override int InitMaxHits{ get{ return 65; } }
public override int AosStrReq{ get{ return 95; } }
public override int OldStrReq{ get{ return 60; } }
public override int OldDexBonus{ get{ return -8; } }
public override int ArmorBase{ get{ return 40; } }
public override ArmorMaterialType MaterialType{ get{ return ArmorMaterialType.Plate; } }

[Constructable]
public PlateChest() : base( 0x1415 )
{
Attributes.BonusDex = -8;
Weight = 10.0;
}
public PlateChest( Serial serial ) : base( serial )
{
}
public override bool CanEquip( Mobile from )
{
if (from.Skills[SkillName.Magery].Base > 20) return false; <<<<<<<<<<<<<<
}

public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 );
}

public override void Deserialize(GenericReader reader)
{
base.Deserialize( reader );
int version = reader.ReadInt();
if ( Weight == 1.0 )
Weight = 10.0;
}
}
}



NOW WORKS
public override bool CanEquip( Mobile from )
{
if (from.Skills[SkillName.Magery].Base > 20) return false;
return base.CanEquip(from); <<< THIS MISSED>>>
}

Thanks Lokai for you help!!
 
Last edited:
Back