Dimos7 Posted January 18, 2017 Share Posted January 18, 2017 (edited) cameralocations = {1483.3354492188, -1719.1064453125, 50.896812438965, 1481.7545166016, -1803.435546875, -2.8257052898407, 1429.7171630859, -1709.8178710938, 20.389394760132, 1345.8790283203, -1666.9763183594, -13.311774253845, 1085.6225585938, -1797.7232666016, 19.463459014893, 1185.4050292969, -1796.0799560547, 25.848203659058, 1199.8775634766, -1324.5711669922, 26.630777359009, 1108.8699951172, -1321.8992919922, -14.72714138031, 1353.8889160156, -1280.1647949219, 19.625982284546, 1446.3851318359, -1283.6138916016, -18.22318649292, 1418.2659912109, -890.18493652344, 85.20630645752, 1403.9643554688, -791.30133056641, 89.388885498047} function tutorial() for #cameralocations do location = cameralocations cameraTimer = setTimer(setCameraMatrix, 5000, 1, location[1], location[2], location[3], location[4], location[5], location[6]) end end addEventHandler("onClientResourceStart", resourceRoot, tutorial) error line 4 # expect <name> near # Edited January 18, 2017 by Dimos7 Link to comment
DNL291 Posted January 18, 2017 Share Posted January 18, 2017 You're looping the table the wrong way. Also, it will not work the way you created that. cameralocations = { {1483.3354492188, -1719.1064453125, 50.896812438965, 1481.7545166016, -1803.435546875, -2.8257052898407}, {1429.7171630859, -1709.8178710938, 20.389394760132, 1345.8790283203, -1666.9763183594, -13.311774253845}, {1085.6225585938, -1797.7232666016, 19.463459014893, 1185.4050292969, -1796.0799560547, 25.848203659058}, {1199.8775634766, -1324.5711669922, 26.630777359009, 1108.8699951172, -1321.8992919922, -14.72714138031}, {1353.8889160156, -1280.1647949219, 19.625982284546, 1446.3851318359, -1283.6138916016, -18.22318649292}, {1418.2659912109, -890.18493652344, 85.20630645752, 1403.9643554688, -791.30133056641, 89.388885498047} } Try with the table like that. Link to comment
LoPollo Posted January 18, 2017 Share Posted January 18, 2017 5 minutes ago, DNL291 said: You're looping the table the wrong way. Also, it will not work the way you created that. cameralocations = { {1483.3354492188, -1719.1064453125, 50.896812438965, 1481.7545166016, -1803.435546875, -2.8257052898407}, {1429.7171630859, -1709.8178710938, 20.389394760132, 1345.8790283203, -1666.9763183594, -13.311774253845}, {1085.6225585938, -1797.7232666016, 19.463459014893, 1185.4050292969, -1796.0799560547, 25.848203659058}, {1199.8775634766, -1324.5711669922, 26.630777359009, 1108.8699951172, -1321.8992919922, -14.72714138031}, {1353.8889160156, -1280.1647949219, 19.625982284546, 1446.3851318359, -1283.6138916016, -18.22318649292}, {1418.2659912109, -890.18493652344, 85.20630645752, 1403.9643554688, -791.30133056641, 89.388885498047} } Try with the table like that. This is not enough, tell him also to fix the loop Link to comment
DNL291 Posted January 18, 2017 Share Posted January 18, 2017 3 minutes ago, LoPollo said: This is not enough, tell him also to fix the loop Yes, he's calling setTimer function inside a loop, it will not work. Regarding the loop, I already warned him. Quote You're looping the table the wrong way 1 Link to comment
Dimos7 Posted January 18, 2017 Author Share Posted January 18, 2017 cameralocations = { {1483.3354492188, -1719.1064453125, 50.896812438965, 1481.7545166016, -1803.435546875, -2.8257052898407}, {1429.7171630859, -1709.8178710938, 20.389394760132, 1345.8790283203, -1666.9763183594, -13.311774253845}, {1085.6225585938, -1797.7232666016, 19.463459014893, 1185.4050292969, -1796.0799560547, 25.848203659058}, {1199.8775634766, -1324.5711669922, 26.630777359009, 1108.8699951172, -1321.8992919922, -14.72714138031}, {1353.8889160156, -1280.1647949219, 19.625982284546, 1446.3851318359, -1283.6138916016, -18.22318649292}, {1418.2659912109, -890.18493652344, 85.20630645752, 1403.9643554688, -791.30133056641, 89.388885498047} } function tutorial() for #cameralocations do location = cameralocations cameraTimer = setTimer(setCameraMatrix, 5000, 1, location[1], location[2], location[3], location[4], location[5], location[6]) end end addEventHandler("onClientResourceStart", resourceRoot, tutorial) same error line 10 Link to comment
LoPollo Posted January 18, 2017 Share Posted January 18, 2017 (edited) That's because that's not a correct for loop in this case it's also useful to use ipairs. Another thing: you will be overwriting cameraTimer In the below code i will be using local variables as they're faster local cameralocations = { { 1483.3354492188, -1719.1064453125, 50.896812438965, 1481.7545166016, -1803.435546875, -2.8257052898407 }, { 1429.7171630859, -1709.8178710938, 20.389394760132, 1345.8790283203, -1666.9763183594, -13.311774253845 }, { 1085.6225585938, -1797.7232666016, 19.463459014893, 1185.4050292969, -1796.0799560547, 25.848203659058 }, { 1199.8775634766, -1324.5711669922, 26.630777359009, 1108.8699951172, -1321.8992919922, -14.72714138031 }, { 1353.8889160156, -1280.1647949219, 19.625982284546, 1446.3851318359, -1283.6138916016, -18.22318649292 }, { 1418.2659912109, -890.18493652344, 85.20630645752, 1403.9643554688, -791.30133056641, 89.388885498047 }, } local cameraTimers = {} function tutorial() for index,location in ipairs(cameralocations) do if isTimer( cameraTimers[index] ) then killTimer(cameraTimers[index]) cameraTimers[index] = nil end cameraTimers[index] = setTimer( setCameraMatrix, 5000, 1, location[1], location[2], location[3], location[4], location[5], location[6] ) end end addEventHandler("onClientResourceStart", resourceRoot, tutorial) This should what you wanted to do. Also notice this is completely useless since the timers are going to be executed all after 5s, so actually only the last location will be shown: wait 5s, set camera matrix to loc1, set camera matrix to loc2, ......., set camera matrix to loc6 -> only loc6 landscape will be visible (loc stands for location) If you want to change the location every 5s in a loop then tell us and it will be shown to you. like this: set to loc1, wait 5s, set to loc2, wait 5s, set to loc3, wait5s, ...., set to loc6, wait 5s, restart from loc1 Edited January 18, 2017 by LoPollo 1 Link to comment
Dimos7 Posted January 18, 2017 Author Share Posted January 18, 2017 (edited) well i want all be visible and change after 5 seconds Edited January 18, 2017 by Dimos7 Link to comment
LoPollo Posted January 18, 2017 Share Posted January 18, 2017 (edited) 7 minutes ago, Dimos7 said: i want all be visible with "all", do you mean 34 minutes ago, LoPollo said: set to loc1, wait 5s, set to loc2, wait 5s, set to loc3, wait5s, ...., set to loc6, wait 5s, restart from loc1 ? Edited January 18, 2017 by LoPollo Link to comment
Dimos7 Posted January 18, 2017 Author Share Posted January 18, 2017 (edited) yes when come to 6 location stop Edited January 18, 2017 by Dimos7 Link to comment
LoPollo Posted January 18, 2017 Share Posted January 18, 2017 local cameraLocations = { { 1483.3354492188, -1719.1064453125, 50.896812438965, 1481.7545166016, -1803.435546875, -2.8257052898407 }, { 1429.7171630859, -1709.8178710938, 20.389394760132, 1345.8790283203, -1666.9763183594, -13.311774253845 }, { 1085.6225585938, -1797.7232666016, 19.463459014893, 1185.4050292969, -1796.0799560547, 25.848203659058 }, { 1199.8775634766, -1324.5711669922, 26.630777359009, 1108.8699951172, -1321.8992919922, -14.72714138031 }, { 1353.8889160156, -1280.1647949219, 19.625982284546, 1446.3851318359, -1283.6138916016, -18.22318649292 }, { 1418.2659912109, -890.18493652344, 85.20630645752, 1403.9643554688, -791.30133056641, 89.388885498047 }, } local cameraTimers = {} function tutorial1() for index,location in ipairs(cameraLocations) do --set the timers from location if isTimer( cameraTimers[index] ) then killTimer(cameraTimers[index]) cameraTimers[index] = nil end cameraTimers[index] = setTimer( setCameraMatrix, 5000*index, 1, --5s*1st location = 5s, 5s*2nd loc = 10s, 5s*6th loc = 30s location[1], location[2], location[3], location[4], location[5], location[6] ) end if isTimer( cameraTimers[0] ) then killTimer(cameraTimers[0]) cameraTimers[0] = nil end cameraTimers[0] = setTimer( setCameraTarget, 5000*(#cameraLocations+1), 1, localPlayer ) --the camera will return to player end local activeLocation function tutorial2() if not activeLocation then activeLocation = 1 end local location = cameraLocations[activeLocation] setCameraMatrix( location[1], location[2], location[3], location[4], location[5], location[6] ) if activeLocation < #cameraLocations then activeLocation = activeLocation + 1 setTimer( tutorial2, 5000, 1 ) else setCameraTarget( localPlayer ) end end addEventHandler("onClientResourceStart", resourceRoot, tutorial1 ) --or tutorial2 This is not tested, also i tried to be as clear as possible. Please note that these 2 are not the only nor the best ways to achieve what you want, but i think they are clean and easy to understand. But everyone understand in its own way, so if you have any question we're here to answer them. Link to comment
Dimos7 Posted January 18, 2017 Author Share Posted January 18, 2017 not working no error or warning just appear los santos ganton nothing else and camera not change Link to comment
LoPollo Posted January 18, 2017 Share Posted January 18, 2017 i must have done an error i can't spot now... try changing the handler to use tutorial2: addEventHandler("onClientResourceStart", resourceRoot, tutorial1 ) change to addEventHandler("onClientResourceStart", resourceRoot, tutorial2 ) Link to comment
Dimos7 Posted January 18, 2017 Author Share Posted January 18, 2017 now go to 5 location but again set to player not go to 6 Link to comment
LoPollo Posted January 18, 2017 Share Posted January 18, 2017 (edited) oh found the problem of method 2, just a moment Edit: done local activeLocation function tutorial2() if not activeLocation then activeLocation = 1 end if activeLocation <= #cameraLocations then local location = cameraLocations[activeLocation] setCameraMatrix( location[1], location[2], location[3], location[4], location[5], location[6] ) activeLocation = activeLocation + 1 setTimer( tutorial2, 5000, 1 ) else setCameraTarget( localPlayer ) end end addEventHandler("onClientResourceStart", resourceRoot, tutorial2 ) Edited January 18, 2017 by LoPollo Link to comment
Dimos7 Posted January 20, 2017 Author Share Posted January 20, 2017 work good i want add a text from each location dx where to put them? Link to comment
LoPollo Posted January 21, 2017 Share Posted January 21, 2017 (edited) Depends of what you want: if you want text on screen (like hud... etc) then a simple dxDrawText is enough. You can also use render targets if you want to. If you want text on the world, there are a lot of things you can do: dxDrawText + getScreenFromWorldPosition, or a renderTarget + dxDrawLine3D and there is even more... like shaders etc Edited January 21, 2017 by LoPollo Link to comment
Dimos7 Posted January 21, 2017 Author Share Posted January 21, 2017 yes i know the function i mean where to put the dxDrawText in code show apear for each location Link to comment
LoPollo Posted January 21, 2017 Share Posted January 21, 2017 (edited) drawText draws the text on the screen for one frame, so if you want to display the text you must call it inside a function that handles onClientRender. If you want some examples you can see pratically every dx function (e.g dxDrawText) at the example part. Edited January 21, 2017 by LoPollo 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