Example #1
0
        private static void HandleKick(GameSession session, PacketReader packet)
        {
            string target = packet.ReadUnicodeString();

            Player targetPlayer = GameServer.Storage.GetPlayerByName(target);

            if (targetPlayer == null)
            {
                return;
            }

            Guild guild = GameServer.GuildManager.GetGuildByLeader(session.Player);

            if (guild == null)
            {
                return;
            }

            if (targetPlayer.CharacterId == guild.LeaderCharacterId)
            {
                //TODO: Error packets
                return;
            }

            GuildMember selfPlayer = guild.Members.FirstOrDefault(x => x.Player == session.Player);

            if (selfPlayer == null)
            {
                return;
            }

            if (!((GuildRights)guild.Ranks[selfPlayer.Rank].Rights).HasFlag(GuildRights.CanInvite))
            {
                return;
            }

            session.Send(GuildPacket.KickConfirm(targetPlayer));
            if (targetPlayer.Session != null)
            {
                targetPlayer.Session.Send(GuildPacket.KickNotification(session.Player));
                targetPlayer.Session.FieldManager.BroadcastPacket(GuildPacket.UpdateGuildTag(targetPlayer));
            }
            guild.RemoveMember(targetPlayer);
            guild.BroadcastPacketGuild(GuildPacket.KickMember(targetPlayer, session.Player));
        }