Jump to content

HELP - Rob script


Jinx099

Recommended Posts

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

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
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
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
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
  • 1 month later...
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 

  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...