Server.Guilds.BaseGuild.FindByName C# (CSharp) Method

FindByName() public static method

public static FindByName ( string name ) : BaseGuild
name string
return BaseGuild
		public static BaseGuild FindByName( string name )
		{
			foreach ( BaseGuild g in m_GuildList.Values )
			{
				if ( g.Name == name )
					return g;
			}

			return null;
		}

Usage Example

Ejemplo n.º 1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (!(sender.Mobile is PlayerMobile pm) || pm.Guild != null)
            {
                return; // Sanity
            }

            switch (info.ButtonID)
            {
            case 1:
            {
                var tName   = info.GetTextEntry(5);
                var tAbbrev = info.GetTextEntry(6);

                var guildName   = tName == null ? "" : tName.Text;
                var guildAbbrev = tAbbrev == null ? "" : tAbbrev.Text;

                guildName   = Utility.FixHtml(guildName.Trim());
                guildAbbrev = Utility.FixHtml(guildAbbrev.Trim());

                if (guildName.Length <= 0)
                {
                    pm.SendLocalizedMessage(1070884);         // Guild name cannot be blank.
                }
                else if (guildAbbrev.Length <= 0)
                {
                    pm.SendLocalizedMessage(1070885);         // You must provide a guild abbreviation.
                }
                else if (guildName.Length > Guild.NameLimit)
                {
                    pm.SendLocalizedMessage(
                        1063036,
                        Guild.NameLimit.ToString()
                        );     // A guild name cannot be more than ~1_val~ characters in length.
                }
                else if (guildAbbrev.Length > Guild.AbbrevLimit)
                {
                    pm.SendLocalizedMessage(
                        1063037,
                        Guild.AbbrevLimit.ToString()
                        );     // An abbreviation cannot exceed ~1_val~ characters in length.
                }
                else if (BaseGuild.FindByAbbrev(guildAbbrev) != null || !BaseGuildGump.CheckProfanity(guildAbbrev))
                {
                    pm.SendLocalizedMessage(501153);         // That abbreviation is not available.
                }
                else if (BaseGuild.FindByName(guildName) != null || !BaseGuildGump.CheckProfanity(guildName))
                {
                    pm.SendLocalizedMessage(1063000);         // That guild name is not available.
                }
                else if (!Banker.Withdraw(pm, Guild.RegistrationFee))
                {
                    pm.SendLocalizedMessage(
                        1063001,
                        Guild.RegistrationFee
                        .ToString()
                        );     // You do not possess the ~1_val~ gold piece fee required to create a guild.
                }
                else
                {
                    pm.SendLocalizedMessage(
                        1060398,
                        Guild.RegistrationFee.ToString()
                        );                                    // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                    pm.SendLocalizedMessage(1063238);         // Your new guild has been founded.
                    pm.Guild = new Guild(pm, guildName, guildAbbrev);
                }

                break;
            }

            case 2:
            {
                pm.AcceptGuildInvites = !pm.AcceptGuildInvites;

                if (pm.AcceptGuildInvites)
                {
                    pm.SendLocalizedMessage(1070699);         // You are now accepting guild invitations.
                }
                else
                {
                    pm.SendLocalizedMessage(1070698);         // You are now ignoring guild invitations.
                }

                break;
            }
            }
        }
All Usage Examples Of Server.Guilds.BaseGuild::FindByName