I’ve been looking for a script or a way to force First Person on players when they are doing a drive-by as the driver but couldn’t find anything.
So I spent the last hour trying different methods and functions and I finally got it to work.

As I believe there is no publicly released script that can achieve this purpose, I wanted to share my code with the community :smiling_face_with_three_hearts:

  • I also made it so when the player stops doing the drive-by it’ll switch him back to the view cam that he had before.

So, for this to work, put this code on the client side :smile:

------------------------------------------------------
---------  Forced First Person On Driveby  -----------
------------------------------------------------------
local recentViewMode = 0
local changedViewMode = false

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(10)
		local ped = PlayerPedId()

		if IsPedInAnyVehicle(ped) then
			local veh = GetVehiclePedIsIn(ped, false)
			if GetPedInVehicleSeat(veh, -1) == ped and IsPedDoingDriveby(ped) then
				if GetFollowVehicleCamViewMode() ~= 4 then
					recentViewMode = GetFollowVehicleCamViewMode()
					local context = GetCamActiveViewModeContext()
					SetCamViewModeForContext(context, 4)
					changedViewMode = true
				end
			end
			if changedViewMode and not IsPedDoingDriveby(ped) then
				local context = GetCamActiveViewModeContext()
				SetCamViewModeForContext(context, recentViewMode)
				changedViewMode = false
			end
		end

	end

end)

2 Likes



Looking for paid scripts? Click here