Advertisement
Guest User

Garena LoL

a guest
Apr 7th, 2021
1,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. import psutil
  2. import os
  3. import shlex
  4. import subprocess
  5.  
  6. riot_service_process_name = "RiotClientServices.exe"
  7.  
  8. # WINEPREFIX create by https://lutris.net/games/league-of-legends/
  9. launchhelper = "/media/iu/LinuxGames/LutrisGames/league-of-legends/launchhelper.sh"
  10. WINEPREFIX = "/media/iu/LinuxGames/LutrisGames/league-of-legends/"
  11.  
  12. # Game install location
  13. game_path = "/media/iu/LinuxGames/LutrisGames/garena/drive_c/Garena/Games/32771/Riot Client/RiotClientServices.exe"
  14.  
  15. # Wine lol download from lutris
  16. wine_exe = (
  17. "/home/iu/.local/share/lutris/runners/wine/lutris-lol-5.5-2-x86_64/bin/wine"
  18. )
  19.  
  20. # Use gamemode
  21. use_gamemoderun = True
  22.  
  23. # Enable esync
  24. use_esync = True
  25.  
  26. # Enable fsync
  27. use_fsync = True
  28.  
  29.  
  30. def findProcessIdByName(processName):
  31. """
  32. Get a list of all the PIDs of a all the running process whose name contains
  33. the given string processName
  34. """
  35. # Iterate over the all the running process
  36. while True:
  37. for proc in psutil.process_iter():
  38. try:
  39. pinfo = proc.as_dict(attrs=["cmdline", "name", "pid"])
  40. # Check if process name contains the given name string.
  41. if processName.lower() in pinfo["name"].lower():
  42. return pinfo
  43. except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
  44. pass
  45.  
  46.  
  47. riot_process = findProcessIdByName(riot_service_process_name)
  48.  
  49. # Programmatically get RiotClientServices.exe arguments
  50. try:
  51. riot_argument = " ".join(riot_process.get("cmdline", [])[1:])
  52. except Exception:
  53. print("Cannot get Garena Token")
  54.  
  55. # Exit if no riot_argument is found
  56. if not riot_argument:
  57. quit()
  58.  
  59. # Kill the current RiotClientServices.exe
  60. p = psutil.Process(riot_process.get("pid"))
  61. p.kill()
  62.  
  63.  
  64. # Kill all wine process (Including Garena) or else it won't work
  65. os.system("wineserver -k")
  66.  
  67. # Start game using correct setup
  68. # Keep in mind the client will take awhile to start, after that you can play like normal
  69. # No garena while playing though
  70. launch_command = f'env WINEPREFIX={WINEPREFIX} WINEESYNC={1 if use_esync else 0} WINEFSYNC={1 if use_fsync else 0} {"gamemoderun " if use_gamemoderun else ""}"{wine_exe}" "{game_path}" {riot_argument} & "{launchhelper}"'
  71. # detached_process = subprocess.Popen(shlex.split(launch_command), start_new_session=True)
  72. os.system(launch_command)
  73.  
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement