Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Metin2
You last visited: Today at 07:17

  • Please register to post and access all features, it's quick, easy and FREE!

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.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2016
Posts: 6
Received Thanks: 0
Question 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:
Arrgi is offline  
Old 10/02/2023, 17:16   #2
 
elite*gold: 0
Join Date: Feb 2016
Posts: 6
Received Thanks: 0
Refresh
Arrgi is offline  
Old 10/03/2023, 10:49   #3
 
SpankTeam's Avatar
 
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
SpankTeam is offline  
Thanks
1 User
Old 10/06/2023, 19:48   #4
 
elite*gold: 0
Join Date: Feb 2016
Posts: 6
Received Thanks: 0
Question Thanks for reply

Quote:
Originally Posted by SpankTeam View Post
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.


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.
Arrgi is offline  
Old 10/07/2023, 10:26   #5
 
SpankTeam's Avatar
 
elite*gold: 0
Join Date: Apr 2013
Posts: 205
Received Thanks: 51
Quote:
Originally Posted by Arrgi View Post
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.


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.
SpankTeam is offline  
Thanks
1 User
Old 10/07/2023, 14:31   #6
 
elite*gold: 0
Join Date: Feb 2016
Posts: 6
Received Thanks: 0
Question Ok, let's try step by step

Quote:
Originally Posted by SpankTeam View Post
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)
- comp.py (the code I got from you)

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


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:


Regards
Arrgi is offline  
Old 10/09/2023, 12:38   #7
 
SpankTeam's Avatar
 
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.
SpankTeam is offline  
Thanks
1 User
Old 10/14/2023, 12:56   #8
 
elite*gold: 0
Join Date: Feb 2016
Posts: 6
Received Thanks: 0
Smile

Quote:
Originally Posted by SpankTeam View Post
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!
Arrgi is offline  
Old 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 !!!
Paultest1337 is offline  
Reply

Tags
compile, hack, import, metin2, python




All times are GMT +1. The time now is 07:17.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.