本文整理汇总了C#中db.Database.RemoveFromGuildMembers方法的典型用法代码示例。如果您正苦于以下问题:C# Database.RemoveFromGuildMembers方法的具体用法?C# Database.RemoveFromGuildMembers怎么用?C# Database.RemoveFromGuildMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Database
的用法示例。
在下文中一共展示了Database.RemoveFromGuildMembers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LeaveGuild
public void LeaveGuild(GuildRemovePacket pkt)
{
try
{
if (psr.Account.Guild == null || psr.Account.Guild.Name == "")
{
psr.SendPacket(new CreateGuildResultPacket()
{
ResultMessage = "You don't have a guild!",
Success = false
});
return;
}
using (Database dbx = new Database())
{
var cmd = dbx.CreateQuery();
cmd.CommandText = "UPDATE accounts SET guild='0', guildRank='-1' WHERE [email protected]";
cmd.Parameters.AddWithValue("@id", psr.Account.AccountId);
if (cmd.ExecuteNonQuery() == 0)
{
psr.SendPacket(new CreateGuildResultPacket()
{
ResultMessage = "Unable to remove guild from account data!",
Success = false
});
return;
}
else
{
var members = dbx.GetGuildMembers(psr.Account);
if (!members.Contains(psr.Account.AccountId))
{
psr.SendPacket(new CreateGuildResultPacket()
{
ResultMessage = "Unable to find account in guild's members list!",
Success = false
});
return;
}
members.Remove(psr.Account.AccountId);
var newmembers = Utils.GetCommaSepString<int>(members.ToArray());
if (newmembers.Length == 0)
{
if (dbx.RemoveGuild(psr.Account) == false)
{
psr.SendPacket(new CreateGuildResultPacket()
{
ResultMessage = "Unable to delete guild!",
Success = false
});
return;
}
}
else
{
if (dbx.RemoveFromGuildMembers(psr.Account) == false)
{
psr.SendPacket(new CreateGuildResultPacket()
{
ResultMessage = "Unable to remove account from guild's members list!",
Success = false
});
return;
}
}
foreach (var i in RealmManager.Clients.Values)
{
if (i.Account.Guild.Name == psr.Account.Guild.Name && i.Account.Guild.Id == psr.Account.Guild.Id)
{
i.SendPacket(new TextPacket()
{
Name = "",
BubbleTime = 0,
Stars = -1,
Text = psr.Account.Name + " left the guild."
});
}
}
psr.Account.Guild = new Guild()
{
Id = 0,
Name = "",
Rank = -1
};
UpdateCount++;
psr.SendPacket(new CreateGuildResultPacket()
{
ResultMessage = "Successfully left the guild!",
Success = true
});
return;
}
}
}
catch
{
psr.SendPacket(new CreateGuildResultPacket()
{
ResultMessage = "Error leaving the guild!",
Success = false
//.........这里部分代码省略.........