Jump to content

Destroy Element Issue


toptional

Recommended Posts

Here is the client

function SpawnDodo () 
    triggerServerEvent ( "spawnDodo", localPlayer ) 
    guiSetVisible(Window2, false) 
    showCursor(false) 
    destroyElement ( DestinationBlip ) 
    destroyElement ( DestinationMarker ) 
    PasengerMarker = createMarker (1574.69788, 1503.02808, 10.8363, "checkpoint",5,9,233,213,105 ) 
    addEventHandler ( "onClientMarkerHit", PasengerMarker, mainFunction ) 
end 
addEventHandler ( 'onClientGUIClick', Button2, SpawnDodo, false ) 

And here the server

addEvent ( "spawnDodo", true) 
addEventHandler ("spawnDodo", root, 
    function () 
            destroyElement ( source ) 
        local dodo = createVehicle ( 593, 1580.09619, 1358.62195, 16, 0, 0,180 ) 
            warpPedIntoVehicle( source, dodo ) 
            outputChatBox ("#00CD66You will now take your first flight! Go to the blip marked on your map to pickup your first passenger.", source,24,116,205, true) 
            fixVehicle ( dodo ) 
            outputChatBox ("#EE9A00Please make your way to the terminal to pick the passnegers.", source,24,116,205, true) 
            --destroyElement ( getRootElement() ) 
    end 
) 
  
  

My issue is this im trying to do this:

when you hit this marker a gui shows up and you press the button and it spawns a dodo and destroys the current car you are in, althought when i change the destroyElement to ( source ) nothing is destroyed but with ( getRootElement() ) all the cars are destroyed which is not what i want

Any help?

Link to comment
addEvent ( "spawnDodo", true) 
addEventHandler ("spawnDodo", root, 
    function () 
            if (dodo) then 
            destroyElement( dodo ) 
            end 
        local dodo = createVehicle ( 593, 1580.09619, 1358.62195, 16, 0, 0,180 ) 
            warpPedIntoVehicle( source, dodo ) 
            outputChatBox ("#00CD66You will now take your first flight! Go to the blip marked on your map to pickup your first passenger.", source,24,116,205, true) 
            fixVehicle ( dodo ) 
            outputChatBox ("#EE9A00Please make your way to the terminal to pick the passnegers.", source,24,116,205, true) 
            --destroyElement ( getRootElement() ) 
    end 
) 

Link to comment
addEvent ( "spawnDodo", true) 
addEventHandler ("spawnDodo", root, 
    function () 
            local v = getPedOccupiedVehicle(source) 
            if v then 
            destroyElement( v ) 
            end 
        local dodo = createVehicle ( 593, 1580.09619, 1358.62195, 16, 0, 0,180 ) 
            warpPedIntoVehicle( source, dodo ) 
            outputChatBox ("#00CD66You will now take your first flight! Go to the blip marked on your map to pickup your first passenger.", source,24,116,205, true) 
            fixVehicle ( dodo ) 
            outputChatBox ("#EE9A00Please make your way to the terminal to pick the passnegers.", source,24,116,205, true) 
            --destroyElement ( getRootElement() ) 
    end 
) 

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