So hopefully I can explain this clearly.
I started with this free resource:
LX - Forced Camera - FiveM Releases - Cfx.re Community
GitHub - deLiinux/lx-forcedcam: A script that changes camera when aiming a gun inside a vehicle.
And it has the ability to limit the players camera view to one of the three levels of third person view & first person view, and the ability to force first person when doing driveby’s in vehicles.
However, I would prefer this to be locked to the near and medium third person views.
I was able to do just that by modifying a couple values in the original client.lua. Now the script limits on foot Cameras to near and medium third person view, and car cameras to medium third person view only while retaining it’s ability to force players into first person view for drievbys, exactly what I wanted.
BUT… when I quit and rejoin the server, this works in the opposite way. It instead locks me into medium third person camera while on foot, and allows me to switch between near and medium while in a car… BUT… when i do get in a car, and then aim to make the secondary function of forcing first person for driveby’s, it then starts to work as intended just fine again.
I’m going to post the code I’m currently using that is producing these results. Anybody have any ideas what could be causing this strange behavior and how I could fix it so that it works when you quit and rejoin without having to get in a car and aim down sights?
local check = false
local camera = Config.Cam
local fps = 4
CreateThread(function()
while true do
if Config.ForcedFPSinVehicle then
if not IsPedInAnyVehicle(PlayerPedId()) then Wait(600) end
if IsPedDoingDriveby(PlayerPedId()) then
if GetFollowVehicleCamViewMode() == fps and check == false then
check = false
else
SetFollowVehicleCamViewMode(fps)
check = true
end
else
if check == true then
SetFollowVehicleCamViewMode(camera)
check = false
end
end
Wait(1)
else
Wait(60000)
end
end
end)
CreateThread(function()
local setpov = false
while true do
if Config.Only2CamViews then
DisableControlAction(0, 0, true)
local VehicleCurrentCamViewMode = GetFollowVehicleCamViewMode(PlayerPedId())
local context = GetCamActiveViewModeContext()
if not setpov and IsDisabledControlJustPressed(0, 0) then
setpov = true
SetCamViewModeForContext(context, 0)
elseif setpov and IsDisabledControlJustPressed(0, 0) then
setpov = false
SetCamViewModeForContext(context, camera)
end
Wait(1)
else
Wait(60000)
end
end
end)