Ejemplo n.º 1
0
        public static void HandleCommand(string commandArgs)
        {
            ClientObject pmPlayer      = null;
            int          matchedLength = 0;

            foreach (ClientObject testPlayer in ClientHandler.GetClients())
            {
                //Only search authenticated players
                if (testPlayer.authenticated)
                {
                    //Try to match the longest player name
                    if (commandArgs.StartsWith(testPlayer.playerName) && testPlayer.playerName.Length > matchedLength)
                    {
                        //Double check there is a space after the player name
                        if ((commandArgs.Length > (testPlayer.playerName.Length + 1)) ? commandArgs[testPlayer.playerName.Length] == ' ' : false)
                        {
                            pmPlayer      = testPlayer;
                            matchedLength = testPlayer.playerName.Length;
                        }
                    }
                }
            }
            if (pmPlayer != null)
            {
                string messageText = commandArgs.Substring(pmPlayer.playerName.Length + 1);
                Messages.Chat.SendChatMessageToClient(pmPlayer, messageText);
            }
            else
            {
                DarkLog.Normal("Player not found!");
            }
        }
Ejemplo n.º 2
0
        private static void ConnectionStats(string commandArgs)
        {
            //Do some shit here.
            long bytesQueuedOutTotal = 0;
            long bytesSentTotal      = 0;
            long bytesReceivedTotal  = 0;

            DarkLog.Normal("Connection stats:");
            foreach (ClientObject client in ClientHandler.GetClients())
            {
                if (client.authenticated)
                {
                    bytesQueuedOutTotal += client.bytesQueuedOut;
                    bytesSentTotal      += client.bytesSent;
                    bytesReceivedTotal  += client.bytesReceived;
                    DarkLog.Normal("Player '" + client.playerName + "', queued out: " + client.bytesQueuedOut + ", sent: " + client.bytesSent + ", received: " + client.bytesReceived);
                }
            }
            DarkLog.Normal("Server, queued out: " + bytesQueuedOutTotal + ", sent: " + bytesSentTotal + ", received: " + bytesReceivedTotal);
        }