.................
Although the correct data is gone, it does not return and returns the same errorQuote:
set a breakpoint with cheat engine at that function in the client, check if its being triggered if you run your function. if the breakpoint does get triggered, step through the function and check where the error is coming from. alternatively, you can also debug your dll through visual studio, just google how to do it. there are a few other forums that have a ton of informations on these basics. just google "debug game hack dll" - maybe you will find a *guide* or some *unknown* resources ;)
is the CPythonPlayer Pointer correct? compare it to a native call -> set the breakpoint again, call it natively through the metin2 client somehow, write down all the register values. let the code run through and call the function manually through your hack and compare the register valuesQuote:
Although the correct data is gone, it does not return and returns the same error
CPythonPlayer is right, I use it in many places GetNameByVID, GetTargetVID etc. but I tried a lot for get status and none of them worked. never made an example of this before,Quote:
is the CPythonPlayer Pointer correct? compare it to a native call -> set the breakpoint again, call it natively through the metin2 client somehow, write down all the register values. let the code run through and call the function manually through your hack and compare the register values
// import the player module first
#ifdef GAMEFORGE
player_module_ = PyImport_ImportModule("playerm2g2");
#else
player_module_ = PyImport_ImportModule("player");
#endif
long GetStatus(std::uint32_t type)
{
auto* args = PyTuple_New(1);
PyTuple_SetItem(args, 0, PyInt_FromLong(type));
auto* fun = PyObject_Call(
PyObject_GetAttrString(player_module_, "GetStatus"), args, nullptr);
auto const res = PyInt_AsLong(fun);
Py_DECREF(fun);
Py_XDECREF(args);
return res;
}
11/10, the by far best approach if the knowledge is thereQuote:
here is a much simpler approach without hassling with inline assembler, function pointers or addresses (except for the hook :p) in the first place:
1. hook a function that is periodically called from within the mainthread of metin2 (OnUpdate, OnRender, etc.). go for OnUpdate since you probably want to run your cheat in the background.
2. use the python c api to retrieve the GetStatus function like so (untested code):
Refer to [Only registered and activated users can see links. Click Here To Register...] for the documentation.Code:// import the player module first #ifdef GAMEFORGE player_module_ = PyImport_ImportModule("playerm2g2"); #else player_module_ = PyImport_ImportModule("player"); #endif long GetStatus(std::uint32_t type) { auto* args = PyTuple_New(1); PyTuple_SetItem(args, 0, PyInt_FromLong(type)); auto* fun = PyObject_Call( PyObject_GetAttrString(player_module_, "GetStatus"), args, nullptr); auto const res = PyInt_AsLong(fun); Py_DECREF(fun); Py_XDECREF(args); return res; }
3. now call all of the metin2 game functions from within the mainthread hook (OnUpdate). if you disregard this - like many other poorly written cheats - you will encounter many runtime errors. this is due to the fact that metin2 is not thread-safe by itself and you need to ensure that all external function calls that yield to game functions are only executed from within the same thread in which the gameloop is running.
4. ???
5. profit.
This probably works, but the server I use has python disabled and I am using radstudio. i want to do this with asmQuote:
here is a much simpler approach without hassling with inline assembler, function pointers or addresses (except for the hook :p) in the first place:
1. hook a function that is periodically called from within the mainthread of metin2 (OnUpdate, OnRender, etc.). go for OnUpdate since you probably want to run your cheat in the background.
2. use the python c api to retrieve the GetStatus function like so (untested code):
Refer to [Only registered and activated users can see links. Click Here To Register...] for the documentation.Code:// import the player module first #ifdef GAMEFORGE player_module_ = PyImport_ImportModule("playerm2g2"); #else player_module_ = PyImport_ImportModule("player"); #endif long GetStatus(std::uint32_t type) { auto* args = PyTuple_New(1); PyTuple_SetItem(args, 0, PyInt_FromLong(type)); auto* fun = PyObject_Call( PyObject_GetAttrString(player_module_, "GetStatus"), args, nullptr); auto const res = PyInt_AsLong(fun); Py_DECREF(fun); Py_XDECREF(args); return res; }
3. now call all of the metin2 game functions from within the mainthread hook (OnUpdate). if you disregard this - like many other poorly written cheats - you will encounter many runtime errors. this is due to the fact that metin2 is not thread-safe by itself and you need to ensure that all external function calls that yield to game functions are only executed from within the same thread in which the gameloop is running.
4. ???
5. profit.