ѕeмa™ 308 Posted December 3, 2014 Share Posted December 3, 2014 Hi, someone know how get for example: constinfo.py Test = "Hello" how can i get this "Hello" from c++? Im searching on the forum but i not found nothing, so i write here if somenone can help me. Sorry my english, Thanks. https://m2admin.net/ Link to comment Share on other sites More sharing options...
Premium Sanchez 2464 Posted December 3, 2014 Premium Share Posted December 3, 2014 You can do it easily, I just don't get the point of it. Call this in your binary: PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "GetTest", Py_BuildValue("()")); Make a "GetTest" function in game.py: def GetTest(self): net.SetTest(constInfo.Test)Add the receiver function to your binary: object* netSetTest(PyObject* poSelf, PyObject* poArgs) { char* szTest; if (!PyTuple_GetString(poArgs, 0, &szTest)) return Py_BuildException(); // Do something with szTest return Py_BuildNone(); } I'm sure there is a better way to solve your problem, so please explain what you want to do. 3 Link to comment Share on other sites More sharing options...
Honorable Member Solution xP3NG3Rx 19658 Posted December 3, 2014 Honorable Member Solution Share Posted December 3, 2014 Try this: PyObject *pMod = PyImport_AddModule("constInfo"); PyObject *pVal = PyObject_GetAttrString(pMod, "Test"); char* var = PyString_AsString(pVal); Py_DECREF(pVal); printf("Test is: %s", var); 3 Link to comment Share on other sites More sharing options...
ѕeмa™ 308 Posted December 3, 2014 Author Share Posted December 3, 2014 Thanks sanchez and p3ng3r i go to try the 2 methods. I want call a function return the constinfo "example in python" self.get(self): return constInfo.Test in c++ do a variable with the constInfo.Test https://m2admin.net/ Link to comment Share on other sites More sharing options...
Sober 37 Posted December 3, 2014 Share Posted December 3, 2014 why don't you just do it in python ? Link to comment Share on other sites More sharing options...
ѕeмa™ 308 Posted December 3, 2014 Author Share Posted December 3, 2014 (edited) why don't you just do it in python ? i can't xd this i can't do with python xD PD: I use the method of p3ng3r and when select character the client close without any log or sysser i go to try now with the method or sanchez. PD2: I have this problem now: Edited August 18, 2022 by Metin2 Dev Core X - External 2 Internal https://m2admin.net/ Link to comment Share on other sites More sharing options...
Active Member Koray 1994 Posted December 3, 2014 Active Member Share Posted December 3, 2014 (edited) why don't you just do it in python ? i can't xd this i can't do with python xD PD: I use the method of p3ng3r and when select character the client close without any log or sysser i go to try now with the method or sanchez. PD2: I have this problem now: http://en.wikibooks.org/wiki/C++_Programming/Code/Standard_C_Library/Functions/printf %d a decimal integer Edited August 18, 2022 by Metin2 Dev Core X - External 2 Internal 1 Link to comment Share on other sites More sharing options...
ѕeмa™ 308 Posted December 3, 2014 Author Share Posted December 3, 2014 (edited) why don't you just do it in python ? i can't xd this i can't do with python xD PD: I use the method of p3ng3r and when select character the client close without any log or sysser i go to try now with the method or sanchez. PD2: I have this problem now: http://en.wikibooks.org/wiki/C++_Programming/Code/Standard_C_Library/Functions/printf %d a decimal integer O.o Thanks u i dont know c++ and i dont know the functions on c++ Thanks The p3ng3r method is the shortest Thanks to all, can close this topic is solved. Edited August 18, 2022 by Metin2 Dev Core X - External 2 Internal https://m2admin.net/ Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now