on request of @iAegle here is the C# code from my (not released yet) RCON plugin which reads the output from the console after you've executed a command.
This is not perfect, because it waits 1 sec which makes command processing not really fast. You can change it to something lower however i do not recommend it
Function
Usage example
This is not perfect, because it waits 1 sec which makes command processing not really fast. You can change it to something lower however i do not recommend it
Function
Code:
string readResponse(string identifier)
{
string[] content = File.ReadAllLines("addon\\logs\\console.log");
bool add = false;
string output = "";
foreach (string z in content)
{
string r = "";
try { r = z.Substring(11); } catch { }
if(add) { output += r; output += "\n"; }
if (r == identifier) add = true;
}
return output;
}Usage example
Code:
Random random = new Random();
string id = Convert.ToString(random.Next(1, 99999));
ServerPrint("]" + cmd.Replace("\r\n", "").Replace("\n", ""));
ServerLog(LogType.LogConsole, id);
ServerCommand(cmd);
Thread.Sleep(1000); //wait for the command to process
string lulz = readResponse(id);
return lulz;
