Jump to content

Matrix cams


CapY

Recommended Posts

Well i have a problem with switching matrix cams .

local matrixCams = { 
--{camX,camY,camZ,sthZ,distance} 
    {1614.837, -1301.275, 38.188, 200, 400}, --LS 
    {2052.229, 1559.058, 10.671, 125, 200}, --LV 
    {-1856.736, 807.699, 112.546, 300, 250},  --SF 
} 
  
function setCameraOnPlayerJoin() 
     -- set the player's camera to a fixed position, looking at a fixed point 
     if getCameraMatrix() then 
     setTimer(matrixCams,5,5) 
     addEventHandler("onClientGUIClick", Button1[1],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn2[2],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn3[3],camTarget, false ) 
    end 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),setCameraOnPlayerJoin) 
  

Error on line 11.

EDIT: This is just a part of the code.

Link to comment

5?

Minimum timer time interval is 50.

local matrixCams = { 
--{camX,camY,camZ,sthZ,distance} 
    {1614.837, -1301.275, 38.188, 200, 400}, --LS 
    {2052.229, 1559.058, 10.671, 125, 200}, --LV 
    {-1856.736, 807.699, 112.546, 300, 250},  --SF 
} 
  
function setCameraOnPlayerJoin() 
     -- set the player's camera to a fixed position, looking at a fixed point 
     if getCameraMatrix() then 
     setTimer(matrixCams,50,5) 
     addEventHandler("onClientGUIClick", Button1[1],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn2[2],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn3[3],camTarget, false ) 
    end 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),setCameraOnPlayerJoin) 

Edited by Guest
Link to comment

Sincerely i dont know what i did on switchMatrixCams , because i dont know which function i must use .

function switchMatrixCams(old,new) 
local matrixCams = { 
    {1614.837, -1301.275, 38.188, 200, 400}, --LS 
    {2052.229, 1559.058, 10.671, 125, 200}, --LV 
    {-1856.736, 807.699, 112.546, 300, 250},  --SF 
} 
end 

function setCameraOnPlayerJoin() 
     -- set the player's camera to a fixed position, looking at a fixed point 
     if getCameraMatrix() then 
     setTimer(switchMatrixCams,50,5) 
     addEventHandler("onClientGUIClick", Button1[1],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn2[2],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn3[3],camTarget, false ) 
    end 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),setCameraOnPlayerJoin) 

Anyone can help ?

Link to comment

so switchMatrixCams is called 5 times every 50 ms..

So what do you expect the script to do? Everytime it's called, a table of matrixes will be created..

This is non-sense..

Below code should work, however you do not specify LookAt 3rd argument so I dont know how good this will look

  
local matrixCams = { 
    {1614.837, -1301.275, 38.188, 200, 400}, --LS 
    {2052.229, 1559.058, 10.671, 125, 200}, --LV 
    {-1856.736, 807.699, 112.546, 300, 250},  --SF 
} 
function switchMatrixCams() 
     local rand = math.random(1, #matrixCams) 
     local x,y,z, lx, ly = unpack(matrixCams[rand]) 
     setCameraMatrix(x,y,z, lx,ly) 
end 
  
function setCameraOnPlayerJoin() 
     -- set the player's camera to a fixed position, looking at a fixed point 
     if getCameraMatrix() then 
     setTimer(switchMatrixCams,50,5) 
     addEventHandler("onClientGUIClick", Button1[1],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn2[2],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn3[3],camTarget, false ) 
    end 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),setCameraOnPlayerJoin) 
  

Edited by Guest
Link to comment

Sometimes camera switch for 10 secs , sometimes for 1 minute and cameras doesn't go one after the other.

local matrixCams = { 
    --{positionX,positionY,positionZ,lookAtX,lookAtY,lookAtZ, roll, fov} 
    {1614.837, -1301.275, 138.188, 200, 400, 102,0,180}, --LS 
    {2052.229, 1559.058, 20.671, 125, 200, 101, 0, 150}, --LV 
    {-1856.736, 807.699, 115.546, 300, 250,99.98, 70, 90},  --SF 
    {1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316,0,180},--Vinewood Sign  
} 
  
  
function switchMatrixCams() 
     local rand = math.random(1, #matrixCams) 
     local positionX,positionY,positionZ,lookAtX,lookAtY,lookAtZ, roll, fov = unpack(matrixCams[rand]) 
     if getCameraMatrix() then 
     setCameraMatrix(positionX,positionY,positionZ,lookAtX,lookAtY,lookAtZ, roll, fov) 
     setTimer(switchMatrixCams,10000,0) 
    end 
end 
  
function setCameraOnPlayerJoin() 
     -- set the player's camera to a fixed position, looking at a fixed point 
     addEventHandler("onClientGUIClick", Button1[1],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn2[2],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn3[3],camTarget, false ) 
     killTimer(setTimer,switchMatrixCams) 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),setCameraOnPlayerJoin)  

Anyone can help.

Link to comment
local table = { posX , posY , posZ } 
  
local posX , posY , posZ = unpack ( table ) 

Unpacks the table, a table have x, y, z coordinates.

you can do: x, y, z = unpack(table)

local matrixCams = { 
    --{positionX,positionY,positionZ,lookAtX,lookAtY,lookAtZ, roll, fov} 
    {1614.837, -1301.275, 138.188, 200, 400, 102,0,180}, --LS 
    {2052.229, 1559.058, 20.671, 125, 200, 101, 0, 150}, --LV 
    {-1856.736, 807.699, 115.546, 300, 250,99.98, 70, 90},  --SF 
    {1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316,0,180}--Vinewood Sign 
} 
 local index = 1 
