-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSPT-RPC.py
More file actions
49 lines (37 loc) · 1.42 KB
/
Copy pathSPT-RPC.py
File metadata and controls
49 lines (37 loc) · 1.42 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
import subprocess
import sys
import time
import psutil
# Path to TarkovRPC
node_app_path = r"rpc\TarkovRPC-Controller.exe"
working_directory = r"rpc"
# EFT Process check
def is_process_running(process_name):
for proc in psutil.process_iter():
if process_name.lower() in proc.name().lower():
return True
return False
print("Looking for EscapeFromTarkov.exe...")
# im so lazy to write a ws check in python, so its better if i just leave the timer here
delay_seconds = 45
while True:
if is_process_running("EscapeFromTarkov.exe"):
print("EscapeFromTarkov.exe found, waiting WS...")
time.sleep(delay_seconds) # THE DELAY
print("Running RPC...")
try:
# running the thing...?
process = subprocess.Popen([node_app_path], cwd=working_directory)
except Exception as e:
print(f"Error: {e}")
sys.exit(1)
while is_process_running("EscapeFromTarkov.exe"):
time.sleep(1)
# when EFT is closed, we kill RPC
print("EscapeFromTarkov.exe closed, killing RPC...")
try:
subprocess.run(["taskkill", "/f", "/im", "TarkovRPC-Controller.exe"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
except Exception as e:
print(f"Something went wrong: {e}")
sys.exit(1)
print("Waiting for the process to start RPC again...")