当前位置: 首页>>代码示例>>C#>>正文


C# Database.AddToGuildMembers方法代码示例

本文整理汇总了C#中db.Database.AddToGuildMembers方法的典型用法代码示例。如果您正苦于以下问题:C# Database.AddToGuildMembers方法的具体用法?C# Database.AddToGuildMembers怎么用?C# Database.AddToGuildMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在db.Database的用法示例。


在下文中一共展示了Database.AddToGuildMembers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: JoinGuild

 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 [email protected], guildRank='0' WHERE [email protected]";
         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."
                 });
             }
         }
     }
 }
开发者ID:lcnvdl,项目名称:rotmg-server,代码行数:74,代码来源:Player.cs


注:本文中的db.Database.AddToGuildMembers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。