Jump to content

Plane mission need help!


Miika

Recommended Posts

addEventHandler("onMarkerHit", finalMarker, Remove) 

'finalMarker' wasn't yet created and so not defined. That's why it's not working. Try this:

missionMarker = createMarker ( -1305.2, -120.3, 13.4, "cylinder", 2, 0, 255, 255, 170 ) 
addEventHandler("onResourceStart", resourceRoot, 
function ( ) 
 missionBlip = createBlipAttachedTo(missionMarker,53) 
    outputChatBox( "[Plane Mission] Älä vielä mene lentokone missionille. se on kesken", source, 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( ) 
    if (finalMarker ~= nil) and (source == finalMarker) then 
        if isElement(finalMarker) then 
            removeEventHandler("onMarkerHit", finalMarker, Remove) 
            destroyElement(finalMarker) 
        end 
        if isElement(finalBlip) then 
            destroyElement(finalBlip) 
        end 
    end 
end 
addEventHandler("onMarkerHit", getRootElement(), Remove) 

It working! Yeah

Link to comment

Next problem :DD

It not give cash.

Code:

missionMarker = createMarker ( -1305.2, -120.3, 13.4, "cylinder", 2, 0, 255, 255, 170 ) 
addEventHandler("onResourceStart", resourceRoot, 
function ( ) 
 missionBlip = createBlipAttachedTo(missionMarker,53) 
    outputChatBox( "[Plane Mission] Älä vielä mene lentokone missionille. se on kesken", 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( ) 
    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 
addEventHandler("onMarkerHit", getRootElement(), Remove) 

Link to comment
'thePlayer' is not defined. Also, agian, check or theElement is a player.

PS: Remember this is server-sided, which means, EVERY PLAYER can now touch that marker, and 'steal' the job.

givePlayerMoney ( theElement, 10000 ) 

Not working

Link to comment
'thePlayer' is not defined. Also, agian, check or theElement is a player.

PS: Remember this is server-sided, which means, EVERY PLAYER can now touch that marker, and 'steal' the job.

givePlayerMoney ( theElement, 10000 ) 

Not working

change it to source

Link to comment

Dudes... Srsly?

missionMarker = createMarker ( -1305.2, -120.3, 13.4, "cylinder", 2, 0, 255, 255, 170 ) 
addEventHandler("onResourceStart", resourceRoot, 
function ( ) 
 missionBlip = createBlipAttachedTo(missionMarker,53) 
    outputChatBox( "[Plane Mission] Älä vielä mene lentokone missionille. se on kesken", 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) 

Just define theElement in the function ('thePlayer') and check or it's a player.

Link to comment
Dudes... Srsly?
missionMarker = createMarker ( -1305.2, -120.3, 13.4, "cylinder", 2, 0, 255, 255, 170 ) 
addEventHandler("onResourceStart", resourceRoot, 
function ( ) 
 missionBlip = createBlipAttachedTo(missionMarker,53) 
    outputChatBox( "[Plane Mission] Älä vielä mene lentokone missionille. se on kesken", 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) 

Just define theElement in the function ('thePlayer') and check or it's a player.

I get cash but other players wont get cash :o

Link to comment

Now I'm making client side and panel.

[server side error]

WARNING: Plane-mission.lua:6: Bad argument @ 'WarpPedIntoVehicle' 

[server]

missionMarker = createMarker ( -1305.2, -120.3, 13.4, "cylinder", 2, 0, 255, 255, 170 ) 
  
-- Trigger -- 
function MarkerHit( hitElement, matchingDimension ) 
    local plane = createVehicle ( 519, 70.21049, -233.00739, 2.33665 ) 
    warpPedIntoVehicle ( hitElement, plane ) 
    outputChatBox( "[Plane Mission] Test", source, 0, 255, 255 ) 
end 
addEvent ( "onMissionAccept", true ) 
addEventHandler ( "onMissionAccept", root, MarkerHit ) 
  
function createMissionMarker() 
    missionBlip = createBlipAttachedTo(missionMarker,53) 
    outputChatBox( "[Plane Mission] Älä vielä mene lentokone missionille. se on kesken", source, 0, 255, 255 ) 
end 
addEventHandler("onResourceStart", resourceRoot, createMissionMarker) 
  
function MarkerHit( hitElement, matchingDimension ) 
    triggerClientEvent( hitElement, "createMissionGui", hitElement ) 
    outputChatBox( "[Plane Mission] Test", source, 0, 255, 255 ) 
end 
addEventHandler("onMarkerHit", missionMarker, MarkerHit) 
  

[Client]

function createAcceptPanel() 
    missionGui = guiCreateWindow(250,100,445,445,"Plane mission",false) 
    guiWindowSetSizable(missionGui, false) 
     
    showCursor( true ) 
  
    missionGuiButton1 = guiCreateButton(14, 50, 136, 58, "Accept", false, missionGui) 
    missionGuiButton2 = guiCreateButton(160, 50, 136, 58, "Cancel", false, missionGui) 
     
    addEventHandler ( "onClientGUIClick", missionGuiButton1, takeMission, false ) 
    addEventHandler ( "onClientGUIClick", missionGuiButton2, cancelMission, false ) 
end 
addEvent ( "createMissionGui", true ) 
addEventHandler ( "createMissionGui", root, createAcceptPanel ) 
  
function takeMission() 
    triggerServerEvent("onMissionAccept", localPlayer ) 
end 
  
function cancelMission() 
    guiSetVisible(missionGui, false) 
    showCursor( false ) 
end 
  

Where is the problem?

Link to comment
Again, first check or 'hitElement' is a player. >.> Also, you have 2 functions with the same name.

I fix it but same problem...

Code:

missionMarker = createMarker ( -1305.2, -120.3, 13.4, "cylinder", 2, 0, 255, 255, 170 ) 
  
-- Trigger -- 
function MarkerHit( hitElement, matchingDimension ) 
    local plane = createVehicle ( 519, -1654, -162, 14, 0, 0, -45 ) 
    warpPedIntoVehicle ( hitElement, plane ) 
    outputChatBox( "[Plane Mission] Aja perseeseen! Muista pitää hauskaa!", hitElement, 0, 255, 255 ) 
    finalMarker = createMarker ( 338, 2505, 16, "checkpoint", 6, 255, 255, 0, 170 ) 
    finalBlip = createBlipAttachedTo(finalMarker,19) 
end 
addEvent ( "onMissionAccept", true ) 
addEventHandler ( "onMissionAccept", root, MarkerHit ) 
  
function createMissionMarker() 
    missionBlip = createBlipAttachedTo(missionMarker,53) 
    outputChatBox( "[Plane Mission] Älä vielä mene lentokone missionille. se on kesken", player, 0, 255, 255 ) 
end 
addEventHandler("onResourceStart", resourceRoot, createMissionMarker) 
  
function MarkerHit( hitMarker, matchingDimension ) 
    triggerClientEvent( hitMarker, "createMissionGui", hitMarker ) 
    outputChatBox( "[Plane Mission] Test", hitMarker, 0, 255, 255 ) 
end 
addEventHandler("onMarkerHit", missionMarker, MarkerHit) 

Link to comment

--Server

missionMarker = createMarker ( -1305.2, -120.3, 13.4, "cylinder", 2, 0, 255, 255, 170 ) 
  
-- Trigger -- 
function MarkerHit( hitElement, matchingDimension ) 
    if  getElementType ( hitElement ) == 'player'  then 
    local plane = createVehicle ( 519, 70.21049, -233.00739, 2.33665 ) 
    warpPedIntoVehicle ( hitElement, plane ) 
    outputChatBox( "[Plane Mission] Test", source, 0, 255, 255 ) 
end 
addEvent ( "onMissionAccept", true ) 
addEventHandler ( "onMissionAccept", root, MarkerHit ) 
  
function createMissionMarker() 
    missionBlip = createBlipAttachedTo(missionMarker,53) 
    outputChatBox( "[Plane Mission] Älä vielä mene lentokone missionille. se on kesken", source, 0, 255, 255 ) 
end 
addEventHandler("onResourceStart", resourceRoot, createMissionMarker) 
  
function MarkerHit2( hitElement, matchingDimension ) 
    if  getElementType ( hitElement ) == 'player'  then 
    triggerClientEvent( hitElement, "createMissionGui", hitElement ) 
    outputChatBox( "[Plane Mission] Test", source, 0, 255, 255 ) 
   end 
  end 
end 
addEventHandler("onMarkerHit", missionMarker, MarkerHit2) 
Link to comment
--Server

missionMarker = createMarker ( -1305.2, -120.3, 13.4, "cylinder", 2, 0, 255, 255, 170 ) 
  
-- Trigger -- 
function MarkerHit( hitElement, matchingDimension ) 
    if  getElementType ( hitElement ) == 'player'  then 
    local plane = createVehicle ( 519, 70.21049, -233.00739, 2.33665 ) 
    warpPedIntoVehicle ( hitElement, plane ) 
    outputChatBox( "[Plane Mission] Test", source, 0, 255, 255 ) 
end 
addEvent ( "onMissionAccept", true ) 
addEventHandler ( "onMissionAccept", root, MarkerHit ) 
  
function createMissionMarker() 
    missionBlip = createBlipAttachedTo(missionMarker,53) 
    outputChatBox( "[Plane Mission] Älä vielä mene lentokone missionille. se on kesken", source, 0, 255, 255 ) 
end 
addEventHandler("onResourceStart", resourceRoot, createMissionMarker) 
  
function MarkerHit2( hitElement, matchingDimension ) 
    if  getElementType ( hitElement ) == 'player'  then 
    triggerClientEvent( hitElement, "createMissionGui", hitElement ) 
    outputChatBox( "[Plane Mission] Test", source, 0, 255, 255 ) 
   end 
  end 
end 
addEventHandler("onMarkerHit", missionMarker, MarkerHit2) 

Not working. It not create window

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