Esempio n. 1
0
        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!"
                        });
                    }
                }
            }
        }
Esempio n. 2
0
        public void GuildRemove(RealmTime t, GuildRemovePacket pkt)
        {
            var pname = pkt.Name;

            try
            {
                var p = RealmManager.FindPlayer(pname);
                if (p != null && p.Guild == Guild)
                {
                    var db = new Database();
                    var g  = db.ChangeGuild(p.Client.Account, p.Client.Account.Guild.Id, p.GuildRank, p.Client.Account.Guild.Fame, true);
                    p.Guild                = "";
                    p.GuildRank            = 0;
                    p.Client.Account.Guild = g;
                    p.UpdateCount++;
                    p.SendGuild("You have been kicked from the guild.");
                    foreach (var pl in RealmManager.GuildMembersOf(Guild))
                    {
                        pl.SendGuild(p.nName + " has been kicked from the guild by " + nName + ".");
                    }
                }
                else
                {
                    try
                    {
                        var db    = new Database();
                        var other = db.GetAccount(pname);
                        if (other.Guild.Name == Guild)
                        {
                            db.ChangeGuild(other, other.Guild.Id, other.Guild.Rank, other.Guild.Fame, true);
                            foreach (var pl in RealmManager.GuildMembersOf(Guild))
                            {
                                pl.SendGuild(pname + " has been kicked from the guild by " + nName + ".");
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        psr.SendPacket(new TextPacket()
                        {
                            BubbleTime = 0,
                            Stars      = -1,
                            Name       = "*Error*",
                            Text       = e.Message
                        });
                    }
                }
            }
            catch (Exception e)
            {
                psr.SendPacket(new TextPacket()
                {
                    BubbleTime = 0,
                    Stars      = -1,
                    Name       = "*Error*",
                    Text       = e.Message
                });
            }
        }
Esempio n. 3
0
        public void ChangeGuildRank(RealmTime t, ChangeGuildRankPacket pkt)
        {
            var pname = pkt.Name;
            var rank  = pkt.GuildRank;

            if (GuildRank >= 20)
            {
                var other = RealmManager.FindPlayer(pname);
                if (other != null && other.Guild == Guild)
                {
                    var rankname  = ResolveRankName(other.GuildRank);
                    var rankname2 = ResolveRankName(rank);
                    other.GuildRank = rank;
                    other.Client.Account.Guild.Rank = rank;
                    new Database().ChangeGuild(other.Client.Account, other.Client.Account.Guild.Id, other.GuildRank, other.Client.Account.Guild.Fame, false);
                    other.UpdateCount++;
                    foreach (var p in RealmManager.GuildMembersOf(Guild))
                    {
                        p.Client.SendPacket(new TextPacket()
                        {
                            BubbleTime = 0,
                            Stars      = -1,
                            Name       = "",
                            Recipient  = "*Guild*",
                            Text       = other.Client.Account.Name + " has been demoted to " + rankname2 + "."
                        });
                    }
                }
                else
                {
                    try
                    {
                        var db  = new Database();
                        var acc = db.GetAccount(pname);
                        if (acc.Guild.Name == Guild)
                        {
                            var rankname  = ResolveRankName(acc.Guild.Rank);
                            var rankname2 = ResolveRankName(rank);
                            db.ChangeGuild(acc, acc.Guild.Id, rank, acc.Guild.Fame, false);
                            foreach (var p in RealmManager.GuildMembersOf(Guild))
                            {
                                p.Client.SendPacket(new TextPacket()
                                {
                                    BubbleTime = 0,
                                    Stars      = -1,
                                    Name       = "",
                                    Recipient  = "*Guild*",
                                    Text       = acc.Name + " has been promoted to " + rankname2 + "."
                                });
                            }
                        }
                        else
                        {
                            psr.SendPacket(new TextPacket()
                            {
                                BubbleTime = 0,
                                Stars      = -1,
                                Name       = "*Error*",
                                Text       = "You can only change a player in your guild."
                            });
                        }
                    }
                    catch (Exception e)
                    {
                        psr.SendPacket(new TextPacket()
                        {
                            BubbleTime = 0,
                            Stars      = -1,
                            Name       = "*Error*",
                            Text       = e.Message
                        });
                    }
                }
            }
            else
            {
                psr.SendPacket(new TextPacket()
                {
                    BubbleTime = 0,
                    Stars      = -1,
                    Name       = "",
                    Text       = "Members and initiates cannot promote!"
                });
            }
        }