BorderLine Posted January 28, 2014 Share Posted January 28, 2014 Hola a todos, bueno hace rato que no me pasaba por aqui para pedir ayuda. he estado practicando con algunas funciones de MTA que no solia ocupar. me surgio la idea de aser unos lasers para matar a quien los toque. Eso esta hecho el tema es que quiero saber como hacer que los lasers se muevan hacia arriba o hacia abajo function drawLaser() dxDrawLine3D ( 2490, -1679.7, 13.3, 2490, -1660.4, 13.3, tocolor(255,0,0,math.random(100,230)),math.random(1,1.-- s8) -->) dxDrawLine3D ( 2485, -1679.7, 14, 2485, -1660.4, 14, tocolor(255,0,0,math.random(100,230)),math.random(1,1.-- s8) -->) end addEventHandler("onClientRender",getRootElement(),drawLaser) No estoy seguro si interpolateBetween funcione, y si es asi, como podria usarlo? quiero que el laser suba y baje interminablente. Gracias por su atencion Link to comment
MTA Team 0xCiBeR Posted January 28, 2014 MTA Team Share Posted January 28, 2014 Para algo lineal de esa magnitud, es mejor usar getTickCount y Timers para setear una nueva posición a la linea. Siempre usando estos, fuera del onClientRender. Ej:(es un ejemplo con timers que consumira bastante memoria..) z = 13.3 setTimer(function () z = 13.3+1 end,1000,1) setTimer(function () z = 13.3+2 end,2000,1) function drawLaser() dxDrawLine3D ( 2490, -1679.7, z, 2490, -1660.4, z, tocolor(255,0,0,math.random(100,230)),math.random(1,1.-- s8) --> dxDrawLine3D ( 2485, -1679.7, 14, 2485, -1660.4, 14, tocolor(255,0,0,math.random(100,230)),math.random(1,1.-- s8) --> end addEventHandler("onClientRender",getRootElement(),drawLaser) Link to comment
Alexs Posted January 28, 2014 Share Posted January 28, 2014 Para algo lineal de esa magnitud, es mejor usar getTickCount y Timers para setear una nueva posición a la linea. Siempre usando estos, fuera del onClientRender.Ej:(es un ejemplo con timers que consumira bastante memoria..) z = 13.3 setTimer(function () z = 13.3+1 end,1000,1) setTimer(function () z = 13.3+2 end,2000,1) function drawLaser() dxDrawLine3D ( 2490, -1679.7, z, 2490, -1660.4, z, tocolor(255,0,0,math.random(100,230)),math.random(1,1.-- s8) --> dxDrawLine3D ( 2485, -1679.7, 14, 2485, -1660.4, 14, tocolor(255,0,0,math.random(100,230)),math.random(1,1.-- s8) --> end addEventHandler("onClientRender",getRootElement(),drawLaser) Si estas en client-side, es mucho mas eficiente ahorrarse los timers, sobre todo si los utilizaras de esa manera. @BorderLine lo que deberías hacer es aumentar la altura de la linea en cada frame ('onClientRender'), cuando suba lo necesario que comience a bajar. Link to comment
Recommended Posts