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


C# Server.KillPlayer方法代码示例

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


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

示例1: Ban

 public bool Ban(Server server, int sourceClientId, int targetClientId, string reason)
 {
     if (!server.PlayerHasPrivilege(sourceClientId, ServerClientMisc.Privilege.ban))
     {
         server.SendMessage(sourceClientId, string.Format(server.language.Get("Server_CommandInsufficientPrivileges"), server.colorError));
         return false;
     }
     if (!reason.Equals(""))
     {
         reason = server.language.Get("Server_CommandKickBanReason") + reason + ".";
     }
     ClientOnServer targetClient = server.GetClient(targetClientId);
     if (targetClient != null)
     {
         if (targetClient.clientGroup.IsSuperior(server.GetClient(sourceClientId).clientGroup) || targetClient.clientGroup.EqualLevel(server.GetClient(sourceClientId).clientGroup))
         {
             server.SendMessage(sourceClientId, string.Format(server.language.Get("Server_CommandTargetUserSuperior"), server.colorError));
             return false;
         }
         string targetName = targetClient.playername;
         string sourceName = server.GetClient(sourceClientId).playername;
         string targetNameColored = targetClient.ColoredPlayername(server.colorImportant);
         string sourceNameColored = server.GetClient(sourceClientId).ColoredPlayername(server.colorImportant);
         server.banlist.BanPlayer(targetName, sourceName, reason);
         SaveBanlist(server);
         server.SendMessageToAll(string.Format(server.language.Get("Server_CommandBanMessage"), server.colorImportant, targetNameColored, sourceNameColored, reason));
         server.ServerEventLog(string.Format("{0} bans {1}.{2}", sourceName, targetName, reason));
         server.SendPacket(targetClientId, ServerPackets.DisconnectPlayer(string.Format(server.language.Get("Server_CommandBanNotification"), reason)));
         server.KillPlayer(targetClientId);
         return true;
     }
     server.SendMessage(sourceClientId, string.Format(server.language.Get("Server_CommandNonexistantID"), server.colorError, targetClientId));
     return false;
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:34,代码来源:BanList.cs

示例2: Update

    public override void Update(Server server, float dt)
    {
        pingtimer.Update(
        delegate
        {
            if (server.exit.GetExit())
            {
                //Instantly return if server wants to exit
                return;
            }
            List<int> keysToDelete = new List<int>();
            foreach (var k in server.clients)
            {
                // Check if client is alive. Detect half-dropped connections.
                if (!k.Value.Ping.Send(server.platform)/*&& k.Value.state == ClientStateOnServer.Playing*/)
                {
                    if (k.Value.Ping.Timeout(server.platform))
                    {
                        Console.WriteLine(k.Key + ": ping timeout. Disconnecting...");
                        keysToDelete.Add(k.Key);
                    }
                }
                else
                {
                    server.SendPacket(k.Key, ServerPackets.Ping());
                }
            }

            foreach (int key in keysToDelete)
            {
                server.KillPlayer(key);
            }
        }
        );
    }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:35,代码来源:NotifyPing.cs

示例3: Update

    public override void Update(Server server, float dt)
    {
        if (!loaded)
        {
            loaded = true;
            LoadBanlist(server);
        }

        if (server.banlist.ClearTimeBans() > 0)
        {
            SaveBanlist(server);
        }

        foreach (KeyValuePair<int, ClientOnServer> k in server.clients)
        {
            int clientId = k.Key;
            ClientOnServer c = k.Value;
            IPEndPointCi iep1 = c.socket.RemoteEndPoint();

            if (server.banlist.IsIPBanned(iep1.AddressToString()))
            {
                IPEntry entry = server.banlist.GetIPEntry(iep1.AddressToString());
                string reason = entry.Reason;
                if (string.IsNullOrEmpty(reason))
                    reason = "";
                server.SendPacket(clientId, ServerPackets.DisconnectPlayer(string.Format(server.language.ServerIPBanned(), reason)));
                Console.WriteLine(string.Format("Banned IP {0} tries to connect.", iep1.AddressToString()));
                server.ServerEventLog(string.Format("Banned IP {0} tries to connect.", iep1.AddressToString()));
                server.KillPlayer(clientId);
                continue;
            }

            string username = c.playername;
            if (server.banlist.IsUserBanned(username))
            {
                UserEntry entry = server.banlist.GetUserEntry(username);
                string reason = entry.Reason;
                if (string.IsNullOrEmpty(reason))
                    reason = "";
                server.SendPacket(clientId, ServerPackets.DisconnectPlayer(string.Format(server.language.ServerUsernameBanned(), reason)));
                Console.WriteLine(string.Format("{0} fails to join (banned username: {1}).", (c.socket.RemoteEndPoint()).AddressToString(), username));
                server.ServerEventLog(string.Format("{0} fails to join (banned username: {1}).", (c.socket.RemoteEndPoint()).AddressToString(), username));
                server.KillPlayer(clientId);
                continue;
            }
        }
    }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:47,代码来源:BanList.cs


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