Jump to content

[help] Plane mission


ville

Recommended Posts

i have done plane mission working correctly, but how can i do that the plane gets destroyed after finished mission? i have tried so many things

missionMarker = createMarker ( -1626.1, -373.5, 13.4, "cylinder", 2, 0, 255, 255, 170 ) 
addEventHandler("onResourceStart", resourceRoot, 
function ( ) 
 missionBlip = createBlipAttachedTo(missionMarker,53) 
    outputChatBox( "[Plane Mission] Ota ammatti lähtölippu kuvakkelta.", player, 0, 255, 255 ) 
 end 
) 
  
addEventHandler("onMarkerHit", missionMarker, 
function ( hitElement ) 
    if (getElementType ( hitElement ) == 'player'  ) then 
    local plane = createVehicle ( 519, -1654, -162, 14, 0, 0, -45 ) 
    warpPedIntoVehicle ( hitElement, plane ) 
    outputChatBox( "[Plane Mission] Lennä punaiselle lipulle.", hitElement, 0, 255, 255 ) 
    finalMarker = createMarker ( 338, 2505, 16, "checkpoint", 6, 255, 255, 0, 170 ) 
    finalBlip = createBlipAttachedTo(finalMarker,19) 
 end 
end 
) 
  
  
  
function Remove(thePlayer) 
    if (getElementType(thePlayer) == "player") then 
        if (finalMarker ~= nil) and (source == finalMarker) then 
            if isElement(finalMarker) then 
                givePlayerMoney ( thePlayer, 10000 ) 
                removeEventHandler("onMarkerHit", finalMarker, Remove) 
                destroyElement(finalMarker) 
                outputChatBox( "[Plane Mission] Kiitos kun veit lentokoneen huoltoon. Saat 10K palkkiota.", hitElement, 0, 255, 255 ) 
            end 
            if isElement(finalBlip) then 
                destroyElement(finalBlip) 
            end 
        end 
    end 
end 
addEventHandler("onMarkerHit", getRootElement(), Remove) 

Link to comment
missionMarker = createMarker ( -1626.1, -373.5, 13.4, "cylinder", 2, 0, 255, 255, 170 ) 
addEventHandler("onResourceStart", resourceRoot, 
function ( ) 
 missionBlip = createBlipAttachedTo(missionMarker,53) 
    outputChatBox( "[Plane Mission] Ota ammatti lähtölippu kuvakkelta.", player, 0, 255, 255 ) 
 end 
) 
  
addEventHandler("onMarkerHit", missionMarker, 
function ( hitElement ) 
    if (getElementType ( hitElement ) == 'player'  ) then 
    plane = createVehicle ( 519, -1654, -162, 14, 0, 0, -45 ) 
    warpPedIntoVehicle ( hitElement, plane ) 
    outputChatBox( "[Plane Mission] Lennä punaiselle lipulle.", hitElement, 0, 255, 255 ) 
    finalMarker = createMarker (338, 2505, 16, "checkpoint", 6, 255, 255, 0, 170 ) 
    finalBlip = createBlipAttachedTo(finalMarker,19) 
 end 
end 
) 
  
  
  
function Remove(thePlayer) 
    if (getElementType(thePlayer) == "player") then 
        if (finalMarker ~= nil) and (source == finalMarker) then 
            if isElement(finalMarker) then 
                givePlayerMoney ( thePlayer, 10000 ) 
                removeEventHandler("onMarkerHit", finalMarker, Remove) 
                destroyElement(finalMarker) 
                outputChatBox( "[Plane Mission] Kiitos kun veit lentokoneen huoltoon. Saat 10K palkkiota.", hitElement, 0, 255, 255 ) 
            end 
            if isElement(finalBlip) and isElement(plane) then 
                destroyElement(finalBlip) 
                destroyElement(plane) 
            end 
        end 
    end 
end 
addEventHandler("onMarkerHit", getRootElement(), Remove) 

