Page 2 of 2

Re: [ANY] Weapon Zoom

Posted: Tue Jan 26, 2021 12:48 pm
by Kami
Just wanted to make sure it's okay for me to put the code on github :D

Thank you for the idea with the poster, I think it fits really well.

Image

Re: [ANY] Weapon Zoom

Posted: Tue Jan 26, 2021 1:57 pm
by VinciT
Hahahahahaha that's brilliant!

Re: [ANY] Weapon Zoom

Posted: Tue Jan 26, 2021 3:20 pm
by Ayuto
That looks great!! I would like to have one as well! :D

Re: [ANY] Weapon Zoom

Posted: Tue Jan 26, 2021 5:24 pm
by L'In20Cible
Damn, what a museum-worthy masterpiece! xDD

Re: [ANY] Weapon Zoom

Posted: Tue Jan 26, 2021 6:35 pm
by daren adler
Hello. Good afternoon, is there a way to have a crosshair on the zoom? I have a lasergun i use and it has a crosshair of its own, is there a way to use that crosshair on the zoom?

Re: [ANY] Weapon Zoom

Posted: Wed Jan 27, 2021 8:20 pm
by Kami
You need to find the texture for the crosshair and then you can use this version:

Syntax: Select all

from commands.client import ClientCommand
from entities.hooks import EntityCondition
from entities.hooks import EntityPreHook
from listeners import get_button_combination_status
from listeners import ButtonStatus
from listeners import OnButtonStateChanged
from memory import make_object
from players.constants import PlayerButtons
from players.entity import Player
from weapons.entity import Weapon
from players.constants import HideHudFlags

zoom_button = PlayerButtons.ATTACK2
zoom_level = 30
zoom_weapons = ['weapon_357']
zoom_overlay = ""

def toggle_zoom(player):
weapon = player.active_weapon
if weapon is None or weapon.classname not in zoom_weapons:
return

player.fov = player.default_fov if player.fov == zoom_level else zoom_level
if zoom_overlay:
if player.fov == zoom_level:
player.hidden_huds |= HideHudFlags.CROSSHAIR
player.client_command(f'r_screenoverlay {zoom_overlay}')
else:
player.hidden_huds = 0
player.client_command('r_screenoverlay 0')

if zoom_button is not None:
@OnButtonStateChanged
def on_buttons_state_changed(player, old, new):
if get_button_combination_status(old, new, zoom_button) != ButtonStatus.PRESSED:
return

toggle_zoom(player)

@ClientCommand('do_zoom')
def do_zoom(command, index, team_only=False):
toggle_zoom(Player(index))

@EntityPreHook(EntityCondition.is_player, 'weapon_switch')
def pre_weapon_switch(stack_data):
player = make_object(Player, stack_data[0])
player.fov = player.default_fov
if zoom_overlay:
player.hidden_huds = 0
player.client_command('r_screenoverlay 0')


zoom_overlay has to be the overlay you want (e.g. effects/combine_binocoverlay.vmt)

Re: [ANY] Weapon Zoom

Posted: Wed Jan 27, 2021 9:39 pm
by daren adler
:cool: OK thank you. :cool:

Re: [ANY] Weapon Zoom

Posted: Sun Sep 12, 2021 4:28 pm
by daren adler
Is there a way to have a 3-way zoom on here ?. Like lets say zoom_level = 40, next 25, and then 10, or something like that.