That is a problem with the script, but it is not the main reason this is not working. From my testing, scrollDown and scrollUp are never true. I initially thought that maybe a think hook just didn’t work with inputs, but then I replaced the scrolldown with the k key and it worked.
For some reason detecting whether the scroll wheel is being scrolled isn’t possible or very hard, at least with the method you are using. I think the best way to accomplish what you want is to check if the binds invprev and invnext are pressed. Although this will only use the scrollwheel for those who have the scrollwheel bound to invprev and invnext, it will allow most people to use the scrollwheel to zoom and it’s better than having to use some other keys.
Another problem with this is the fact that you will constantly be scrolling through weapons, but your implementation would have done the same thing.
Here is the code:
if ( CLIENT ) then
local zoom = 100
hook.Add( "ShouldDrawLocalPlayer", "ThirdPersonDrawPlayer", function()
if LocalPlayer():Alive() then
return true
end
end )
hook.Add( "CalcView", "ThirdPersonView", function( ply, pos, angles, fov )
if ply:Alive() then
local view = {}
view.origin = pos - ( angles:Forward() * zoom ) + ( angles:Right() * 4 ) + ( angles:Up() * 1 )
view.angles = ply:EyeAngles() + Angle( 1, 1, 0 )
view.fov = fov
return GAMEMODE:CalcView( ply, view.origin, view.angles, view.fov )
end
end )
hook.Add("PlayerBindPress", "zooming", function(ply, bind, pressed)
if not pressed then return end
if string.find(bind, "invnext") then
zoom = ( zoom + 5 )
return false
elseif string.find(bind, "invprev") then
zoom = ( zoom - 5 )
return false
end
end )
end
You can return true in the bind presses if you want to prevent them from switching weapons with the scroll wheel.
Thanks so much! Luckily for me, I don’t have a weapons in my gamemode (Or at least the default weapon selection that is). Worked like a charm, thanks again.