Jump to content

Get Sniper Zoom %


Lestat

Recommended Posts

Posted

Is there a way to get Sniper Zoom % or distance?

I tried getCameraMatrix() but it seems the camera position doesn't change, and camera has no getZoom function.

Posted

i believe that sniper zoom effect is made by changing FOV value, but currently you can't get FOV value in mta because its disabled

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

Posted

I know, you can try to make a script that calculate's the distance in meters. And then script the rifle zoom for show you on a part of the screen the distance between the target and you.

"Keep making it simplex."

Posted

You can get the fov of the camera with getCameraMatrix, but the fov doesnt change when you zoom with sniper so its not that.

the position of the camera, the player and the target (lets say other player) doesnt change when you zoom with sniper.

So the camera doesn't move, the fov doesnt change. It has to be a zoom value. But it seems we cant get it xD

  • Moderators
Posted

There might be a way. (probably inaccurate)

Using:

getScreenFromWorldPosition

getWorldFromScreenPosition

Since you can convert pixels > units and units > pixels using those functions.

When you zoom in, you can see less units than when you zoom out. Etc.

Also it might be possible with only getWorldFromScreenPosition, if this returns a correct position. Then you can compare it with getPedTargetStart.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

Unfortunately that didn't work, but I could do what I wanted to do other way. Not as good but it works :P

Suggestion, we should be able to get the camera zoom when using sniper and camera.

  • Moderators
Posted
Unfortunately that didn't work, but I could do what I wanted to do other way. Not as good but it works :P

Suggestion, we should be able to get the camera zoom when using sniper and camera.

Must have worked 1 of the 2 ways. The only thing you need is creativity and lua skills.

There is another thing you can do if you can't get a long with getScreenFromWorldPosition and getWorldFromScreenPosition.

By scripting an overwrite. Zooming in mta works with steps, there are an amount of steps you can zoom in/zoom out.

bindKey -- "zoom_in" "zoom_out" > function 
  
-- create a variable which contains the zoom status. 
  
setControlState ( "zoom_in", true) -- zoom in 
setControlState ( "zoom_in", false) 
-- increase variable zoom status 
  
setControlState ("zoom_out", true) -- zoom out 
setControlState ("zoom_out", false) 
-- de-increase variable zoom status 
  
toggleControl -- "zoom_in" "zoom_out"  > false 
  
  
-- onClientPreRender  -- check if aiming with sniper else reset the variable zoom status. 
  

I have made it like this before (an overwrite of zooming with sniper), so I can guaranty it will work.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...