Narutimmy Posted September 18, 2015 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 ) mtasa://66.85.14.178:22003 Ts3: thezombiworld.com:7777
Tomas Posted September 18, 2015 Posted September 18, 2015 ¿Cuál es el error? Currently developing for International Gaming Community - Join us!
Razor64 Posted September 18, 2015 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)
Narutimmy Posted September 20, 2015 Author 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) mtasa://66.85.14.178:22003 Ts3: thezombiworld.com:7777
Tomas Posted September 20, 2015 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) Currently developing for International Gaming Community - Join us!
Narutimmy Posted September 20, 2015 Author 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 mtasa://66.85.14.178:22003 Ts3: thezombiworld.com:7777
TheCrazy17 Posted September 20, 2015 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
Tomas Posted September 20, 2015 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á Currently developing for International Gaming Community - Join us!
Narutimmy Posted September 21, 2015 Author 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á mtasa://66.85.14.178:22003 Ts3: thezombiworld.com:7777
aka Blue Posted September 21, 2015 Posted September 21, 2015 ¿Por qué no usas el evento onPlayerDamage?
Sasu Posted September 21, 2015 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. State: Inactive
UserToDelete Posted September 21, 2015 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 )
Tomas Posted September 21, 2015 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 Currently developing for International Gaming Community - Join us!
Narutimmy Posted September 21, 2015 Author 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. mtasa://66.85.14.178:22003 Ts3: thezombiworld.com:7777
Recommended Posts