CapY Posted September 11, 2011 Share Posted September 11, 2011 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
JR10 Posted September 11, 2011 Share Posted September 11, 2011 (edited) 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 September 11, 2011 by Guest Link to comment
CapY Posted September 11, 2011 Author Share Posted September 11, 2011 (edited) Where are matrixCams defined ? EDIT:Doesnt work. Error on line 2. Edited September 11, 2011 by Guest Link to comment
JR10 Posted September 11, 2011 Share Posted September 11, 2011 Are you f*cking kidding me? It's your code, and you said it's not the full one, are you high? Link to comment
Aibo Posted September 11, 2011 Share Posted September 11, 2011 matrixCams is a table, not a function, you can't call it with a timer. JR10: you haven't copied the full code in your post, missed the "local matrixCams = {" declaration. Link to comment
CapY Posted September 11, 2011 Author Share Posted September 11, 2011 matrixCams is a table, not a function, you can't call it with a timer. Yes i know i can't call a table because i'm trying to fix it , but i don't know how . Link to comment
JR10 Posted September 11, 2011 Share Posted September 11, 2011 (edited) JR10: you haven't copied the full code in your post, missed the "local matrixCams = {" declaration. Yea, just noticed that. Edited September 11, 2011 by Guest Link to comment
CapY Posted September 11, 2011 Author Share Posted September 11, 2011 Then edit the code, if you can. Link to comment
JR10 Posted September 11, 2011 Share Posted September 11, 2011 It won't work either, because you still trying to call a table. Should be a function for getting data and setCameraMatrix. Link to comment
CapY Posted September 11, 2011 Author Share Posted September 11, 2011 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
BinSlayer1 Posted September 11, 2011 Share Posted September 11, 2011 (edited) 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 September 11, 2011 by Guest Link to comment
qaisjp Posted September 11, 2011 Share Posted September 11, 2011 Use toursa from the community and put in your own coordinates. Give credits to owners (John_Michael and qaisjp) too. Link to comment
CapY Posted September 11, 2011 Author Share Posted September 11, 2011 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
qaisjp Posted September 11, 2011 Share Posted September 11, 2011 Can you explain what the function unpack does? I am not sure Link to comment
JR10 Posted September 11, 2011 Share Posted September 11, 2011 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
bandi94 Posted September 11, 2011 Share Posted September 11, 2011 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
karlis Posted September 11, 2011 Share Posted September 11, 2011 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
CapY Posted September 11, 2011 Author Share Posted September 11, 2011 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
JR10 Posted September 11, 2011 Share Posted September 11, 2011 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
50p Posted September 11, 2011 Share Posted September 11, 2011 Doesnt works. Use stopCamSwitch to stop camera switching. Link to comment
CapY Posted September 11, 2011 Author Share Posted September 11, 2011 Use stopCamSwitch to stop camera switching. Well ..you already did it in the script . Link to comment
JR10 Posted September 11, 2011 Share Posted September 11, 2011 I just added the function, you must trigger it. Link to comment
CapY Posted September 12, 2011 Author Share Posted September 12, 2011 From a server side ? Link to comment
Castillo Posted September 12, 2011 Share Posted September 12, 2011 By trigger I guess he meant, use, example via command, event handler, whatever you want. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now