QuestionHelpCall Function on Variable Change

Posts 15 of 5 · Page 1 of 1
Call Function on Variable Change
I'm working on a custom server tool for a game I'm trying to trigger an event when a variable in the memory changes a certain way.

Example of what I'm trying to do in a timer

 
Code

int client0alivevalue = memory.ReadByte((IntPtr)address + (clientsize * 0));


if (client0alivevalue == 0 then changes from 0 to 1)
{ do something }



So when client0alivevalue = 0 the client is dead and when it's 1 the client is alive. When the client dies and then respawns I want to trigger a function hence the example: if (client0alivevalue == 0 then changes from 0 to 1). I only want to trigger said function when the client0alivevalue changes from 0 to 1.

I hope this makes sense.
Subscribe to an eventhandle and have this code: http://stackoverflow.com/questions/5...lue-is-changed
Hope it solved some parts of your problem.

You could also do a thread event that grabs the integer repeatedly. But that would take up alot of CPU.
So i'd recommend subscribing to an eventhandle.
I suggest you to have your code injected into the target process. That will make it easy to simply check the value every x milliseconds without requiring alot of resources
Quote Originally Posted by supermarre1 View Post
Subscribe to an eventhandle and have this code: http://stackoverflow.com/questions/5...lue-is-changed
Hope it solved some parts of your problem.

You could also do a thread event that grabs the integer repeatedly. But that would take up alot of CPU.
So i'd recommend subscribing to an eventhandle.
Properties won't do him any good if the process is external and he doesn't have the code. Reading from memory in a loop isn't all that CPU intensive, just don't query too often. 100 milliseconds between checks should be fine for *most* purposes.
Quote Originally Posted by Hell_Demon View Post
Properties won't do him any good if the process is external and he doesn't have the code. Reading from memory in a loop isn't all that CPU intensive, just don't query too often. 100 milliseconds between checks should be fine for *most* purposes.
And even if he did it in a continuous loop without any sleeps, it will only use like 20% of your CPU. I tell you this from experience...
Posts 15 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?