public void JoinGuild(RealmTime t, JoinGuildPacket pkt)
 {
     var db = new Database();
     var gStruct = db.GetGuild(pkt.GuildName);
     if (psr.Player.Invited == false)
     {
         SendInfo("You need to be invited to join a guild!");
     }
     if (gStruct != null)
     {
         var g = db.ChangeGuild(psr.Account, gStruct.Id, 0, 0, false);
         if (g != null)
         {
             psr.Account.Guild = g;
             Guild = g.Name;
             GuildRank = g.Rank;
             UpdateCount++;
             foreach (var p in RealmManager.GuildMembersOf(g.Name))
             {
                 p.Client.SendPacket(new TextPacket()
                 {
                     BubbleTime = 0,
                     Stars = -1,
                     //Name = "@" + psr.Account.Name + " has joined the guild!"
                     Name = "",
                     Recipient = "*Guild*",
                     Text = psr.Account.Name + " has joined the guild!"
                 });
             }
         }
     }
 }
示例#2
0
 public void JoinGuild(JoinGuildPacket pkt)
 {
     if (psr.Account.Guild.Name != "" || psr.Account.Guild.Id != 0 || psr.Account.Guild.Rank != -1 || psr.Account.Guild.Id != 0 && psr.Account.Guild.Rank != -1)
     {
         Console.WriteLine(psr.Account.Guild.Name + "!" + psr.Account.Guild.Id + "!" + psr.Account.Guild.Rank);
         psr.SendPacket(new TextPacket()
         {
             BubbleTime = 0,
             Name = "",
             Stars = -1,
             Text = "You already are in a guild!"
         });
         return;
     }
     if (psr.Player.Invited == false)
     {
         psr.SendPacket(new TextPacket()
         {
             BubbleTime = 0,
             Name = "",
             Stars = -1,
             Text = "You need to be invited to join a guild!"
         });
         return;
     }
     using (Database dbx = new Database())
     {
         var cmd = dbx.CreateQuery();
         cmd.CommandText = "UPDATE accounts SET guild=@guildId, guildRank='0' WHERE id=@accId";
         cmd.Parameters.AddWithValue("@accId", psr.Account.AccountId);
         cmd.Parameters.AddWithValue("@guildId", dbx.GetGuildIdByName(pkt.Name));
         if (cmd.ExecuteNonQuery() == 0)
         {
             psr.SendPacket(new TextPacket()
             {
                 BubbleTime = 0,
                 Name = "",
                 Stars = -1,
                 Text = "Error changing the guild in the account data!"
             });
             return;
         }
         psr.Account.Guild = new Guild()
         {
             Id = dbx.GetGuildIdByName(pkt.Name),
             Name = pkt.Name,
             Rank = 0
         };
         if(dbx.AddToGuildMembers(psr.Account, dbx.GetGuildIdByName(pkt.Name)) == false)
         {
             psr.SendPacket(new TextPacket()
             {
                 BubbleTime = 0,
                 Name = "",
                 Stars = -1,
                 Text = "Error adding the account to the guild's members list!"
             });
             return;
         }
         foreach (var i in RealmManager.Clients.Values)
         {
             if (i.Account.Guild.Name == psr.Account.Guild.Name)
             {
                 i.SendPacket(new TextPacket()
                 {
                     BubbleTime = 0,
                     Name = "",
                     Stars = -1,
                     Text = psr.Account.Name + " joined the guild."
                 });
             }
         }
     }
 }