Jump to content

freeze camera


Xwad

Recommended Posts

Posted

How can i freeze the camera? i tryied this but it does not work

function fc()
local cam = getElementsByType ( "camera" )
setElementFrozen ( localPlayer, cam )
end
addCommandHandler("fd",fc)

 

Posted

Well, depending on what you want to achieve here are two things.

1st: If you want to lock the camera's target to a specific location or object, use setCameraMatrix

2nd: If you want to make the player to not be able to move at all, use setElementFrozen(localPlayer, true)

Posted (edited)

You can use this, you just have to trigger the event onClientIsFreezed when the player is being freezed. :D

addEvent("onClientIsFreezed", true)
addEvent("onClientIsUnFrozen", true)

local freezed = false
local fx, fy, fz, ftx, fty, ftz

function saveXYZ()
  fx, fy, fz, ftx, fty, ftz = getCameraMatrix()
  freezed = true
end
addEventHandler("onClientIsFreezed", root, saveXYZ )

function unfroze()
  freezed = false
  fx, fy, fz, ftx, fty, ftz = nil, nil, nil, nil, nil, nil
end
addEventHandler("onClientIsUnFrozen", root, unfroze)

function check()
  if ( freezed == true ) then
    local nx, ny, nz, ntx, nty, ntz = getCameraMatrix()
    if ( nx ~= fx ) or ( ny ~= fy ) or ( nz ~= fz ) or ( ntx ~= ftx ) or ( nty ~= fty ) or ( ntz ~= ftz ) then
      setCameraMatrix( fx, fy, fz, ftx, fty, ftz )
    end
  end
end
addEventHandler("onClientRender", root, check )

 

Edited by Simple01
Added unfrozen function + Fixed spelling error

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...