This repository has been archived on 2023-09-02. You can view files and clone it, but cannot push or open issues or pull requests.
csh/cheats/noflash.py

49 lines
1.3 KiB
Python
Raw Normal View History

2023-03-31 18:52:22 +02:00
from hack import Hack, sleep
from utils import errors_unload
2023-03-31 18:52:22 +02:00
class Noflash(Hack):
2023-04-01 16:11:56 +02:00
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
2023-03-31 18:52:22 +02:00
2023-05-05 16:04:06 +02:00
self.__brightness = 30.0
self.__default_brightness = 255.0
2023-03-31 21:58:07 +02:00
2023-03-31 18:52:22 +02:00
def noflash(self) -> None:
# Aliases
mem = self.pm
offset = self.offsets
# Get module address
client = self.find_module("client")
# Get local player
2023-04-03 02:40:57 +02:00
self.__local_player = self.find_uint(client, offset["dwLocalPlayer"])
local_player = self.__local_player
2023-03-31 18:52:22 +02:00
def cheat():
# Override the brightness value
mem.write_float(
2023-05-05 16:04:06 +02:00
local_player + offset["m_flFlashMaxAlpha"], self.__brightness
)
2023-03-31 18:52:22 +02:00
2023-03-31 19:36:49 +02:00
# Value only overrided on first flash or when server fullupdate
sleep(10)
2023-03-31 18:52:22 +02:00
self.hack_loop(cheat)
2023-04-03 02:40:57 +02:00
def noflash_unload(self):
# Aliases
mem = self.pm
offset = self.offsets
try:
local_player = self.__local_player
except errors_unload():
# No modification has been done
return
2023-04-03 02:40:57 +02:00
# Reset to default value
mem.write_float(
2023-05-05 16:04:06 +02:00
local_player + offset["m_flFlashMaxAlpha"], self.__default_brightness
)