function switchMatrixCams() 
     local positionX,positionY,positionZ,lookAtX,lookAtY,lookAtZ, roll, fov = unpack(matrixCams[index]) 
     if getCameraMatrix() then 
     setCameraMatrix(positionX,positionY,positionZ,lookAtX,lookAtY,lookAtZ, roll, fov) 
     setTimer(switchMatrixCams,10000,1) 
     index = index + 1 
     if index > #matrixCams then 
         index = 1 
     end 
    end 
end 
  
function setCameraOnPlayerJoin() 
     -- set the player's camera to a fixed position, looking at a fixed point 
     addEventHandler("onClientGUIClick", Button1[1],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn2[2],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn3[3],camTarget, false ) 
     switchMatrixCams ( ) 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),setCameraOnPlayerJoin) 

Link to comment

try to use this

dat1 ={"1614.837","2052.229"}         --   x cordinates for each location 
dat2 ={"-1301.275","1559.058"}              -- y cordinates for each location  
dat3 ={}                                             --- z cordinates for each one  
dat4 ={}                                              -- and so on  
dat5 ={} 
dat6 ={} 
dat7 ={} 
dat8 ={} 

and then

local rand = math.random(1, #dat1) 

and then

setCameraMatrix(dat1[rand],dat2[rand],dat3[rand],dat4[rand],dat5[rand],dat6[rand], dat7[rand], dat8[rand]) 

Link to comment
try to use this
dat1 ={"1614.837","2052.229"}         --   x cordinates for each location 
dat2 ={"-1301.275","1559.058"}              -- y cordinates for each location  
dat3 ={}                                             --- z cordinates for each one  
dat4 ={}                                              -- and so on  
dat5 ={} 
dat6 ={} 
dat7 ={} 
dat8 ={} 

and then

local rand = math.random(1, #dat1) 

and then

setCameraMatrix(dat1[rand],dat2[rand],dat3[rand],dat4[rand],dat5[rand],dat6[rand], dat7[rand], dat8[rand]) 

it is correct, except #dat1, you need to specify the count of tables elsewhere...

Link to comment

One more problem , when a click on a play button i play normally , but after 10 seconds setCameraMatrix continue to work..

After gui click matrixCamera needs to be stopped, anybody can help ?

NOTE:This is just a part of the code:

local matrixCams = { 
    --{positionX,positionY,positionZ,lookAtX,lookAtY,lookAtZ, roll, fov} 
    {1614.837, -1301.275, 138.188, 200, 400, 102,0,180}, --LS 
    {2052.229, 1559.058, 20.671, 125, 200, 101, 0, 150}, --LV 
    {-1856.736, 807.699, 115.546, 300, 250,99.98, 70, 90},  --SF 
    {1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316,0,180}--Vinewood Sign 
} 
 local index = 1 
function switchMatrixCams() 
     local positionX,positionY,positionZ,lookAtX,lookAtY,lookAtZ, roll, fov = unpack(matrixCams[index]) 
     if getCameraMatrix() then 
     setCameraMatrix(positionX,positionY,positionZ,lookAtX,lookAtY,lookAtZ, roll, fov) 
     setTimer(switchMatrixCams,10000,1) 
     index = index + 1 
     if index > #matrixCams then 
         index = 1 
     end 
    end 
end 
  
  
function setCameraOnPlayerJoin() 
     -- set the player's camera to a fixed position, looking at a fixed point 
     addEventHandler("onClientGUIClick", Button1[1],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn2[2],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn3[3],camTarget, false ) 
     switchMatrixCams ( ) 
     killTimer(switchMatrixCams) 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),setCameraOnPlayerJoin) 

Link to comment

What is this.

killTimer on function.

And exactly when the function starts.

local matrixCams = { 
    --{positionX,positionY,positionZ,lookAtX,lookAtY,lookAtZ, roll, fov} 
    {1614.837, -1301.275, 138.188, 200, 400, 102,0,180}, --LS 
    {2052.229, 1559.058, 20.671, 125, 200, 101, 0, 150}, --LV 
    {-1856.736, 807.699, 115.546, 300, 250,99.98, 70, 90},  --SF 
    {1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316,0,180}--Vinewood Sign 
} 
 local index = 1 
function switchMatrixCams() 
     local positionX,positionY,positionZ,lookAtX,lookAtY,lookAtZ, roll, fov = unpack(matrixCams[index]) 
     if getCameraMatrix() then 
     setCameraMatrix(positionX,positionY,positionZ,lookAtX,lookAtY,lookAtZ, roll, fov) 
     camTimer = setTimer(switchMatrixCams,10000,1) 
     index = index + 1 
     if index > #matrixCams then 
         index = 1 
     end 
    end 
end 
  
  
function setCameraOnPlayerJoin() 
     -- set the player's camera to a fixed position, looking at a fixed point 
     addEventHandler("onClientGUIClick", Button1[1],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn2[2],camTarget, false ) 
     addEventHandler("onClientGUIClick", Btn3[3],camTarget, false ) 
     switchMatrixCams ( ) 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),setCameraOnPlayerJoin) 
  
function stopCamSwitch ( ) 
killTimer ( camTimer ) 
end 

Use stopCamSwitch to stop camera switching.

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