This repository was archived by the owner on Nov 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcs2_loader.py
More file actions
61 lines (48 loc) · 1.9 KB
/
cs2_loader.py
File metadata and controls
61 lines (48 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import sys
import os
import ctypes
import importlib
import traceback
BASE_PATH = "{{BASE_PATH}}\\cs2"
try:
with open("cs2_loader_log.txt", "w") as f:
f.write(f"Starting CS2.py loader\n")
f.write(f"BASE_PATH: {BASE_PATH}\n")
f.write(f"Current working directory: {os.getcwd()}\n")
f.write(f"Python version: {sys.version}\n")
f.write(f"System path: {sys.path}\n")
except Exception as e:
ctypes.windll.user32.MessageBoxW(None, f"Failed to create log: {e}", "Log Error", 0)
sys.path.append(BASE_PATH)
sys.path.append(os.path.dirname(BASE_PATH))
try:
with open("cs2_loader_log.txt", "a") as f:
f.write(f"Reloading cs2 modules...\n")
for name in list(sys.modules):
try:
if name == "cs2" or name.startswith("cs2."):
importlib.reload(sys.modules[name])
with open("cs2_loader_log.txt", "a") as f:
f.write(f"Reloaded module: {name}\n")
except Exception as ex:
with open("cs2_loader_log.txt", "a") as f:
f.write(f"Failed to reload {name}: {ex}\n")
pass
with open("cs2_loader_log.txt", "a") as f:
f.write(f"Importing main cs2 module...\n")
import cs2
with open("cs2_loader_log.txt", "a") as f:
f.write(f"Running cs2.run()...\n")
cs2.run()
with open("cs2_loader_log.txt", "a") as f:
f.write(f"cs2.run() completed successfully\n")
except Exception as e:
exc_type, exc_value, exc_tb = sys.exc_info()
tb_str = "".join(traceback.format_exception(exc_type, exc_value, exc_tb))
try:
with open("cs2_loader_error.txt", "w") as f:
f.write(f"CS2 Import/Run Error: {e}\n")
f.write(f"Traceback:\n{tb_str}\n")
except:
pass
ctypes.windll.user32.MessageBoxW(None, f"CS2 Import/Run Error: {e}\nSee cs2_loader_error.txt for details", "FAIL", 0)