TheGodfather

Hello I am looking for a way to make it so non faction players can enter places like Lord British's castle.

Any help would be much appreciated!
 
Code:
using System;
using Server.Mobiles;
using Server.Regions;

namespace Server.Factions
{
    public class StrongholdRegion : BaseRegion
    {
        private Faction m_Faction;
        public StrongholdRegion(Faction faction)
            : base(faction.Definition.FriendlyName, Faction.Facet, Region.DefaultPriority, faction.Definition.Stronghold.Area)
        {
            this.m_Faction = faction;

            this.Register();
        }

        public Faction Faction
        {
            get
            {
                return this.m_Faction;
            }
            set
            {
                this.m_Faction = value;
            }
        }
        public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation)
        {
            if (!base.OnMoveInto(m, d, newLocation, oldLocation))
                return false;

            if (m.IsStaff() || this.Contains(oldLocation))
                return true;
           
            if (m is PlayerMobile)
            {
                PlayerMobile pm = (PlayerMobile)m;

                if (pm.DuelContext != null)
                {
                    m.SendMessage("You may not enter this area while participating in a duel or a tournament.");
                    return false;
                }
            }

            return (Faction.Find(m, true, true) != null);
        }

        public override bool AllowHousing(Mobile from, Point3D p)
        {
            return false;
        }
    }
}

Should look like: ?

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

namespace Server.Factions
{
    public class StrongholdRegion : BaseRegion
    {
        private Faction m_Faction;
        public StrongholdRegion(Faction faction)
            : base(faction.Definition.FriendlyName, Faction.Facet, Region.DefaultPriority, faction.Definition.Stronghold.Area)
        {
            this.m_Faction = faction;

            this.Register();
        }

        public Faction Faction
        {
            get
            {
                return this.m_Faction;
            }
            set
            {
                this.m_Faction = value;
            }
        }
        public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation)
        {
            if (!base.OnMoveInto(m, d, newLocation, oldLocation))
                return true;

            if (m.IsStaff() || this.Contains(oldLocation))
                return true;
           
            if (m is PlayerMobile)
            {
                PlayerMobile pm = (PlayerMobile)m;

                if (pm.DuelContext != null)
                {
                    m.SendMessage("You may not enter this area while participating in a duel or a tournament.");
                    return true;
                }
            }

            return (Faction.Find(m, true, true) != null);
        }

        public override bool AllowHousing(Mobile from, Point3D p)
        {
            return true;
        }
    }
}
[doublepost=1473799450][/doublepost]
Keep in mind that a change like this can cause issues such as blue players blocking the sigils and such.
I disabled factions in general so just wanna open up those areas.
 
The line you need to change is:

return (Faction.Find(m, true, true) != null);

OnMoveInto is looking for a bool (true or false) to be returned. If true, the player can go in, if false, they cannot.

That line is doing a FactionFind to determine if the player is in a faction. If he is in a faction, then it returns true and he can go in. You can simply change that line to:

return true;

That will let all players in.

However, if you are not using factions, you could just delete them and the stronghold region will go away instead of changing the script.
 
The line you need to change is:

return (Faction.Find(m, true, true) != null);

OnMoveInto is looking for a bool (true or false) to be returned. If true, the player can go in, if false, they cannot.

That line is doing a FactionFind to determine if the player is in a faction. If he is in a faction, then it returns true and he can go in. You can simply change that line to:

return true;

That will let all players in.

However, if you are not using factions, you could just delete them and the stronghold region will go away instead of changing the script.

Interesting thank you for the explanation that helps a lot actually.
 
Back