Link to comment
missionMarker = createMarker ( -1626.1, -373.5, 13.4, "cylinder", 2, 0, 255, 255, 170 ) 
addEventHandler("onResourceStart", resourceRoot, 
function ( ) 
 missionBlip = createBlipAttachedTo(missionMarker,53) 
    outputChatBox( "[Plane Mission] Ota ammatti lähtölippu kuvakkelta.", player, 0, 255, 255 ) 
 end 
) 
  
addEventHandler("onMarkerHit", missionMarker, 
function ( hitElement ) 
    if (getElementType ( hitElement ) == 'player'  ) then 
    plane = createVehicle ( 519, -1654, -162, 14, 0, 0, -45 ) 
    warpPedIntoVehicle ( hitElement, plane ) 
    outputChatBox( "[Plane Mission] Lennä punaiselle lipulle.", hitElement, 0, 255, 255 ) 
    finalMarker = createMarker (338, 2505, 16, "checkpoint", 6, 255, 255, 0, 170 ) 
    finalBlip = createBlipAttachedTo(finalMarker,19) 
 end 
end 
) 
  
  
  
function Remove(thePlayer) 
    if (getElementType(thePlayer) == "player") then 
        if (finalMarker ~= nil) and (source == finalMarker) then 
            if isElement(finalMarker) then 
                givePlayerMoney ( thePlayer, 10000 ) 
                removeEventHandler("onMarkerHit", finalMarker, Remove) 
                destroyElement(finalMarker) 
                outputChatBox( "[Plane Mission] Kiitos kun veit lentokoneen huoltoon. Saat 10K palkkiota.", hitElement, 0, 255, 255 ) 
            end 
            if isElement(finalBlip) and isElement(plane) then 
                destroyElement(finalBlip) 
                destroyElement(plane) 
            end 
        end 
    end 
end 
addEventHandler("onMarkerHit", getRootElement(), Remove) 

Thanks, but now i have problem.. if 2 players are doing plane mission sametime and one goes to finalmarker and gets his reward, then the other one goes and nothing happens :D

Link to comment

Test that :

plane = {} 
finalMarker = {} 
finalBlip = {} 
missionMarker = createMarker ( -1626.1, -373.5, 13.4, "cylinder", 2, 0, 255, 255, 170 ) 
addEventHandler("onResourceStart", resourceRoot, 
function ( ) 
 missionBlip = createBlipAttachedTo(missionMarker,53) 
    outputChatBox( "[Plane Mission] Ota ammatti lähtölippu kuvakkelta.", player, 0, 255, 255 ) 
 end 
) 
  
addEventHandler("onMarkerHit", missionMarker, 
function ( hitElement ) 
    if (getElementType ( hitElement ) == 'player'  ) then 
    plane[hitElement] = createVehicle ( 519, -1654, -162, 14, 0, 0, -45 ) 
    warpPedIntoVehicle ( hitElement, plane[hitElement] ) 
    outputChatBox( "[Plane Mission] Lennä punaiselle lipulle.", hitElement, 0, 255, 255 ) 
    finalMarker[hitElement] = createMarker (338, 2505, 16, "checkpoint", 6, 255, 255, 0, 170 ) 
    finalBlip[hitElement] = createBlipAttachedTo(finalMarker[thePlayer],19) 
 end 
end 
) 
  
  
  
function Remove(thePlayer) 
    if (getElementType(thePlayer) == "player") then 
        if (finalMarker[thePlayer] ~= nil) and (source == finalMarker[thePlayer]) then 
            if isElement(finalMarker[thePlayer]) then 
                givePlayerMoney ( thePlayer, 10000 ) 
                removeEventHandler("onMarkerHit", finalMarker[thePlayer], Remove) 
                destroyElement(finalMarker[thePlayer]) 
                outputChatBox( "[Plane Mission] Kiitos kun veit lentokoneen huoltoon. Saat 10K palkkiota.", hitElement, 0, 255, 255 ) 
            end 
            if isElement(finalBlip[thePlayer]) and isElement(plane[thePlayer]) then 
                destroyElement(finalBlip[thePlayer]) 
                destroyElement(plane[thePlayer]) 
            end 
        end 
    end 
end 
addEventHandler("onMarkerHit", getRootElement(), Remove) 

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