When I press the first key, it works, but when I try to change the key it is not changing, it remains on the first key that was pressed
def exec_control(gun, k):
print(f"CurrentWeapon:t{gun.name}nMagazineSize:t{len(gun.recoil)}nRPM:t{gun.rpm}nn[INSERT]n")
delay = get_time(gun.rpm) / 1000
index = 0
while True:
while win32api.GetAsyncKeyState(win32con.VK_LBUTTON) and index != len(gun.recoil):
win32api.mouse_event(win32con.MOUSEEVENTF_MOVE, int(gun.recoil[index][0] * k), int(gun.recoil[index][1] * k), 0, 0)
index += 1
time.sleep(delay)
index = 0
def main():
k = get_k(800, 0.95)
ak47 = load_weapon("AK-47", ak47_pattern, 600)
m4a4 = load_weapon("M4A4", m4a4_pattern, 666)
ump45 = load_weapon("UMP-45", ump45_pattern, 666)
current_weapon = None # Armazena a arma atualmente em uso
while True:
# Verifica se a tecla NumPad 1 (AK-47) foi pressionada e se a arma atual não é a AK-47
if win32api.GetAsyncKeyState(win32con.VK_NUMPAD1) & 0x8000 and current_weapon != ak47:
exec_control(ak47, k)
current_weapon = ak47
# Verifica se a tecla NumPad 2 (M4A4) foi pressionada e se a arma atual não é a M4A4
elif win32api.GetAsyncKeyState(win32con.VK_NUMPAD2) & 0x8000 and current_weapon != m4a4:
exec_control(m4a4, k)
current_weapon = m4a4
# Verifica se a tecla NumPad 3 (UMP-45) foi pressionada e se a arma atual não é a UMP-45
elif win32api.GetAsyncKeyState(win32con.VK_NUMPAD3) & 0x8000 and current_weapon != ump45:
exec_control(ump45, k)
current_weapon = ump45
time.sleep(0.15)
if __name__ == "__main__":
main()
I tried to adapt it to other keys but it didn’t work
New contributor
Nirvan Company is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.