public void CreateGuild(RealmTime t, CreateGuildPacket pkt)
 {
     bool GuildsActive = true;
     if (GuildsActive == false)
     {
         psr.SendPacket(new CreateGuildResultPacket()
         {
             Success = false,
             ResultMessage = "Guilds currently disabled!"
         });
         return;
     }
     else
     {
         try
         {
             string name = pkt.Name.ToString();
             if (psr.Account.Stats.Fame >= 1000 || Guild != "")
             {
                 if (name != "")
                 {
                     if (new Database().GetGuild(name) != null)
                     {
                         psr.SendPacket(new CreateGuildResultPacket()
                         {
                             Success = false,
                             ResultMessage = "Guild already exists!"
                         });
                         return;
                     }
                     using (Database db1 = new Database())
                     {
                         try
                         {
                             if (Guild != "")
                             {
                                 string oldname = psr.Account.Guild.Name;
                                 Guild g = db1.ChangeGuild(psr.Account, db1.GetGuildId(psr.Account.Guild.Name), 0, true);
                                 psr.Account.Guild.Name = g.Name;
                                 psr.Account.Guild.Rank = 0;
                                 Guild = g.Name;
                                 GuildRank = 0;
                                 UpdateCount++;
                                 psr.SendPacket(new NotificationPacket()
                                 {
                                     Text = "Left guild " + oldname,
                                     Color = new ARGB(0xFF008800),
                                     ObjectId = Id
                                 });
                                 psr.SendPacket(new CreateGuildResultPacket()
                                 {
                                     Success = true
                                 });
                                 foreach (var i in RealmManager.Worlds)
                                 {
                                     if (i.Key != 0)
                                     {
                                         foreach (var e in i.Value.Players)
                                         {
                                             if (e.Value.Client.Account.Guild.Name == oldname)
                                             {
                                                 e.Value.Client.SendPacket(new TextPacket()
                                                 {
                                                     BubbleTime = 0,
                                                     Stars = -1,
                                                     Name = "",
                                                     Recipient = "*Guild*",
                                                     Text = psr.Account.Name + " has left the guild!"
                                                 });
                                             }
                                         }
                                     }
                                 }
                                 return;
                             }
                             else
                             {
                                 if (pkt.Name != "")
                                 {
                                     Guild g = db1.CreateGuild(psr.Account, pkt.Name);
                                     psr.Account.Guild.Name = g.Name;
                                     psr.Account.Guild.Rank = g.Rank;
                                     Guild = g.Name;
                                     GuildRank = g.Rank;
                                     psr.SendPacket(new NotificationPacket()
                                     {
                                         Text = "Created guild " + g.Name,
                                         Color = new ARGB(0xFF008800),
                                         ObjectId = Id
                                     });
                                     psr.SendPacket(new CreateGuildResultPacket()
                                     {
                                         Success = true,
                                         ResultMessage = "Success!"
                                     });
                                     CurrentFame = psr.Account.Stats.Fame = psr.Database.UpdateFame(psr.Account, -1000);
                                     UpdateCount++;
                                     return;
                                 }
                                 else
                                 {
                                     psr.SendPacket(new CreateGuildResultPacket()
                                     {
                                         Success = false,
                                         ResultMessage = "Guild name cannot be blank!"
                                     });
                                     return;
                                 }
                             }
                         }
                         catch (Exception e)
                         {
                             psr.SendPacket(new CreateGuildResultPacket()
                             {
                                 Success = false,
                                 ResultMessage = e.Message
                             });
                             return;
                         }
                     }
                 }
                 else
                 {
                     psr.SendPacket(new CreateGuildResultPacket()
                     {
                         Success = false,
                         ResultMessage = "Name cannot be empty!"
                     });
                 }
             }
             else
             {
                 psr.SendPacket(new CreateGuildResultPacket()
                 {
                     Success = false,
                     ResultMessage = "Not enough fame!"
                 });
             }
         }
         catch (Exception)
         {
             Console.WriteLine("Error at line 755 of Player.cs");
             psr.SendPacket(new TextPacket()
             {
                 Name = "",
                 Stars = -1,
                 BubbleTime = 0,
                 Text = "Error creating guild!"
             });
         }
     }
 }