Release Read command output
#1
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
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;
Reply

#2
<3 5char
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.