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)