Destroyer.- Posted January 31, 2015 Posted January 31, 2015 Hola tengo una duda con ped, lo que pasa es que cree un ped y quiero que el ped me siga , pero no se me ocurre que cada 2 segundos aparesca en mi posicion, como lo haria? function ped ( thePlayer ) if not pedxd then pedxd = createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) local px,py,pz= getElementPosition(thePlayer) setElementPosition(pedxd,px+2,py,pz) end end addCommandHandler("ped",ped) Gracias
Tomas Posted January 31, 2015 Posted January 31, 2015 Podrías hacer un timer que detecte la posición del jugador que creó el ped y que cambie la posición del ped según la del creador del mismo.
Destroyer.- Posted January 31, 2015 Author Posted January 31, 2015 Y como lo podria hacer? Es que no se me ocurre que lo siga repitiendo
Calculador Posted January 31, 2015 Posted January 31, 2015 Y como lo podria hacer? Es que no se me ocurre que lo siga repitiendo Utilizar la función: setTimer -- En esté caso setTimer(laFuncion, 2000, 0) -- El 0 en el 3 argumento es para que se repita la función, así el ped se teletransporta a ti cada 2 segundos
Destroyer.- Posted January 31, 2015 Author Posted January 31, 2015 Y como lo podria hacer? Es que no se me ocurre que lo siga repitiendo Utilizar la función: setTimer -- En esté caso setTimer(laFuncion, 2000, 0) -- El 0 en el 3 argumento es para que se repita la función, así el ped se teletransporta a ti cada 2 segundos Tira warning en el argumento 1, "got boolean" y no funca :C function ped ( thePlayer ) if pedxd then return end pedxd = createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) local px,py,pz= getElementPosition(thePlayer) test = setElementPosition(pedxd,px+2,py,pz) setTimer(test, 2000, 0) end addCommandHandler("ped",ped)
Tomas Posted January 31, 2015 Posted January 31, 2015 function ped ( thePlayer ) if pedxd then return end pedxd = createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) local px,py,pz= getElementPosition(thePlayer) timer = setTimer(function() setElementPosition(pedxd,px+2,py,pz) end, 2000, 0) end addCommandHandler("ped",ped)
Destroyer.- Posted January 31, 2015 Author Posted January 31, 2015 function ped ( thePlayer ) if pedxd then return end pedxd = createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) local px,py,pz= getElementPosition(thePlayer) timer = setTimer(function() setElementPosition(pedxd,px+2,py,pz) end, 2000, 0) end addCommandHandler("ped",ped) El timer no se repite
Alexs Posted January 31, 2015 Posted January 31, 2015 Si lo hace, pero la posición no se actualiza. function ped ( thePlayer ) if pedxd then return end thePlayer = thePlayer pedxd = createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) timer = setTimer(function() local px,py,pz= getElementPosition(thePlayer) setElementPosition(pedxd,px+2,py,pz) end, 2000, 0) end addCommandHandler("ped",ped) Perdón por la estructura visual, respondí desde un dispositivo móvil.
Tomas Posted January 31, 2015 Posted January 31, 2015 Si lo hace, pero la posición no se actualiza. function ped ( thePlayer ) if pedxd then return end thePlayer = thePlayer pedxd = createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) timer = setTimer(function() local px,py,pz= getElementPosition(thePlayer) setElementPosition(pedxd,px+2,py,pz) end, 2000, 0) end addCommandHandler("ped",ped) Perdón por la estructura visual, respondí desde un dispositivo móvil. Oh cierto, que tonto soy (es malo responder a las 5 AM ), por cierto, puedes usar animaciones para que se vea más cool, ya que ahí sólo se teletransporta atrás tuyo y queda un poco feo
Recommended Posts