This script enables a free camera mode in FiveM, allowing players to take screenshots or record videos without the HUD or other UI elements interfering. The camera can move freely within a configurable range, zoom in and out, and apply different visual filters. It also includes controls for rolling (tilting) the camera and hiding all HUD elements, including NUI elements added by other scripts.
Features
Free Camera Movement: Move the camera in any direction within a configurable range.
Camera Zoom: Use the scroll wheel or Page Up/Down keys to zoom in and out.
Camera Roll: Tilt the camera using the arrow keys.
HUD and NUI Control: Hide all HUD and NUI elements for a clean screenshot or recording environment.
Filter Effects: Cycle through different visual filters using the F1 key.
Customizable: Easily configure the camera’s range, movement speed, and more.
Installation
Download the Script
Clone the repository or download it as a ZIP file and extract it. git clone https://github.com/yourusername/fivem-freecam.git
Add to Your FiveM Server
Place the extracted folder in your FiveM server’s resources directory.
Add to server.cfg
Open your server.cfg file and add the following line to ensure the script is loaded when the server starts: start dh-freecam
Configure the Script
Open the config.lua file in the fivem-freecam folder to customize the camera settings, including the range, movement speed, and keybindings.
Starting the Script
The script will start automatically when the server is launched. Players can activate the free camera mode in-game using the command configured in config.lua (default is /freecam).
Controls
W/S: Move Forward/Backward
A/D: Move Left/Right
Q/E: Move Up/Down
Scroll Wheel / Page Up/Down: Zoom In/Out
Arrow Keys: Roll (Tilt) Camera Left/Right
F1: Cycle through visual filters
F2: Toggle on-screen control helpers
/freecam: Activate/Deactivate the free camera mode
Dependencies
This script is designed to be compatible with ESX and other common frameworks, but it should work in any FiveM server setup.
Troubleshooting
If you encounter issues with the camera or UI elements not hiding, ensure that any other scripts are compatible with the NUI messages sent by this script. You may need to coordinate with the developers of other scripts to ensure full compatibility.
In cases of ESX or custom HUD scripts - You will need to either alter this script to disable the HUD using that script’s functionality, or simply use stop HUDSCRIPTNAME and temporarily stop the HUD script to hide it.
Contributing
Contributions are welcome! Feel free to submit a pull request or open an issue if you have suggestions or find a bug.
I have not, however it is open source so this can be implemented - And I may decide to add this as a built in feature in future too if that’s something people would like
Hi there! The keybinds can all be changed within the ‘client.lua’ file as below…
-- Main thread to handle free camera movement and keybinds
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if freeCamActive then
-- Disable player controls
disablePlayerControls()
-- Get the camera's current position and rotation
local camPos = GetCamCoord(cam)
local camRot = GetCamRot(cam, 2)
-- Camera movement controls
if IsControlPressed(1, 32) then -- W key (CHANGE TO KEYBIND HERE)
camPos = camPos + (GetCamForwardVector(cam) * 0.1)
end
if IsControlPressed(1, 33) then -- S key (CHANGE TO KEYBIND HERE)
camPos = camPos - (GetCamForwardVector(cam) * 0.1)
end
if IsControlPressed(1, 34) then -- A key (move left) (CHANGE TO KEYBIND HERE)
camPos = camPos + (GetCamRightVector(cam) * 0.1)
end
if IsControlPressed(1, 35) then -- D key (move right) (CHANGE TO KEYBIND HERE)
camPos = camPos - (GetCamRightVector(cam) * 0.1)
end
if IsControlPressed(1, 44) then -- Q key (move up) (CHANGE TO KEYBIND HERE)
camPos = camPos + vector3(0.0, 0.0, 0.1)
end
if IsControlPressed(1, 38) then -- E key (move down) (CHANGE TO KEYBIND HERE)
camPos = camPos - vector3(0.0, 0.0, 0.1)
end
-- Set camera position
SetCamCoord(cam, camPos)
-- Camera rotation controls (mouse controls yaw and pitch)
local xMagnitude = GetControlNormal(0, 1) * 8.0 -- Mouse X
local yMagnitude = GetControlNormal(0, 2) * 8.0 -- Mouse Y
-- Roll controls (adjust Z axis rotation for tilt)
if IsControlPressed(1, 174) then -- Arrow Left to roll left (tilt) (CHANGE TO KEYBIND HERE)
rollAngle = rollAngle - 1.0
end
if IsControlPressed(1, 175) then -- Arrow Right to roll right (tilt) (CHANGE TO KEYBIND HERE)
rollAngle = rollAngle + 1.0
end
camRot = vector3(camRot.x - yMagnitude, camRot.y, camRot.z - xMagnitude)
SetCamRot(cam, camRot.x, rollAngle, camRot.z, 2) -- Apply roll angle separately
-- Zoom controls (FOV adjustment)
if IsControlPressed(1, 16) then -- Scroll up or Page Up key to zoom in (CHANGE TO KEYBIND HERE)
currentFOV = math.max(30.0, currentFOV - 1.0) -- Min FOV of 30
SetCamFov(cam, currentFOV)
end
if IsControlPressed(1, 17) then -- Scroll down or Page Down key to zoom out (CHANGE TO KEYBIND HERE)
currentFOV = math.min(120.0, currentFOV + 1.0) -- Max FOV of 120
SetCamFov(cam, currentFOV)
end
-- Toggle filter cycling with F1 key
if IsControlJustPressed(1, 288) then -- F1 key (CHANGE TO KEYBIND HERE)
cycleFilter()
end
-- Toggle helpers with F2 key
if IsControlJustPressed(1, 289) then -- F2 key (CHANGE TO KEYBIND HERE)
helpersVisible = not helpersVisible
end
-- Draw control helpers
DrawHelpers()
end
end
end)