Example #1
0
        /// <summary>
        /// Changes the name of the guild by ID (int guildID string guildName)
        /// </summary>
        /// <param name="plr">Player that initiated the command</param>
        /// <param name="values">List of command arguments (after command name)</param>
        /// <returns>True if command was correctly handled, false if operation was canceled</returns>
        public static bool ModifyGuildNameByID(Player plr, ref List <string> values)
        {
            if (values.Count < 2)
            {
                plr.SendClientMessage("Usage: .modify guildnamebyid <guildID> <guildName>");
                return(true);
            }

            uint   guildID   = (uint)(int)GetInt(ref values);
            string guildName = GetTotalString(ref values).Trim();

            if (string.IsNullOrEmpty(guildName))
            {
                plr.SendClientMessage("you need to specify a new guild name");
                return(true);
            }

            Guild guild = Guild.GetGuild(guildID);

            if (guild == null)
            {
                plr.SendClientMessage("The Specified guild does not exist");
                return(true);
            }

            if (Guild.GetGuild(guildName) != null)
            {
                plr.SendClientMessage("That guildname is already taken");
                return(true);
            }

            else
            {
                plr.SendClientMessage("Changing from " + guild.Info.Name + " to " + guildName);
                if (guild.Info.AllianceId != 0)
                {
                    guild.LeaveAlliance();  //sanity in case of packet changes with guild name change on guild inside alliance
                }

                GMCommandLog log = new GMCommandLog
                {
                    PlayerName = plr.Name,
                    AccountId  = (uint)plr.Client._Account.AccountId,
                    Command    = "CHANGED GUILDNAME OF: " + guild.Info.Name + " TO: " + guildName,
                    Date       = DateTime.UtcNow
                };
                CharMgr.Database.AddObject(log);

                guild.Info.Name = guildName;
                CharMgr.ChangeGuildName(guild.Info, guildName);

                return(true);
            }
        }