Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Silkroad Online > SRO Coding Corner
You last visited: Today at 05:18

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Supermike online players ip list output

Discussion on Supermike online players ip list output within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jun 2018
Posts: 1
Received Thanks: 0
Supermike online players ip list output

Hello,

I want to list the ip addresses of all connected players. I have edited the "WhoIsOnline()" function in the project. The output after the cycle does not work. AgentContext and AgentContext2 edited same function.

The program does not output when it is on for a long time. The first openings can be output.

Code:
static void ConsolePoolThread(){
...
if (cmd.Contains("/whos"))
{
    AgentContext.WhosOnline();
    if ((!FilterMain.AGENT_IP2.Equals("0")) && (FilterMain.AGENT_IP2 != String.Empty))
        AgentContext2.WhosOnline();
}
...
}
public static void WhosOnline()
{
    lock (locker) {
        try
        {
            string clipboard_data = "AGENT\r\nUSERID\tCHARNAME\tIP\r\n";
            int count = 0;
            foreach (AgentContext current in clientlistgame)
            {
                if (current.m_ClientSocket.Connected)
                {
                    Console.WriteLine("Method 1: " + current.user_id + " is online! IP: " + current.ip);
                }

                if (current.m_ClientSocket.Connected && current.m_ModuleSocket.Connected)
                {
                    Console.WriteLine("Method 2: " + current.user_id + " is online! IP: " + current.ip);
                }
                clipboard_data += current.user_id + "\t" + current.charname + "\t" + current.ip+"\r\n";
                count++;
            }
            Console.WriteLine("Total agent count: " + count);
            var rand = new Random();
            var _rand = rand.Next(99999);
            Program.OutputFile("iplog_" + string.Concat(DateTime.Now.ToString("yyyyMMddHHmmss")) + "_" + _rand + "_agent.txt", clipboard_data);
        }
        catch { }
    }
}
Output Function
dooq is offline  
Old 11/15/2018, 22:48   #2
 
elite*gold: 100
Join Date: Sep 2017
Posts: 1,109
Received Thanks: 903
You can do something better for your Output function:
Code:
public static void OutputFile(string filename, string content)
        {
            try
            {
                System.IO.StreamWriter log = new System.IO.StreamWriter(filename, true);
                log.WriteLine(content);
                log.Close();
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Output error. Error:" + e.Message);
                Console.ResetColor();
            }
        }
#HB is offline  
Old 11/18/2018, 17:13   #3
 
B1Q's Avatar
 
elite*gold: 350
Join Date: Aug 2015
Posts: 1,999
Received Thanks: 1,188


use this one liner for the output function

Quote:
Originally Posted by #HB View Post
You can do something better for your Output function:
Code:
public static void OutputFile(string filename, string content)
        {
            try
            {
                System.IO.StreamWriter log = new System.IO.StreamWriter(filename, true);
                log.WriteLine(content *+ Environment.NewLine*);
                log.Close();
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Output error. Error:" + e.Message);
                Console.ResetColor();
            }
        }
The WriteLine methods append a newline "\r\n" at each call
B1Q is offline  
Reply


Similar Threads Similar Threads
[LIST] WarRock Privat Server List! [LIST]
07/27/2013 - WarRock - 46 Replies
http://archiv.so/images/2013/03/01/bQaXx.png Hallo elitepvpers Community! Da es in letzter Zeit viele unnötige Threads, mit Fragen zu guten Privat Servern gab, möchte ich es Neulingen (Newbies) etwas erleichern! Und das ganze soll durch diese Liste an mir bekannten WarRock P-Servern geschehen. Sollten euch noch weitere Server bekannt sein, schreibt den Thread-Link & Namen als Kommentar, damit ich diesen Server eventueller Weise auch noch rein editieren kann.



All times are GMT +1. The time now is 05:18.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.