• Zoom questions
    4 replies, posted
All righty, so I have this little tidbit of code: [code] function SWEP:SecondaryAttack() //The variable "ScopeLevel" tells how far the scope has zoomed. //This SWEP has 2 zoom levels. if(ScopeLevel == 0) then if(SERVER) then self.Owner:SetFOV( 60, 0 ) //SetFOV changes the field of view, or zoom. First argument is the //number of degrees in the player's view (lower numbers zoom farther,) //and the second is the duration it takes in seconds. end ScopeLevel = 1 //This is zoom level 1. else if(ScopeLevel == 0) then else //If the user is zoomed in all the way, reset their view. if(SERVER) then self.Owner:SetFOV( 0, 0 ) //Setting the FOV to zero resets the player's view, AFAIK end ScopeLevel = 0 //There is no zoom. end end end [/code] This makes it zoom into place a little bit, but it's jerky and instant. Is there any way I can make it smooth and neat-looking, like the Arma zoom, or the HL2 crossbow? In addition, any way I can make a little dot appear in the center of the screen upon zooming?
[url]http://wiki.garrysmod.com/page/Player/SetFOV[/url] For drawing the dot, use an if statement and check the zoom level variable in this hook: [url]http://wiki.garrysmod.com/page/WEAPON/DoDrawCrosshair[/url]
Funny that Chessnut shows up to this because I'm doing this on NS using Black Tea's CS base in lieu of iron sights. Anyways, this is what I came up with: [code]function SWEP:DoDrawCrosshair( x, y ) if(ScopeLevel == 0) then surface.SetDrawColor( 0, 250, 255, 255 ) surface.DrawOutlinedRect( x - 32, y - 32, 64, 64 ) return true else return false end end [/code] No errors, but no crosshair showing up. Is this because of Nutscript by default disabling the crosshair?
Did you see if the hook is running? [editline]24th June 2015[/editline] Try just using SWEP:DrawHUD
[QUOTE=Chessnut;48044626]Did you see if the hook is running? [editline]24th June 2015[/editline] Try just using SWEP:DrawHUD[/QUOTE] DrawHUD worked, thanks! Will try to figure out on my own how to make it a little dot or something.
Sorry, you need to Log In to post a reply to this thread.