Jump to content

camera script


Recommended Posts

i made this script and the idea is that you can make custom camera angles and save them to keys 1, 2, 3, 4, 5. Im making it so i can adjust all the parameters of setCameraMatrix including roll and FOV. But it, like all my scripts, doesn't work. I have no idea what is wrong with it but it just doesn't work. I've probs done something dumb. any help is appreciated. I havent done anything in the last 4 functions as i cant get the 1st to work anyway.

function binds() 
    x,y,z = getElementPosition(player) 
    rx,ry,rz = getElementRotation(player) 
    bindkey("1", "down", cam1) 
    bindkey("2", "down", cam2) 
    bindkey("3", "down", cam3) 
    bindkey("4", "down", cam4) 
    bindkey("5", "down", cam5) 
end 
addCommandHandler("test", binds) 
  
function cam1() 
    setCameraMatrix(x,y,z,rx,ry,rz) 
end 
  
function cam2() 
     
end 
  
function cam3() 
     
end 
  
function cam4() 
     
end 
  
function cam5() 
     
end 



Link to comment

For the getElementRotation, since it's a ped, the value is only from 0(facing north) to 360.

anyways, try this:

function binds(player) --forgot the player argument 
    x,y,z = getElementPosition(player) 
    rx,ry,rz = getElementRotation(player) -- the player has only one value, so the ry and rz will be nil 
    bindKey("1", "down", cam1) --lua is case-sensitive 
    bindKey("2", "down", cam2) 
    bindKey("3", "down", cam3) 
    bindKey("4", "down", cam4) 
    bindKey("5", "down", cam5) 
end 
addCommandHandler("test", binds) 
  
function cam1() 
    setCameraMatrix(x,y,z,rx,ry,rz) 
end 
  
function cam2() 
    
end 
  
function cam3() 
    
end 
  
function cam4() 
    
end 
  
function cam5() 
    
end 

Edited by Guest
Link to comment
  
local camX, camY, camZ, tarX, tarY, tarZ 
 function binds() --client version doesn't have player parameter 
        camX, camY, camZ, tarX, tarY, tarZ = getCameraMatrix() -- isn't this what you want to do? save camera position 
        bindKey("1", "down", cam1) --lua is case-sensitive 
        bindKey("2", "down", cam2) 
        bindKey("3", "down", cam3) 
        bindKey("4", "down", cam4) 
        bindKey("5", "down", cam5) 
    end 
    addCommandHandler("test", binds) 
      
    function cam1() 
        setCameraMatrix(camX, camY, camZ, tarX, tarY, tarZ) 
    end 
      
    function cam2() 
        
    end 
      
    function cam3() 
        
    end 
      
    function cam4() 
        
    end 
      
    function cam5() 
        
    end 

Link to comment

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...