tinnetju Posted June 28, 2010 Share Posted June 28, 2010 Oké, guys i made a flying UFO that flies over Los Santos. But when i run the script, nothing happens! Just nothing, i debugged the script and also nothing. Here are my files: meta.xml <meta> <info author="Tinnetju" type="script" version="1.0" /> <script src="script.lua" type="client" /> <script src="replacescript.lua" type="client" /> <file src="kmb_skip.dff" /> <file src="kmb_skip.txd" /> meta> replacescript.lua function replaceModel() txd = engineLoadTXD("kmb_skip.txd", 3065 ) engineImportTXD(txd, 3065) dff = engineLoadDFF("kmb_skip.dff", 3065 ) engineReplaceModel(dff, 3065) end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceModel) script.lua ----------------------------------------------------UFO----------------------------------------------------- function ufo0() setTimer ( ufo1, 20000, 1 ) obj = createObject ( 3065, 1816.2037353516, 2984.2958984375, 18.470184326172, 0.0, 0.0, 180.0 ) end function ufo1 () moveObject ( obj, 30000, 1819.6104736328, 2972.0537109375, 2972.0537109375 ) end function ufo2 () moveObject ( obj, 30000, 2143.0268554688, 1934.6469726563, 50.037300109863 ) end function ufo3 () moveObject ( obj, 30000, 2043.7503662109, 1484.8260498047, 37.90535736084 ) end function ufo4 () moveObject ( obj, 6000, 1968.7268066406, 1556.1391601563, 47.898307800293 ) setTimer ( ufo5, 10000, 1 ) end function ufo5 () moveObject ( obj, 90000, 35.0500831604, 2239.6882324219, 126.6796875848 ) end function ufo6 () moveObject ( obj, 90000, -2002.2766113281, 2833.1345214844, 159.09712219238 ) end function ufo7 () moveObject ( obj, 70000, -692.3271484375, 2835.298828125, 82.780288696289 ) end function ufo8 () moveObject ( obj, 48000, -150.60882568359, 2807.0397949219, 94.384284973145 ) end function ufo9 () moveObject ( obj, 45000, 376.03628540039, 2774.7685546875, 87.456558227539 ) end function ufo10 () moveObject ( obj, 38000, 706.92327880859, 2796.0771484375, 89.685066223145 ) end function ufo11 () moveObject ( obj, 80000, 1815.8771972656, 2980.8264160156, 101.33991241455 ) end function ufo12 () moveObject ( obj, 8000, 1815.8771972656, 2980.8264160156, 18.361310958862 ) end addEventHandler ( "onResourceStart", getRootElement(), ufo0 ) Link to comment
Spider Pork Posted June 28, 2010 Share Posted June 28, 2010 Just a note; you only create 2 UFO objects, 0 (with the handler) and 1 (with the timer). Also, when adding the handler, you should do this: addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), ufo0) And why create them separately? Link to comment
tinnetju Posted June 29, 2010 Author Share Posted June 29, 2010 Just a note; you only create 2 UFO objects, 0 (with the handler) and 1 (with the timer).Also, when adding the handler, you should do this: addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), ufo0) And why create them separately? What is separately...? Im from holland i don't understand expensive words... And why can i create only 2 ufo objects? Link to comment
dzek (varez) Posted June 29, 2010 Share Posted June 29, 2010 ignore Spider Pork's message, he said it wrong. you need new timer every move function (ufo1, ufo2, ufo3) --- like in ufo4 function Link to comment
tinnetju Posted June 29, 2010 Author Share Posted June 29, 2010 So a... like this: ----------------------------------------------------UFO----------------------------------------------------- function ufo0() setTimer ( ufo1, 20000, 1 ) obj = createObject ( 3065, 1816.2037353516, 2984.2958984375, 18.470184326172, 0.0, 0.0, 180.0 ) end function ufo1 () moveObject ( obj, 30000, 1819.6104736328, 2972.0537109375, 2972.0537109375 ) setTimer ( ufo2, 10000, 1 ) end function ufo2 () moveObject ( obj, 30000, 2143.0268554688, 1934.6469726563, 50.037300109863 ) setTimer ( ufo3, 10000, 1 ) end function ufo3 () moveObject ( obj, 30000, 2043.7503662109, 1484.8260498047, 37.90535736084 ) setTimer ( ufo4, 10000, 1 ) end function ufo4 () moveObject ( obj, 6000, 1968.7268066406, 1556.1391601563, 47.898307800293 ) setTimer ( ufo5, 10000, 1 ) end function ufo5 () moveObject ( obj, 90000, 35.0500831604, 2239.6882324219, 126.6796875848 ) And what has to be here? Just ufo 6 when ufo 6 doesnt exist? Or just setTimer ( ufo5, 10000, 1 ) setTimer ( ufo6, 10000, 1 ) end And this has to be like this?: addEventHandler ( "onResourceStart", getRootElement(), ufo0 ) Link to comment
dzek (varez) Posted June 29, 2010 Share Posted June 29, 2010 eeehhh... you dont have any idea about how it's working step by step, right? -- better use: ufoPositions = { { 3000, 1000, 1000, 30}, -- time, posX, posY, posZ -- notice: when time is too low, ufo movement will be just too fast, and you wont see it!! (3000 is TOO LOW BTW for more than 20 meters or something) { 3000, 500, 500, 500}, { 3000, 1000, 500, 30}, { 3000, 500, 1000, 30}, { 3000, 1000, 500, 30} -- notice there are no comma here (afair you can leave it here in lua, but im not sure) } idleTime = 1000 -- time that ufo should stop after every move (you can set it to zero, or more) -------------------- DONT TOUCH ANYTHING BELOW THIS --------------------- iterator = 1 max = #ufoPositions ufo =createObject ( 3065, 1816.2037353516, 2984.2958984375, 18.470184326172, 0.0, 0.0, 180.0) nextUfo() function nextUfo() iterator=iterator+1 if (iterator>max) then iterator = 1 end moveObject(ufo, ufoPositions[iterator][1], ufoPositions[iterator][2], ufoPositions[iterator][3], ufoPositions[iterator][4]) setTimer(nextUfo, ufoPositions[iterator][1]+idleTime, 1) end edit: NOT TESTED of course ;p 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