Jump to content

SOLVED


Recommended Posts

i need help. even the player dies, leaves the marker, quit, timer still continues

any help? there are no errors :(

function onDie( ) 
    if isTimer( timing ) and getElementsWithinColShape( theShape ) == 0 then 
        cancelTimer( timing ) 
    end 
end 
addEventHandler( "onPlayerWasted", root, onDie ) 
addEventHandler( "onPlayerQuit", root, onDie ) 
addEventHandler( "onMarkerLeave", root, onDie ) 

Edited by Guest
Link to comment
function onDie( ) 
    if isTimer( timing ) and getElementsWithinColShape( theShape ) == 0 then 
        killTimer( timing ) 
    end 
end 
addEventHandler( "onPlayerWasted", root, onDie ) 
addEventHandler( "onPlayerQuit", root, onDie ) 
addEventHandler( "onMarkerLeave", root, onDie ) 

Link to comment

it still continues the timer btw...

here is the main part of the script, anything wrong?

everythings fine but the prob is if player leaves , timer still continues

addEventHandler("onMarkerHit", marker, function(player) 
    if isPedInVehicle(player) then return; end 
    if (isMarerHidden == true) then return; end 
    if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Resistances") then 
        outputChatBox("Stay in the marker, do not leave the marker or you will not get the money.", player, 255, 0, 0); 
        if (isTimer( timing )) then 
            return 
        end 
        timing = setTimer(function() 
            for _,v in ipairs(getElementsByType("player")) do 
                if isElementWithinColShape(v, theShape) then 
                    givePlayerMoney(v, 5000); 
                    outputChatBox("Robbery Success, Robbery will be available again in 5 minutes.", v, 0, 255, 0); 
                end 
            end 
            setElementAlpha(marker, 0); 
            isMarerHidden = true; 
            setTimer(function() 
                setElementAlpha(marker, 70); 
                isMarerHidden = false; 
            end, 60000, 1); 
        end, 5000, 1); 
    end 
end); 

Edited by Guest
Link to comment
  
function onDie( ) 
    if isTimer( timing ) and #getElementsWithinColShape( theShape ) == 0 then 
        killTimer( timing ) 
    end 
end 
addEventHandler( "onPlayerWasted", root, onDie ) 
addEventHandler( "onPlayerQuit", root, onDie ) 
addEventHandler( "onMarkerLeave", root, onDie ) 
  

-_-.

Link to comment
  
function onDie( ) 
    if isTimer( timing ) and #getElementsWithinColShape( theShape ) == 0 then 
        killTimer( timing ) 
    end 
end 
addEventHandler( "onPlayerWasted", root, onDie ) 
addEventHandler( "onPlayerQuit", root, onDie ) 
addEventHandler( "onMarkerLeave", root, onDie ) 
  

-_-.

This code won't work,

Try this:

function onDie( ) 
    if (eventName == "onPlayerWasted") then  
        if ( isTimer( timing ) and #getElementsWithinColShape(getElementColShape(theShape), "player") == 0 )  then 
            killTimer( timing ) 
        end 
    elseif (eventName == "onPlayerQuit") then  
        if ( isTimer( timing ) and #getElementsWithinColShape(getElementColShape(theShape), "player") == 0 ) then 
            killTimer( timing ) 
        end 
    elseif (eventName == "onMarkerLeave") then  
        if ( isTimer( timing ) and #getElementsWithinColShape(getElementColShape(theShape), "player") == 0 )  then 
            killTimer( timing ) 
        end 
    end  
end 
addEventHandler( "onPlayerWasted", root, onDie ) 
addEventHandler( "onPlayerQuit", root, onDie ) 
addEventHandler( "onMarkerLeave", root, onDie ) 

Link to comment
SOLVED

no need to fight, both codes work. even anubhav's

Fight? no man

I said that, because I know what I am talking about,

Read the wiki:

https://wiki.multitheftauto.com/wiki/Is ... inColShape

this function requires two arguments

What shit are you talking? Your code is rather longer and my is shorter. Also my code's performence is better. You don't need to put so many ifs.

Also he is NOT USING THAT FUNCTION RATHER THIS: getElementsWithinColShape

/end

Link to comment
SOLVED

no need to fight, both codes work. even anubhav's

Fight? no man

I said that, because I know what I am talking about,

Read the wiki:

https://wiki.multitheftauto.com/wiki/Is ... inColShape

this function requires two arguments

What :~ are you talking? Your code is rather longer and my is shorter. Also my code's performence is better. You don't need to put so many ifs.

Also he is NOT USING THAT FUNCTION RATHER THIS: getElementsWithinColShape

/end

Hey calm down, I didn't mean anything bad, I just said this function requires two arguments else it won't work as the wiki said:

Required Arguments

theElement: The element you're checking.

theShape: The colshape you're checking

Returns

Returns true if the element is within the colshape, false otherwise

IsElementWithinColShape

and sorry If you understood it by wrong, we are here to help and learn from our mistakes I'm gonna test it right now and see the result maybe I am wrong, I just followed the wiki's words.

Link to comment
I'm not angry. But you are wrong here, he was not using that function. He was not using: isElementWithinColShape but rather: getElementsWithinColShape

What's wrong man? Why are you so confused?

Yes you're right, I am sorry I didn't take attention,I tought he used isElementWithinColShape ,it was 4 AM for me so yeah that's why

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...