Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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
CSHARP Code
  1. string readResponse(string identifier)
  2. {
  3. string[] content = File.ReadAllLines("addon\\logs\\console.log");
  4. bool add = false;
  5. string output = "";
  6. foreach (string z in content)
  7. {
  8. string r = "";
  9. try { r = z.Substring(11); } catch { }
  10. if(add) { output += r; output += "\n"; }
  11. if (r == identifier) add = true;
  12. }
  13. return output;
  14. }


Usage example
CSHARP Code
  1. Random random = new Random();
  2. string id = Convert.ToString(random.Next(1, 99999));
  3. ServerPrint("]" + cmd.Replace("\r\n", "").Replace("\n", ""));
  4. ServerLog(LogType.LogConsole, id);
  5. ServerCommand(cmd);
  6. Thread.Sleep(1000); //wait for the command to process
  7. string lulz = readResponse(id);
  8. 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



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help auto command Dynasty 6 4,351 08-26-2013, 16:05
Last Post: hillbilly
Tongue [Request] read if you have a cs:go code:) rawr-saours 5 4,053 04-05-2013, 18:15
Last Post: SuperNovaAO
  Dont Read Stocker 1 2,397 02-24-2013, 19:38
Last Post: JariZ
  !come command Dr3am95 12 7,842 02-12-2013, 12:08
Last Post: SgtLegend
  whats the command to get string length pedjas 4 3,089 01-20-2013, 18:30
Last Post: pedjas
  Help Read from console rcon in Delphi richard1994x 9 6,592 12-01-2012, 17:34
Last Post: richard1994x
  [Request] Team change by admin command. Dumas 10 8,877 11-29-2012, 21:38
Last Post: 99IRock
Question Help kick command still need help koro35 3 3,296 11-27-2012, 22:45
Last Post: koro35
  [Help] How to hide a command? korsika 4 4,106 10-27-2012, 23:30
Last Post: korsika
  Please read this. JariZ 10 6,354 10-17-2012, 20:56
Last Post: diegogt

Forum Jump:


Users browsing this thread:
1 Guest(s)

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