|
You last visited: Today at 07:17
Advertisement
How to compile Metin2 .py script to .pyc ? - Where to get modules to compile?
Discussion on How to compile Metin2 .py script to .pyc ? - Where to get modules to compile? within the Metin2 forum part of the Popular Games category.
09/30/2023, 14:36
|
#1
|
elite*gold: 0
Join Date: Feb 2016
Posts: 6
Received Thanks: 0
|
How to compile Metin2 .py script to .pyc ? - Where to get modules to compile?
Hi there!
I'm Argi.
I'd like to begin by mentioning that I'm a programmer, but I don't typically work with Python. Consequently, my question may appear somewhat basic, for which I apologize in advance.
So let's start with the fact that my problem is compiling a file with the extension '.py' to a file with the extension '.pyc'. I wrote a simple hack [for fun and to learn some Python basics], which cannot work on some servers due to security measures that delete files from the client folder.
Currently I'm loading the '.py' file through some pyLoader when the client starts, I plan to load the '.pyc' file once I manage to compile it
As a programmer, I am aware that when compiling a file, you need to have the sources of the modules that you import in the script and this is where things get a bit complicated
I've created a script named script.py that imports the following modules:
HTML Code:
import app
import ui
import wndMgr
import uiToolTip
import localeInfo
import dbg
The script functions as intended, but I'm interested in compiling it into script.pyc. However, when I attempt to compile it using PyCharm, I encounter a "ModuleNotFoundError: No module named 'app'" error.
I'm sure it's possible to compile these files somehow, I just lack the knowledge. I don't know if I would need metin2 source, or maybe these modules are available somewhere and I could download them?
Or maybe there is another way to compile these files?
I'm asking for help, I'm very interested in this topic from a programmer's point of view. I suspect that there are not many programmers left on the forum who would like to share this knowledge, because the game itself is quite old.
Anyway, I'm looking forward to your replies. If you would prefer to contact me via private message, please do so.
Regards!
Additional information:
I tried to compile the files by replacing the lib/functools.pyc file with (my script) functools.py, after starting the game my file was recompiled to functools.pyc but when I tried to load it using pyLoader I got a "null bytes" error.
Then I downloaded some programs that search for "null bytes" and remove them - this also didn't work.
I also downloaded the Vanilla Core files (from Vanilla - those in the know should know what I mean) but somehow I couldn't find the necessary modules there.
I would be grateful if someone could point me in the right direction
|
|
|
10/02/2023, 17:16
|
#2
|
elite*gold: 0
Join Date: Feb 2016
Posts: 6
Received Thanks: 0
|
Refresh
|
|
|
10/03/2023, 10:49
|
#3
|
elite*gold: 0
Join Date: Apr 2013
Posts: 205
Received Thanks: 51
|
Hi there.
You can use the following syntax to execute your python scripts, once imported, the script will automatically get compiled with .pyc extension.
Code:
import sys
path = '' #path containing your script
sys.path.insert(1, str(path))
import your_script
|
|
|
10/06/2023, 19:48
|
#4
|
elite*gold: 0
Join Date: Feb 2016
Posts: 6
Received Thanks: 0
|
Thanks for reply
Quote:
Originally Posted by SpankTeam
Hi there.
You can use the following syntax to execute your python scripts, once imported, the script will automatically get compiled with .pyc extension.
Code:
import sys
path = '' #path containing your script
sys.path.insert(1, str(path))
import your_script
|
Hi, thanks for your reply. Honestly, I didn't expect a response after so long, that's why I waited so long to respond, I'm sorry.
So yes, let's start with the fact that I tried to do it the way you described. I'll put my attempts in the spoiler.
First, I created the comp.py file [I tried doing this in several ways cause of errors in syserr]
comp.py
HTML Code:
import sys
path = 'D:\Games\Metin2\SCLIENT_PATH\script.py' #path containing your script
sys.path.insert(1, str(path))
import script
# it did not work
# another try after syserr
import sys
path = r'D:\Games\Metin2\CLIENT_PATH\script.py'
sys.path.insert(1, str(path))
import script
# it did not work
#another try after syserr
import sys
path = 'D:\\Games\\Metin2\\CLIENT_PATH\\script.py'
sys.path.insert(1, str(path))
import script
# it did not work
then turned on the game client (pyLoader is turned on together with it), loaded the script via "load comp.py" inside pyLoader teminal and then I got an error in syserr.txt:
HTML Code:
1006 19:08:05874 :: File "comp.py", line 4, in <module>
1006 19:08:05875 ::
1006 19:08:05875 :: import script
1006 19:08:05875 ::
1006 19:08:05875 :: File "system.py", line 130, in __pack_import
1006 19:08:05875 :: File "system.py", line 64, in __init__
1006 19:08:05875 :: AttributeError
1006 19:08:05875 :: :
1006 19:08:05875 :: 'NoneType' object has no attribute 'split'
However, it is very possible that people lack context, so I will try to explain a bit what I actually do (with my life, after hours in an almost 20-year-old game).
So, I should start by downloading some random private game client (a regular public client), which is so unsecured that I can inject the script.py code via pyLoader and play around with coding.
With the above in mind, it is easy to come to the conclusion that I do not have any source files for this game client.
Briefly recalling my problem: I don't know how to compile my script.py file without having the modules that are imported anywhere on my device (example modules that I import are in the first post) in script.py.
In the first spoiler message, I also described how I tried to compile the file by replacing the file in the game client lib/functools.pyc with functools.py - this also didn't work.
Maybe someone can recommend me a discord, forum or something where I can get the information I'm interested in?
Perhaps someone knows how I could compile these files even from within pyCharm. But if not, I will settle for any way of compiling this script, as long as it can be loaded later (already compiled) via pyLoader.
I'm waiting for your answer, best regards.
|
|
|
10/07/2023, 10:26
|
#5
|
elite*gold: 0
Join Date: Apr 2013
Posts: 205
Received Thanks: 51
|
Quote:
Originally Posted by Arrgi
Hi, thanks for your reply. Honestly, I didn't expect a response after so long, that's why I waited so long to respond, I'm sorry.
So yes, let's start with the fact that I tried to do it the way you described. I'll put my attempts in the spoiler.
First, I created the comp.py file [I tried doing this in several ways cause of errors in syserr]
comp.py
HTML Code:
import sys
path = 'D:\Games\Metin2\SCLIENT_PATH\script.py' #path containing your script
sys.path.insert(1, str(path))
import script
# it did not work
# another try after syserr
import sys
path = r'D:\Games\Metin2\CLIENT_PATH\script.py'
sys.path.insert(1, str(path))
import script
# it did not work
#another try after syserr
import sys
path = 'D:\\Games\\Metin2\\CLIENT_PATH\\script.py'
sys.path.insert(1, str(path))
import script
# it did not work
then turned on the game client (pyLoader is turned on together with it), loaded the script via "load comp.py" inside pyLoader teminal and then I got an error in syserr.txt:
HTML Code:
1006 19:08:05874 :: File "comp.py", line 4, in <module>
1006 19:08:05875 ::
1006 19:08:05875 :: import script
1006 19:08:05875 ::
1006 19:08:05875 :: File "system.py", line 130, in __pack_import
1006 19:08:05875 :: File "system.py", line 64, in __init__
1006 19:08:05875 :: AttributeError
1006 19:08:05875 :: :
1006 19:08:05875 :: 'NoneType' object has no attribute 'split'
However, it is very possible that people lack context, so I will try to explain a bit what I actually do (with my life, after hours in an almost 20-year-old game).
So, I should start by downloading some random private game client (a regular public client), which is so unsecured that I can inject the script.py code via pyLoader and play around with coding.
With the above in mind, it is easy to come to the conclusion that I do not have any source files for this game client.
Briefly recalling my problem: I don't know how to compile my script.py file without having the modules that are imported anywhere on my device (example modules that I import are in the first post) in script.py.
In the first spoiler message, I also described how I tried to compile the file by replacing the file in the game client lib/functools.pyc with functools.py - this also didn't work.
Maybe someone can recommend me a discord, forum or something where I can get the information I'm interested in?
Perhaps someone knows how I could compile these files even from within pyCharm. But if not, I will settle for any way of compiling this script, as long as it can be loaded later (already compiled) via pyLoader.
I'm waiting for your answer, best regards.
|
As I understood from your first post, you need to compile your .py script to .pyc, is that right? If yes, try the code below.
You do not have to include in the path the script name.
Use it like this:
Code:
import sys
path = 'D:\\Games\\Metin2\\SCLIENT_PATH'
sys.path.insert(1, str(path))
import script
Regarding modules such as app, player you won't be able to find them anywhere, since they are built in the metin2 client, those are C++ Python extensions.
|
|
|
10/07/2023, 14:31
|
#6
|
elite*gold: 0
Join Date: Feb 2016
Posts: 6
Received Thanks: 0
|
Ok, let's try step by step
Quote:
Originally Posted by SpankTeam
As I understood from your first post, you need to compile your .py script to .pyc, is that right? If yes, try the code below.
You do not have to include in the path the script name.
Use it like this:
Code:
import sys
path = 'D:\\Games\\Metin2\\SCLIENT_PATH'
sys.path.insert(1, str(path))
import script
Regarding modules such as app, player you won't be able to find them anywhere, since they are built in the metin2 client, those are C++ Python extensions.
|
Thanks for the answer ! Below is a description of what I do step by step. I also include the content of the sample script that I want to recompile into .pyc
In this path in windows:
D:\Games\Metin2\CLIENT_PATH
Is located:
- pyLoader
- tocompile.py (the script I want to compile to .pyc)
Code:
import ui
import wndMgr
import uiToolTip
class tocompile (ui.BoardWithTitleBar):
BOARD_WIDTH = 500
BOARD_HEIGHT = 300
SLOT_WIDTH = 150
def __init__(self):
ui.BoardWithTitleBar.__init__(self)
self.wndScript = None
## Item ToolTip
self.tooltipItem = uiToolTip.ItemToolTip()
self.tooltipItem.Hide()
## Board
self.SetSize(self.BOARD_WIDTH, self.BOARD_HEIGHT)
self.SetPosition(0, wndMgr.GetScreenHeight() - self.BOARD_HEIGHT)
self.AddFlag("movable")
self.SetTitleName("Test")
self.SetCloseEvent(self.Hide)
self.Show()
def __del__(self):
ui.BoardWithTitleBar.__del__(self)
del self.tooltipItem
del self.tooltipSkill
def Show(self):
ui.BoardWithTitleBar.Show(self)
def Hide(self):
ui.BoardWithTitleBar.Hide(self)
wndTestScript = tocompile()
wndTestScript.Show()
- comp.py (the code I got from you)
Code:
import sys
path = 'D:\\Games\\Metin2\\CLIENT_PATH'
sys.path.insert(1, str(path))
import tocompile
Now step by step, located in D:\Games\Metin2\CLIENT_PATH
- I launch the game client (pyLoader starts with it - terminal)
- I type "load comp.py"
- Terminal:
Code:
load comp.py
File loading comp.py
An error occurred, please check the file 'syserr.txt', for more information.
- Contents of 'syserr.txt' file
Code:
1007 14:08:17020 :: Traceback (most recent call last):
1007 14:08:17020 :: File "<string>", line 1, in <module>
1007 14:08:17020 :: File "comp.py", line 4, in <module>
1007 14:08:17021 ::
1007 14:08:17021 :: import tocompile
1007 14:08:17021 ::
1007 14:08:17021 :: File "system.py", line 130, in __pack_import
1007 14:08:17021 :: File "system.py", line 64, in __init__
1007 14:08:17053 :: AttributeError
1007 14:08:17053 :: :
1007 14:08:17053 :: 'NoneType' object has no attribute 'split'
1007 14:08:17053 ::
The error does not appear when loading the ' load tocompile.py' file via pyLoader, so I guess it's not my script's fault.
I believe that now you have complete information about what and how I do it.
Additional questions if anyone has the time and inclination to answer them:
Quote:
Regarding modules such as app, player you won't be able to find them anywhere, since they are built in the metin2 client, those are C++ Python extensions.
|
- So I won't find these modules anywhere in metin2 files like .epk etc.?
Or this is only possible when i have the source code ? That's confusing me.
- Maybe there is another way to compile those files ? For example compiling it by pyCharm.
- Still looking for other sources of knowlage like discords or something, maybe you got one ? I need to find someone who will be able to answer my questions related to metin2 scripts, but from the perspective of a developer, not a user of these scripts, and there are more of them on forums like it or not.
Regards
|
|
|
10/09/2023, 12:38
|
#7
|
elite*gold: 0
Join Date: Apr 2013
Posts: 205
Received Thanks: 51
|
If both files are in the same place, you do not need anymore to add this part:
Code:
import sys
path = 'D:\\Games\\Metin2\\CLIENT_PATH'
sys.path.insert(1, str(path))
Simply use 'import tocompile'.
Should work, if not, or have any other questions, add me on Discord: 0x00bad
Best regards.
|
|
|
10/14/2023, 12:56
|
#8
|
elite*gold: 0
Join Date: Feb 2016
Posts: 6
Received Thanks: 0
|
Quote:
Originally Posted by SpankTeam
If both files are in the same place, you do not need anymore to add this part:
Code:
import sys
path = 'D:\\Games\\Metin2\\CLIENT_PATH'
sys.path.insert(1, str(path))
Simply use 'import tocompile'.
Should work, if not, or have any other questions, add me on Discord: 0x00bad
Best regards.
|
Thank you, I sent you a friend request on Discord [My name is almost identical to the one on the forum].
Currently, I have a lot on my mind at work and I have a little less time, but unfortunately there are important and more important matters.
I will contact you as soon as I can, then if you agree, I will share my screen and we will try to solve this problem
Please do not close the topic yet, if possible, if the matter is resolved, I will be happy to share the solution on the forum, unless there are contraindications.
Regards!
|
|
|
11/06/2023, 20:51
|
#9
|
elite*gold: 0
Join Date: Nov 2023
Posts: 3
Received Thanks: 0
|
Someone cam help me with hack hammer? I paid however !!!
|
|
|
All times are GMT +1. The time now is 07:17.
|
|