Timed Event System
By: Pwntzyou
Intro:
Since I have switched from ascent based emulators to Mangos based ones, the only thing I found missing was a timed event system, that being said... I waved my magical wand around and created one.
This C++ addon can be used for -anything- that uses C++... not just Mangos and TC2.
It consists of two files
(Both need to be added to the project before a compile)
*THERE IS NO NEED TO TOUCH ANYTHING IN EITHER OF THE TWO FILES*
TimedEvent.cpp
TimedEvent.h
Getting it working:
1. The script using the timed events MUST have a #include TimedEvent.h at the top
2. There are two methods for adding timed methods, one for a function belonging to a class, the other for a function not belonging to a class.
EX:
Code:
//Format for function without a class
...(&function, "name", (void*)data, time in ms, repeats [0 for infinite]);
//Format for function with a class
...(&SC, &SomeClass::Function, "name", (void*)data, time in ms, repeats [0 for infinite]);
//Function without a class that will call the function HelloWorld(void* data) once after two seconds
_TimedEvent* te = new _TimedEvent;
te->newTimedEvent(&HelloWorld, "Hello World", (void*)0, 2000, 1);
//Function with a class that will call the function SomeClass::HelloWorld(void* data) twice with a five second interval
SomeClass SC;
TimedEvent<SomeClass>* te = new TimedEvent<SomeClass>;
te->newTimedEvent(&SC, &SomeClass::HelloWorld, "HW_Class", (void*)0, 5000, 2);
Things to notice:
-All functions you want timed events to trigger need the parameters (void* data) and only that.
All of you C++ noobies out there don't start crying, you can still pass all of the data you want through the function!
Code:
//This will pass the number 1337 to function someInt(void* data)
void someInt(void* data)
{
int aNumber = (int)data;
//Do whatever you want to do past here... aNumber is = to 1337 in this example
}
_TimedEvent* te = new _TimedEvent;
te->newTimedEvent(&someInt, "C++ Noobs", (void*)1337, 2000, 1);
As you can see we passed (void*)1337 as our parameter in our timed event, whenever you pass data through a timed event it is crucial to have (void*) in front of it.
In the function we accessed you will also notice we had (int) in front of "data" this changes data from void* to an int. This method can be used for any type of variable.
Now I know you C++ noobs are still freaking out because you want to pass multiple parameters through, we can use something called a struct.
Code:
struct myData
{
int aNumber;
string aString;
};
void anotherExample(void* data)
{
myData* mData = (myData*)data
//Do what ever you want after this
}
myData * mData = new myData;
mData->aNumber = 1337;
mData->aString = "Pwntzyou Owns";
_TimedEvent* te = new _TimedEvent;
te->newTimedEvent(&anotherExample, "C++ Noobs", (void*)mData, 2000, 1);
Hopefully that should clear up some of the questions but feel free to ask me more.
Last but not least we have the delete a timed event function... oh how I love this one
Code:
//Put the name of the timed event in there, and it will stop running!
RemoveTimedEvent("NAME");
Download:
Download (Password: pwntzyou)
Filebeam - Beam up that File Scottie!
Enjoy^^