[ANY] Weapon Zoom

Release your plugins here!
User avatar
Kami
Global Moderator
Posts: 250
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [ANY] Weapon Zoom

Postby Kami » Tue Jan 26, 2021 12:48 pm

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
User avatar
VinciT
Senior Member
Posts: 315
Joined: Thu Dec 18, 2014 2:41 am

Re: [ANY] Weapon Zoom

Postby VinciT » Tue Jan 26, 2021 1:57 pm

Hahahahahaha that's brilliant!
ImageImageImageImageImage
User avatar
Ayuto
Project Leader
Posts: 2157
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [ANY] Weapon Zoom

Postby Ayuto » Tue Jan 26, 2021 3:20 pm

That looks great!! I would like to have one as well! :D
User avatar
L'In20Cible
Project Leader
Posts: 1446
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [ANY] Weapon Zoom

Postby L'In20Cible » Tue Jan 26, 2021 5:24 pm

Damn, what a museum-worthy masterpiece! xDD
User avatar
daren adler
Senior Member
Posts: 253
Joined: Sat May 18, 2019 7:42 pm

Re: [ANY] Weapon Zoom

Postby daren adler » Tue Jan 26, 2021 6:35 pm

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?
User avatar
Kami
Global Moderator
Posts: 250
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [ANY] Weapon Zoom

Postby Kami » Wed Jan 27, 2021 8:20 pm

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)
User avatar
daren adler
Senior Member
Posts: 253
Joined: Sat May 18, 2019 7:42 pm

Re: [ANY] Weapon Zoom

Postby daren adler » Wed Jan 27, 2021 9:39 pm

:cool: OK thank you. :cool:
User avatar
daren adler
Senior Member
Posts: 253
Joined: Sat May 18, 2019 7:42 pm

Re: [ANY] Weapon Zoom

Postby daren adler » Sun Sep 12, 2021 4:28 pm

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.

Return to “Plugin Releases”

Who is online

Users browsing this forum: No registered users and 1 guest