Jinx099 Posted August 12, 2016 Share Posted August 12, 2016 Hello guys , I used this code on a rob script , i want fix it like when the player killed or he died the rob cancels i tried many times to do it but i failed any one of you can fix it please? that's the code function cancelRob( crim, target ) if isElement( crim ) then if getElementData( crim, "arrested" ) or getElementData( crim, "Jailed" ) == "Yes" then setElementData( crim, "rob", false ) exports.GTWtopbar:dm( "Robbery failed because you left the store!", crim, 255, 0, 0 ) setPedAnimation( target, nil, nil ) if isTimer( cancelTimers[crim] ) then killTimer( cancelTimers[crim] ) end end end end addEventHandler( "onPlayerWasted", getRootElement(), cancelRob) those aren't working addEventHandler( "onPlayerWasted", getRootElement(), cancelRob) addEventHandler( "onPlayerWasted", crim, cancelRob) addEventHandler( "onPlayerWasted", target, cancelRob) Link to comment
MrDante Posted August 12, 2016 Share Posted August 12, 2016 Test now function cancelRob( crim, target ) if isPedDead(crim) then if isElement( crim ) then if getElementData( crim, "arrested" ) or getElementData( crim, "Jailed" ) == "Yes" then setElementData( crim, "rob", false ) exports.GTWtopbar:dm( "Robbery failed because you left the store!", crim, 255, 0, 0 ) setPedAnimation( target, nil, nil ) if isTimer( cancelTimers[crim] ) then killTimer( cancelTimers[crim] ) end end end end end Link to comment
Jinx099 Posted August 12, 2016 Author Share Posted August 12, 2016 Test now function cancelRob( crim, target ) if isPedDead(crim) then if isElement( crim ) then if getElementData( crim, "arrested" ) or getElementData( crim, "Jailed" ) == "Yes" then setElementData( crim, "rob", false ) exports.GTWtopbar:dm( "Robbery failed because you left the store!", crim, 255, 0, 0 ) setPedAnimation( target, nil, nil ) if isTimer( cancelTimers[crim] ) then killTimer( cancelTimers[crim] ) end end end end end Not working Link to comment
MrDante Posted August 12, 2016 Share Posted August 12, 2016 function cancelRob( crim ) if ( getElementData(source, "arrested") ) or ( getElementData( source, "Jailed" ) ) == "Yes" then removeElementData( source, "rob" ) exports.GTWtopbar:dm( "Robbery failed because you left the store!", source, 255, 0, 0 ) setPedAnimation(source, nil, nil) if isTimer( cancelTimers[source]) then killTimer(cancelTimers[source]) end end end addEventHandler("onPlayerWasted", root, cancelRob) Only now I realized, in his function he was checking who killed him, not the player who was killed Link to comment
Jinx099 Posted August 13, 2016 Author Share Posted August 13, 2016 Dante , it's not working too Link to comment
ManeXi Posted August 14, 2016 Share Posted August 14, 2016 function cancelRob() setElementData(source, "rob", false) exports.GTWtopbar:dm( "Robbery failed because you died, fool!", source, 255, 0, 0 ) setPedAnimation(source, nil, nil) if isTimer(cancelTimers[source]) then killTimer(cancelTimers[source]) end end addEventHandler("onPlayerWasted", root, cancelRob) I'm pretty sure this will stop him robbing, but I've got my doubts about the timer, you should post here how "cancelTimers" adds the client to the timer table Link to comment
Jinx099 Posted September 25, 2016 Author Share Posted September 25, 2016 On 14/08/2016 at 2:02 AM, OverMind said: function cancelRob() setElementData(source, "rob", false) exports.GTWtopbar:dm( "Robbery failed because you died, fool!", source, 255, 0, 0 ) setPedAnimation(source, nil, nil) if isTimer(cancelTimers[source]) then killTimer(cancelTimers[source]) end end addEventHandler("onPlayerWasted", root, cancelRob) I'm pretty sure this will stop him robbing, but I've got my doubts about the timer, you should post here how "cancelTimers" adds the client to the timer table it's the same thing the rob doesn't cancels 1 Link to comment
Gravestone Posted September 25, 2016 Share Posted September 25, 2016 What is the table name which stores the timers? Link to comment
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