[Request] Camera Lock scipt

Just wondering if there is a server side script out there or anyone can make that locks camera horizontal or vertical just like the lambda menu.

Looking at the code of Lambda, this can be directly ported from lambda to lua.

Lambda code:

// Relative horizontal locak
float relhor = CAM::GET_GAMEPLAY_CAM_RELATIVE_HEADING();
CAM::SET_GAMEPLAY_CAM_RELATIVE_HEADING(relhor);

//Relative vertical lock
float relvert = CAM::GET_GAMEPLAY_CAM_RELATIVE_PITCH();
CAM::SET_GAMEPLAY_CAM_RELATIVE_PITCH(relvert, 0.0f);

If we would convert to Lua it would look something like this:"

local lockHorizontal = false
local lockVertical = false

Citizen.CreateThread(function()
    while true do
       if lockHorizontal then
          local heading = GetGameplayCamRelativeHeading()
          SetGameplayCamRelativeHeading(heading)
       end

       if lockVertical then
          local pitch = GetGameplayCamRelativePitch()
          SetGameplayCamRelativePitch(pitch, 0.0f)
      end

       Citizen.Wait(1)
   end
end)

Up to you on how to set the “lockVertical” and “lockHorizontal” variables, set to true will cause the desired axis to be locked.

The code was writting without being tested, may have some errors*

2 Likes

i have used this to make a script and even add it to exsisting and it doesnt seem to work

Thank you very much. This is what I have been looking for for for a long time. I have modified it and used it.

can you share it ?

-- Lock camera
local cameraLocked = true
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(1)
        if cameraLocked then
            DisableControlAction(0, 1, true)
            DisableControlAction(0, 2, true)
        end
    end  
end)