View previous topic :: View next topic |
Author |
Message |
Kamd Cheater Reputation: 1
Joined: 02 May 2018 Posts: 28
|
Posted: Wed May 02, 2018 8:32 pm Post subject: Using Cheat Engine Lua in C# and returning value types? |
|
|
I really want to use Cheat Engine Lua in C# .NET, and I have found out how thanks to DarkByte: forum.cheatengine.org/viewtopic.php?p=5687454
However, I've had no luck trying to make Cheat Engine Lua return any other value than integers to the pipe client so I know the return value in C#.
Please help. Thanks.
Last edited by Kamd on Thu May 03, 2018 12:11 am; edited 1 time in total |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
|
Back to top |
|
|
Kamd Cheater Reputation: 1
Joined: 02 May 2018 Posts: 28
|
Posted: Thu May 03, 2018 7:33 pm Post subject: |
|
|
How do I implement this in C#?
I open a CE trainer that does
Code: |
openLuaServer("SomeLuaServer")
|
And use the following code in C#:
Code: |
private UInt64 doCommand(string serverName, string cmdString)
{
NamedPipeClientStream s = new NamedPipeClientStream(serverName);
s.Connect();
if (s.IsConnected)
{
byte[] result = new byte[8];
byte[] command = System.Text.Encoding.ASCII.GetBytes(cmdString);
byte[] size = BitConverter.GetBytes((int)command.Length);
byte[] fullcommand = new byte[1];
fullcommand[0] = 1; // execute string
fullcommand = fullcommand.Concat(size).ToArray();
fullcommand = fullcommand.Concat(command).ToArray();
fullcommand = fullcommand.Concat(BitConverter.GetBytes((long)0)).ToArray(); //the 'parameter' value
s.Write(fullcommand, 0, fullcommand.Length);
s.Read(result, 0, 8);
s.Close();
return BitConverter.ToUInt64(result, 0);
}
else
return 0;
}
|
How would I make I make it return a different value type, for example a string value.
e.g.
Code: |
string someString = doCommand("SomeLuaServer", "return 'Hello world'");
// someString = "Hello world"
|
|
|
Back to top |
|
|
|