I need help with a Freecam Script for RedM. I wrote this Photo Mod Script and all runs fine, but the zoom doesnt work. I try a lot of things, but I didnt find what I do wrong. Can somebody help me? This the Code:
-- Kassios Photo Mod - Photo Modus für RedM
local photoModeActive = false
local photoCam = nil
local rotationSpeed = 8.0
local cameraOffset = vector3(1.0, -2.0, 0.2) -- Kamera bleibt stabil
local moveSpeed = 2.0
local zoomSpeed = 2.0
local minFov = 20.0
local maxFov = 120.0
-- Chatbefehl für den Photo Modus
RegisterCommand("foto", function()
print("Chatbefehl: foto ausgeführt.")
if photoModeActive then
ExitPhotoMode()
else
EnterPhotoMode()
end
end, false)
RegisterCommand("foto_x", function()
print("Chatbefehl: foto_x ausgeführt.")
ExitPhotoMode()
end, false)
-- Photo Modus Funktionen
function EnterPhotoMode()
if photoModeActive then return end
print("Photo Modus wird aktiviert...")
photoModeActive = true
DisplayHud(false)
DisplayRadar(false)
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
local camPos = coords + cameraOffset
photoCam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true)
SetCamCoord(photoCam, camPos.x, camPos.y, camPos.z)
local heading = GetEntityHeading(playerPed)
SetCamRot(photoCam, 0.0, 0.0, heading, 2)
SetCamActive(photoCam, true)
SetCamFov(photoCam, 50.0)
RenderScriptCams(true, false, 500, true, false)
print("Photo Modus AKTIV")
end
function ExitPhotoMode()
if not photoModeActive then return end
print("Photo Modus wird deaktiviert...")
photoModeActive = false
DisplayHud(true)
DisplayRadar(true)
if photoCam then
DestroyCam(photoCam, false)
RenderScriptCams(false, false, 500, true, false)
photoCam = nil
end
print("Photo Modus DEAKTIVIERT")
end
-- Kamera Bewegung und Zoom aktivieren
Citizen.CreateThread(function()
while true do
Citizen.Wait(5)
if photoModeActive and photoCam then
-- Zoom mit Mausrad
local fov = GetCamFov(photoCam)
if IsControlJustPressed(0, 241) then -- Mausrad hoch
fov = math.max(minFov, fov - zoomSpeed)
SetCamFov(photoCam, fov)
elseif IsControlJustPressed(0, 242) then -- Mausrad runter
fov = math.min(maxFov, fov + zoomSpeed)
SetCamFov(photoCam, fov)
end
-- Kamera Bewegung
local coords = GetCamCoord(photoCam)
local heading = GetCamRot(photoCam, 2).z
if IsControlPressed(0, 32) then -- W
coords = coords + vector3(math.cos(math.rad(heading)), math.sin(math.rad(heading)), 0.0) * moveSpeed
elseif IsControlPressed(0, 33) then -- S
coords = coords - vector3(math.cos(math.rad(heading)), math.sin(math.rad(heading)), 0.0) * moveSpeed
end
if IsControlPressed(0, 34) then -- A
coords = coords - vector3(math.cos(math.rad(heading + 90)), math.sin(math.rad(heading + 90)), 0.0) * moveSpeed
elseif IsControlPressed(0, 35) then -- D
coords = coords + vector3(math.cos(math.rad(heading - 90)), math.sin(math.rad(heading - 90)), 0.0) * moveSpeed
end
if IsControlPressed(0, 44) then -- Q
coords = coords + vector3(0.0, 0.0, moveSpeed)
elseif IsControlPressed(0, 36) then -- E
coords = coords - vector3(0.0, 0.0, moveSpeed)
end
SetCamCoord(photoCam, coords.x, coords.y, coords.z)
-- Maussteuerung
local mouseX = GetDisabledControlNormal(0, GetHashKey('INPUT_LOOK_LR')) * -rotationSpeed
local mouseY = GetDisabledControlNormal(0, GetHashKey('INPUT_LOOK_UD')) * -rotationSpeed
local camRot = GetCamRot(photoCam, 2)
local newRotX = math.max(-90.0, math.min(90.0, camRot.x + mouseY))
local newRotZ = (camRot.z + mouseX) % 360
SetCamRot(photoCam, newRotX, camRot.y, newRotZ, 2)
end
end
end)
Citizen.CreateThread(function()
Citizen.Wait(15000)
TriggerEvent('chat:addMessage', {
color = {255, 255, 0},
multiline = true,
args = {"📸 Photo Modus", "Nutze den Befehl /foto um den Photo Modus zu starten und /foto_x um ihn zu beenden!"}
})
end)