where i should put this code to script.i make like this.
local x, y, z, x1, y1, z1
local fpcam = false
bindKey( "F2", "down",
function()
if fpcam then
setCameraTarget(getLocalPlayer(), getLocalPlayer())
end
fpcam = not fpcam
end
)
addEventHandler("onClientPreRender", root,
function()
if fpcam then
x, y, z = getPedBonePosition(getLocalPlayer(), 6)
setCameraMatrix(x, y, z, x + x1, y + y1, z + z1)
dxDrawImage(screenWidth/2-10, screenHeight/2-10, 20, 20, "images/aimer.png")
local tarX, tarY, tarZ = getWorldFromScreenPosition(screenWidth/2, screenHeight/2, 30)
setPedAimTarget(getLocalPlayer(), tarX, tarY, tarZ)
function getPointFromDistanceRotation(x,y,dist,angle)
local a=math.rad(90-angle)
local dx=math.cos(a)*dist
local dy=math.sin(a)*dist
return x+dx,y+dy
if getControlState"left" or getControlState"right" then
local _,_,Zrot=getElementRotation(getPedOccupiedVehicle(getLocalPlayer()))
wx,wy=getPointFromDistanceRotation(cx,cy,((cx-wx)^2+(cy-wy)^2)^0.5,Zrot)
end
end
end
)
addEventHandler("onClientCursorMove", root,
function( _, _, _, _, wx, wy, wz )
local cx, cy, cz = getCameraMatrix()
x1 = ( wx - cx ) / 300
y1 = ( wy - cy ) / 300
z1 = ( wz - cz ) / 300
end
)