use subclass
This commit is contained in:
parent
85c29fe9a7
commit
f8f9f5a385
1 changed files with 31 additions and 18 deletions
49
main.py
49
main.py
|
@ -11,16 +11,6 @@ class Hack():
|
|||
# Loading offsets
|
||||
self.offsets = self._find_offsets()
|
||||
|
||||
self.cheats_list = [func for func in dir(self)
|
||||
# Function
|
||||
if callable(getattr(self, func))
|
||||
# User defined
|
||||
if not (func.startswith("__") and func.endswith("__"))
|
||||
# Blacklist
|
||||
if func not in ["_find_offsets",
|
||||
"_find_process",
|
||||
"find_module"]]
|
||||
|
||||
self.pm = self._find_process(True)
|
||||
|
||||
def _find_offsets(self) -> dict[str, int]:
|
||||
|
@ -60,6 +50,31 @@ class Hack():
|
|||
else:
|
||||
raise MemoryError
|
||||
|
||||
|
||||
class Cheat(Hack):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.wait_time = 0.01
|
||||
self.timeout = self.wait_time * 50
|
||||
|
||||
self.cheats_list = [func for func in dir(self)
|
||||
# Function
|
||||
if callable(getattr(self, func))
|
||||
# User defined
|
||||
if not func.startswith("_")
|
||||
# Utils
|
||||
if not func.startswith("find_")]
|
||||
|
||||
def find_local_player(self, client) -> int:
|
||||
local_player = None
|
||||
while not local_player:
|
||||
local_player = self.pm.read_uint(
|
||||
client + self.offsets["dwLocalPlayer"])
|
||||
sleep(self.timeout)
|
||||
|
||||
return local_player
|
||||
|
||||
def bhop(self) -> None:
|
||||
# Aliases
|
||||
mem = self.pm
|
||||
|
@ -68,20 +83,18 @@ class Hack():
|
|||
# Get module address
|
||||
client = self.find_module("client")
|
||||
|
||||
# Get local player
|
||||
local_player = self.find_local_player(client)
|
||||
|
||||
# Hack loop
|
||||
while True:
|
||||
# Reduce CPU usage
|
||||
sleep(0.01)
|
||||
sleep(self.wait_time)
|
||||
|
||||
# Space bar detection
|
||||
if not GetAsyncKeyState(ord(" ")):
|
||||
continue
|
||||
|
||||
# Get local player
|
||||
local_player = mem.read_uint(client + offset["dwLocalPlayer"])
|
||||
if not local_player:
|
||||
continue
|
||||
|
||||
# Check if player is alive
|
||||
if not mem.read_int(local_player + offset["m_iHealth"]):
|
||||
continue
|
||||
|
@ -89,13 +102,13 @@ class Hack():
|
|||
# Check if player on ground
|
||||
if mem.read_uint(local_player + offset["m_fFlags"]) & (1 << 0):
|
||||
mem.write_uint(client + offset["dwForceJump"], 5)
|
||||
sleep(0.01)
|
||||
sleep(0.01) # maybe reduce ban rate?
|
||||
mem.write_uint(client + offset["dwForceJump"], 4)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Cheat
|
||||
c = Hack()
|
||||
c = Cheat()
|
||||
|
||||
# Cheat list
|
||||
print("Enter 0 to exit.")
|
||||
|
|
Reference in a new issue