コード例 #1
0
        //BanAction
        public static void ProcessAction(Client client, Player player, BanAction action)
        {
            var target = Player.Find(action.Name);

            if (target != null)
            {
                if (string.IsNullOrEmpty(Ban.CheckBan(target.User, "")))
                {
                    if (action.BanIp == true)
                    {
                        Ban.Add(
                            target.User, action.DurationDays, action.Reason, player.Name, target.Client?.GetIp() ?? ""
                            );
                    }
                    else
                    {
                        Ban.Add(target.User, action.DurationDays, action.Reason, player.Name, "");
                    }

                    UserActivityHistory.LogActivity(target?.UserId ?? Guid.Empty, target?.Id ?? Guid.Empty, target?.Client?.GetIp(), UserActivityHistory.PeerType.Client, UserActivityHistory.UserAction.DisconnectBan, $"{target.User?.Name},{target.Name}");

                    target.Client?.Disconnect();
                    PacketSender.SendChatMsg(player, Strings.Account.banned.ToString(target.Name), Enums.ChatMessageType.Admin, Color.Red);
                }
                else
                {
                    PacketSender.SendChatMsg(player, Strings.Account.alreadybanned.ToString(target.Name), Enums.ChatMessageType.Admin, Color.Red);
                }
            }
            else
            {
                PacketSender.SendChatMsg(player, Strings.Player.offline, Enums.ChatMessageType.Admin);
            }
        }
コード例 #2
0
        //KickAction
        public static void ProcessAction(Client client, Player player, KickAction action)
        {
            var target = Player.FindOnline(action.Name);

            if (target != null)
            {
                UserActivityHistory.LogActivity(target?.UserId ?? Guid.Empty, target?.Id ?? Guid.Empty, target?.Client?.GetIp(), UserActivityHistory.PeerType.Client, UserActivityHistory.UserAction.DisconnectKick, $"{target.User?.Name},{target.Name}");

                PacketSender.SendGlobalMsg(Strings.Player.kicked.ToString(target.Name, player.Name));
                target.Client?.Disconnect(); //Kick em'
            }
            else
            {
                PacketSender.SendChatMsg(player, Strings.Player.offline, Enums.ChatMessageType.Admin);
            }
        }