Narutimmy Posted September 18, 2015 Share Posted September 18, 2015 Hola tnego un problema, pasa que tengo un contador que setea algo a un ped, y a los 5 seg nuevamente, el problema es que si el ped muere antes de que lleguen los 5 seg de la segunda tira error, como puedo arreglarlo? addEventHandler( "Taser", getRootElement(), function () if source then setElementFrozen (source,true) setElementData(source,"Anim2",true) setPedAnimation(source, "CRACK", "crckdeth2", 5000, false, false, false, true) Elemento = source if Elemento then setTimer ( setElementData, 5000, 1, Elemento , "Anim2",false ) ---23 setTimer ( setElementFrozen, 5000, 1, Elemento , false ) ----24 end end end ) Link to comment
Razor64 Posted September 18, 2015 Share Posted September 18, 2015 Tal vez podrias utilizar esto... addEventHandler( "Taser", getRootElement(), function() if source then setElementFrozen (source,true) setElementData(source,"Anim2",true) setPedAnimation(source, "CRACK", "crckdeth2", 5000, false, false, false, true) Elemento = source setTimer(function() if Elemento then setElementData(Elemento , "Anim2",false) setElementFrozen(Elemento , false) end end, 5000, 1) end end) Link to comment
Narutimmy Posted September 20, 2015 Author Share Posted September 20, 2015 Nu funciona :I addEventHandler( "Taser", getRootElement(), function() if source then setElementFrozen (source,true) setElementData(source,"Anim2",true) setPedAnimation(source, "CRACK", "crckdeth2", 5000, false, false, false, true) Elemento = source setTimer(function() if Elemento then if not isPedDead (Elemento) then ----23 setElementData(Elemento , "Anim2",false) ----24 setElementFrozen(Elemento , false) ----25 end end end, 5000, 1) end end) Link to comment
Tomas Posted September 20, 2015 Share Posted September 20, 2015 addEventHandler( "Taser", getRootElement(), function() if source then setElementFrozen (source,true) setElementData(source,"Anim2",true) setPedAnimation(source, "CRACK", "crckdeth2", 5000, false, false, false, true) setTimer(function(Elemento) if not isPedDead (Elemento) then ----23 setElementData(Elemento , "Anim2",false) ----24 setElementFrozen(Elemento , false) ----25 end end end, 5000, 1, source) end end) Link to comment
Narutimmy Posted September 20, 2015 Author Share Posted September 20, 2015 addEventHandler( "Taser", getRootElement(), function() if source then setElementFrozen (source,true) setElementData(source,"Anim2",true) setPedAnimation(source, "CRACK", "crckdeth2", 5000, false, false, false, true) setTimer(function(Elemento) if not isPedDead (Elemento) then ----23 setElementData(Elemento , "Anim2",false) ----24 setElementFrozen(Elemento , false) ----25 end end end, 5000, 1, source) end end) mismo error Otr cosa "isPedDead" no sirve ya que cuando el ped muere es destruido automaticamente Link to comment
TheCrazy17 Posted September 20, 2015 Share Posted September 20, 2015 addEventHandler( "Taser", getRootElement(), function () if source then setElementFrozen (source,true) setElementData(source,"Anim2",true) setPedAnimation(source, "CRACK", "crckdeth2", 5000, false, false, false, true) if isElement(source) and not isPedDead(source) then setTimer ( setElementData, 5000, 1, source , "Anim2",false ) ---23 setTimer ( setElementFrozen, 5000, 1, source , false ) ----24 end end end ) Así debería funcionar Link to comment
Tomas Posted September 20, 2015 Share Posted September 20, 2015 addEventHandler( "Taser", getRootElement(), function () if source then setElementFrozen (source,true) setElementData(source,"Anim2",true) setPedAnimation(source, "CRACK", "crckdeth2", 5000, false, false, false, true) if isElement(source) and not isPedDead(source) then setTimer ( setElementData, 5000, 1, source , "Anim2",false ) ---23 setTimer ( setElementFrozen, 5000, 1, source , false ) ----24 end end end ) Así debería funcionar Si el ped muere luego de la condicional el debug aparecería, cambia el isPedDead por isElement y funcionará Link to comment
Narutimmy Posted September 21, 2015 Author Share Posted September 21, 2015 addEventHandler( "Taser", getRootElement(), function () if source then setElementFrozen (source,true) setElementData(source,"Anim2",true) setPedAnimation(source, "CRACK", "crckdeth2", 5000, false, false, false, true) if isElement(source) and not isPedDead(source) then setTimer ( setElementData, 5000, 1, source , "Anim2",false ) ---23 setTimer ( setElementFrozen, 5000, 1, source , false ) ----24 end end end ) Ya Funciono muchas Gracias! Así debería funcionar Si el ped muere luego de la condicional el debug aparecería, cambia el isPedDead por isElement y funcionará Link to comment
aka Blue Posted September 21, 2015 Share Posted September 21, 2015 ¿Por qué no usas el evento onPlayerDamage? Link to comment
Sasu Posted September 21, 2015 Share Posted September 21, 2015 ¿Por qué no usas el evento onPlayerDamage? Porque está utilizando un ped, y además no sabemos si su evento se activa cuando el ped es dañado. Link to comment
aka Blue Posted September 21, 2015 Share Posted September 21, 2015 Ahh, entonces nada. Link to comment
UserToDelete Posted September 21, 2015 Share Posted September 21, 2015 Como estás triggeando el evento? addEventHandler( "Taser", getRootElement(), function () if source or client then setElementFrozen (source or client,true) setElementData(source or client,"Anim2",true) setPedAnimation(source or client, "CRACK", "crckdeth2", 5000, false, false, false, true) if isElement(source or client) and not isPedDead(source or client) then setTimer ( setElementData, 5000, 1, source or client , "Anim2",false ) ---23 setTimer ( setElementFrozen, 5000, 1, source or client , false ) ----24 end end end ) addEventHandler( "Taser", getRootElement(), function (source) if source or client then setElementFrozen (source or client,true) setElementData(source or client,"Anim2",true) setPedAnimation(source or client, "CRACK", "crckdeth2", 5000, false, false, false, true) if isElement(source or client) and not isPedDead(source or client) then setTimer ( setElementData, 5000, 1, source or client , "Anim2",false ) ---23 setTimer ( setElementFrozen, 5000, 1, source or client , false ) ----24 end end end ) Link to comment
Tomas Posted September 21, 2015 Share Posted September 21, 2015 Como estás triggeando el evento? addEventHandler( "Taser", getRootElement(), function () if source or client then setElementFrozen (source or client,true) setElementData(source or client,"Anim2",true) setPedAnimation(source or client, "CRACK", "crckdeth2", 5000, false, false, false, true) if isElement(source or client) and not isPedDead(source or client) then setTimer ( setElementData, 5000, 1, source or client , "Anim2",false ) ---23 setTimer ( setElementFrozen, 5000, 1, source or client , false ) ----24 end end end ) addEventHandler( "Taser", getRootElement(), function (source) if source or client then setElementFrozen (source or client,true) setElementData(source or client,"Anim2",true) setPedAnimation(source or client, "CRACK", "crckdeth2", 5000, false, false, false, true) if isElement(source or client) and not isPedDead(source or client) then setTimer ( setElementData, 5000, 1, source or client , "Anim2",false ) ---23 setTimer ( setElementFrozen, 5000, 1, source or client , false ) ----24 end end end ) Pasaría lo mismo, si el ped muere luego de que el timer es creado pasaría exáctamente lo mismo. Utiliza el script que te dieron por ahí arriba y cambia isPedDead por isElement Link to comment
Narutimmy Posted September 21, 2015 Author Share Posted September 21, 2015 Como estás triggeando el evento? addEventHandler( "Taser", getRootElement(), function () if source or client then setElementFrozen (source or client,true) setElementData(source or client,"Anim2",true) setPedAnimation(source or client, "CRACK", "crckdeth2", 5000, false, false, false, true) if isElement(source or client) and not isPedDead(source or client) then setTimer ( setElementData, 5000, 1, source or client , "Anim2",false ) ---23 setTimer ( setElementFrozen, 5000, 1, source or client , false ) ----24 end end end ) addEventHandler( "Taser", getRootElement(), function (source) if source or client then setElementFrozen (source or client,true) setElementData(source or client,"Anim2",true) setPedAnimation(source or client, "CRACK", "crckdeth2", 5000, false, false, false, true) if isElement(source or client) and not isPedDead(source or client) then setTimer ( setElementData, 5000, 1, source or client , "Anim2",false ) ---23 setTimer ( setElementFrozen, 5000, 1, source or client , false ) ----24 end end end ) Pasaría lo mismo, si el ped muere luego de que el timer es creado pasaría exáctamente lo mismo. Utiliza el script que te dieron por ahí arriba y cambia isPedDead por isElement Si eso es lo que ise ya esta funcionando bien Gracias a todos. Link to comment
Recommended Posts