Black2 Posted January 14, 2016 Posted January 14, 2016 Hi,how i can do for the ped respawn after death ? I try it but don't work function pedcreate () ped1 = createPed(56, -2225.376953125, 2333.6584472656, 7.546875) pedanim = setTimer ( setPedAnimation, 5000, 0, ped1, "ped", "SEAT_idle" ) --added variable here, to help clean up timers end function peddestroy ( thePlayer ) if ( isPedDead (ped1) ) then outputChatBox ( "Ped is death", thePlayer ) killTimer( pedanim ) --stop ped anim timer when destroying the ped destroyElement( ped1 ) --removed timer here, to prevent your code conflicting with the ped's respawn end end addEventHandler("onPedWasted", getRootElement(), peddestroy ) function pedrespawnafterdeath () ped1 = createPed(56, -2225.376953125, 2333.6584472656, 7.546875) pedanim = setTimer ( setPedAnimation, 5000, 0, ped1, "ped", "SEAT_idle" ) --again, define timer variable end function pednewadeath( thePlayer ) if ( isPedDead (ped1) ) then setTimer ( pedrespawnafterdeath, 5000, 1 ) outputChatBox ( "Ped Respawn work!", thePlayer ) end end addEventHandler("onPedWasted", getRootElement(), pednewadeath ) function pedspawn ( thePlayer ) setTimer ( pedcreate, 5000, 1 ) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), pedspawn ) --changed to resource root element - attaching to root element would trigger a new ped on every new resource starting subenji99 Trick Posts: 226 Joined: Sat Jan 03, 2009 8:48 pm
Chris!i! Posted January 15, 2016 Posted January 15, 2016 this should work ped1 = createPed(56, -2225.376953125, 2333.6584472656, 7.546875) pedanim = setTimer ( setPedAnimation, 5000, 0, ped1, "ped", "SEAT_idle" ) function peddestroy ( thePlayer ) if ( isPedDead (ped1) ) then outputChatBox ( "Ped is dead", thePlayer ) killTimer( pedanim ) --stop ped anim timer when destroying the ped destroyElement( ped1 ) --removed timer here, to prevent your code conflicting with the ped's respawn end end addEventHandler("onPedWasted", getRootElement(), peddestroy ) function pedrespawnafterdeath () ped1 = createPed(56, -2225.376953125, 2333.6584472656, 7.546875) pedanim = setTimer ( setPedAnimation, 5000, 0, ped1, "ped", "SEAT_idle" ) end addEventHandler ( "onPedWasted", ped1, pedrespawnafterdeath ) The rest that you did is totally useless, this will make your ped respawn after death
Black2 Posted January 15, 2016 Author Posted January 15, 2016 ped1 = createPed(56, -2225.376953125, 2333.6584472656, 7.546875) pedanim = setTimer ( setPedAnimation, 5000, 0, ped1, "ped", "SEAT_idle" ) function peddestroy ( thePlayer ) if ( isPedDead (ped1) ) then outputChatBox ( "Ped is dead", thePlayer ) killTimer( pedanim ) --stop ped anim timer when destroying the ped destroyElement( ped1 ) --removed timer here, to prevent your code conflicting with the ped's respawn end end addEventHandler("onPedWasted", getRootElement(), peddestroy ) function pedrespawnafterdeath () ped1 = createPed(56, -2225.376953125, 2333.6584472656, 7.546875) pedanim = setTimer ( setPedAnimation, 5000, 0, ped1, "ped", "SEAT_idle" ) end addEventHandler ( "onPedWasted", ped1, pedrespawnafterdeath ) this work,but if i kill ped 2 times he don't respawn why ?
ALw7sH Posted January 16, 2016 Posted January 16, 2016 local pedanim addEventHandler("onResourceStart",resourceRoot, function() local ped1 = createPed(56, -2225.376953125, 2333.6584472656, 7.546875) pedanim = setTimer ( setPedAnimation, 5000, 0, ped1, "ped", "SEAT_idle" ) addEventHandler("onPedWasted", ped1, onPedWasted) end ) function onPedWasted() outputChatBox ( "Ped is dead", root) killTimer(pedanim) removeEventHandler("onPedWasted",source,onPedWasted) -- just because destroyElement(source) ped1 = createPed(56, -2225.376953125, 2333.6584472656, 7.546875) pedanim = setTimer ( setPedAnimation, 5000, 0, ped1, "ped", "SEAT_idle" ) addEventHandler("onPedWasted", ped1, onPedWasted) end
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