[Need help] script for change FOV

Hi ! I want change the FOV of FPS view
I’ve see here https://runtime.fivem.net/doc/reference.html#_0x80C8B1846639BB19

SET_CAM_FOV #
// 0xB13C14F66A00D047 0xD3D5D74F
// SetCamFov
void SET_CAM_FOV(Cam cam, float fieldOfView);
Sets the field of view of the cam.

Min: 1.0f
Max: 130.0f

i’ve try this

local FOVchange = true

– CODE –

Citizen.CreateThread(function()

	while true do
		Wait(1)

		if FOVchange then
			SetCamFov(130)
		      	end
	end
end)

He dont work…

Please help me

2 Likes

The native needs 2 arguments, and you only provided one. Also, a float should be a decimal number, so 130.0, and not just 130.

I’ve try :

SetCamFov(0, 130.0)
SetCamFov(0,130.0f)

SetCamFov(4,130.0)
SetCamFov(4,130.0f)

nothing change FOV…

Try using this for the camera parameter.

I’ve try this but dont work too…

Citizen.CreateThread(function()

while true do
	Wait(1)

	if IsCamActive (4) then
		SetCamFov(4, 130.0)
	      	end
end

end)

I think he was talking about this native:
GetRenderingCam()
not
IsCamActive()

2 Likes

Yes you need to pass the reference of the camera that is currently being used. You can obtain the camera by running GetRenderingCam() as Cheleber said.

You can do something like this:

local camera = GetRenderingCam()
local fov = 120.0

SetCamFov(camera, fov)
2 Likes

@Syntasu I’ve tried this, using First Person Only as a base.

I have

local forceFirstPerson = true
local camera = GetRenderingCam()
local fov = 120.0

-- CODE --
Citizen.CreateThread(function()

	while true do
		Wait(1)

		if forceFirstPerson then
			SetFollowPedCamViewMode(4)
			SetCamFov(camera, fov)
		      	end
	end
end)

The camera stays as first person, however the FOV doesn’t change from the default.
Any ideas?

Edit
I am able to create a new camera and change the FOV of it however altering the FOV of cam when

local cam = GetRenderingCam()

Doesn’t do anything, does GetRenderingCam work in this way or not?

could someone just make it as a mod and put it up for download?

@NadroJ There was an fov.asi that NTA compiled over a year ago from the .dll mod, it doesn’t work anymore though.

fov.asi (133 KB)

You need to create new camera to make it work

Citizen.CreateThread(function()
    local cam = CreateCam("DEFAULT_SCRIPTED_CAMERA",true)
    local ped = GetPlayerPed(-1)
    local bone = GetPedBoneIndex(ped,12844)
    AttachCamToPedBone(cam,ped,bone,0.0,0.0,0.65,GetEntityHeading(ped))

    SetCamRot(cam, 0.0,0.0,GetEntityHeading(ped))

    SetCamFov(cam,90.0)

    RenderScriptCams(true,true,1000, 1, 0)

    SetCamNearClip(cam, 0.09)
    while true do
    Citizen.Wait(1)
    SetCamRot(cam, 0.0,0.0,GetEntityHeading(ped))
    end
end)

Before :


After:

3 Likes