ville Posted February 21, 2015 Share Posted February 21, 2015 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
Enargy, Posted February 21, 2015 Share Posted February 21, 2015 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
ville Posted February 21, 2015 Author Share Posted February 21, 2015 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 Link to comment
Emilio_M Posted February 21, 2015 Share Posted February 21, 2015 Create a table like plane = {} and create the vehicle like : plane[hitElement] = createVehicle.... and destroy it like : destroyElement(plane[thePlayer]) Link to comment
ville Posted February 21, 2015 Author Share Posted February 21, 2015 Create a table like plane = {} and create the vehicle like : plane[hitElement] = createVehicle.... and destroy it like : destroyElement(plane[thePlayer]) Aand the best thing is .. i dont really understand tables yet Link to comment
Emilio_M Posted February 21, 2015 Share Posted February 21, 2015 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
Emilio_M Posted February 21, 2015 Share Posted February 21, 2015 finalBlip[hitElement] = createBlipAttachedTo(finalMarker[hitElement],19) Sry, Line19 Link to comment
ville Posted February 21, 2015 Author Share Posted February 21, 2015 finalBlip[hitElement] = createBlipAttachedTo(finalMarker[hitElement],19)Sry, Line19 Yeah Thank you! 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