fivem icon indicating copy to clipboard operation
fivem copied to clipboard

Native to change vehicle FOV

Open FlawwsX opened this issue 6 months ago • 7 comments

Segment

Gameplay

Importancy

Nice extra

Improvement request

A native to change the FOV for players in vehicles. We were previously able to set the convar for FOV in vehicles but that’s since been removed.

Area(s)

FiveM

Additional information

No response

FlawwsX avatar May 12 '26 18:05 FlawwsX

I'm currently implementing the missing Native for vehicle FOV scaling. I'll update this issue with a PR once tested.

KAZRUTx avatar May 13 '26 07:05 KAZRUTx

From conversations with Cfx, they would accept a game_ replicated ConVar for both restricting crosshair usage and maximum FOV. For example game_restrictCrosshair and game_restrictVehicleFirstPersonFOV

They should also be false by default and have ConVar_Replicated. This would make them reset after disconnecting from the server, as to not persist between different servers. Which was the problem with the cl_crosshair and cam_vehicleFirstPersonFOV convars - one server could set them for all other servers you play on.

Gogsi avatar May 13 '26 09:05 Gogsi

From conversations with Cfx, they would accept a game_ replicated ConVar for both restricting crosshair usage and maximum FOV. For example game_restrictCrosshair and game_restrictVehicleFirstPersonFOV

They should also be false by default and have ConVar_Replicated. This would make them reset after disconnecting from the server, as to not persist between different servers. Which was the problem with the cl_crosshair and cam_vehicleFirstPersonFOV convars - one server could set them for all other servers you play on.

Hi Gogsi. Are you referring to my comment? Does it mean I am supposed to turn from a Native into a ConVar replication? I just want to be sure if you meant this for me or if you're taking on this task yourself.

If you are referring to me, I'm happy to take this on. Being a student, I need to ensure that everything works out perfectly fine, so I would like to have some sort of reference from the codebase if you have any. Thank you

KAZRUTx avatar May 13 '26 11:05 KAZRUTx

Does it mean I am supposed to turn from a Native into a ConVar replication Yes, they said this shouldn't be controlled via a native, but rather a ConVar.

But I would hold off on implementing this for a bit because there are still discussions on how it should be implemented.

I incorrectly assumed that modifying a ConVar that doesn't have ConVar_Replicated from the server (via setr or SetConvarReplicated) modifies that value for all servers. It turns out there is still logic to reset it to the old value after disconnecting, even if it is not ConVar_Replicated.

This would mean that the fix may be as simple as removing ConVar_UserPref from convars that the server should be able to modify, like cam_vehicleFirstPersonFOV and cl_customCrosshair. We should wait on confirmation from Cfx on if this is acceptible - it still feels weird for the server to modify cl_ convars.

Gogsi avatar May 13 '26 11:05 Gogsi

Because I had to test it, I will post what the actual flags do, as the documentation is a bit lacking

  • no ConVar_Replicated: Client can set values in F8 but if you join a server that has a setr it will force that server value and prevent you from modifying. When you disconnect, it reapplies the old value
  • ConVar_Replicated: Clients can't set values at all in F8. If you join a server that has a setr it will force that server value. When you disconnect, it reapplies the old value, which will always be the default because you can't change it via F8
  • ConVar_UserPref: Prevents setr from working.
  • ConVar_Archive: values set via the F8 console will be saved in fivem.cfg. Values set via setr are not saved, as they get reset before saving.

Gogsi avatar May 13 '26 11:05 Gogsi

Fixed on Canary by https://github.com/citizenfx/fivem/commit/62c4e1f28c7bf84d9ac819247330b941244fcf73

Gogsi avatar May 15 '26 16:05 Gogsi

@FlawwsX are you referring to first person or third?

bleenobtw avatar May 16 '26 19:05 bleenobtw