CreateCameraWithParams
Docslocal retval = CreateCameraWithParams(camHash, posX, posY, posZ, rotX, rotY, rotZ, fov, active, rotationOrder)Description
Introduced in build 323
Create a camera with the specified camera hash, You can use SET_CAM_ natives to manipulate the camera.
Make sure to call RENDER_SCRIPT_CAMS once the camera is created, or this won't have any visible effect.
Take a look at CREATE_CAM if you would like to see the available camera names.
Parameters
| Name | Type | Description |
|---|---|---|
camHash | Hash | The hash of the camera type, use [GET_HASH_KEY](#\_0xD24D37CC275948CC) to get the camera hash from the name. |
posX | float | The x position of the camera. |
posY | float | The y position of the camera. |
posZ | float | The z position of the camera. |
rotX | float | The x rotation of the camera. |
rotY | float | The y rotation of the camera. |
rotZ | float | The z rotation of the camera. |
fov | float | The Field Of View of the camera, is the observable world that is seen. |
active | BOOL | Set to true if you wish to make this new camera the active camera. |
rotationOrder | int | The order of rotation, see [`GET_ENTITY_ROTATION`](#\_0xAFBD61CC738D9EB9). |
Quick Snippet: Get CoordinatesposXposYposZrotX
posXposYposZrotXAdd this command to your client script to retrieve precise locations in-game.
-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)
print(output)
TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)Quick Snippet: Scripted Camera→ Cam
→ CamUse this to create and control a scripted camera for this native.
-- Create a scripted camera at the player's position
local coords = GetEntityCoords(PlayerPedId())
local cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true)
SetCamCoord(cam, coords.x, coords.y, coords.z + 2.0)
SetCamRot(cam, -15.0, 0.0, GetEntityHeading(PlayerPedId()))
SetCamFov(cam, 70.0)
SetCamActive(cam, true)
RenderScriptCams(true, true, 500, true, true)
-- Restore gameplay camera:
-- RenderScriptCams(false, true, 500, true, true)
-- DestroyCam(cam, true)Returns
CamReturns a camera handle.