Jump to content

[HELP]


Recommended Posts

Why destroyElement doesn't detect playerMarker
 
 
 
-- Server Side
addEventHandler("onPlayerQuit", root,
	function()
		if isElement(vehicle[source]) then
			destroyElement(vehicle[source])
			vehicle[source] = nil
	end
end)

vehicle = {}

addEvent("car", true)
addEventHandler("car", root,
    function()
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) end
        local x, y, z = getElementPosition(source)
        vehicle[source] = createVehicle(579, 341.7890625, -1373.0964355469, 14.366669654846, 0, 380, 470) --599 is the vehicle's hands. Put any vehicle you want
        warpPedIntoVehicle(source, vehicle[source])
        playerMarker = createMarker(313.41094970703, -1394.2287597656, 13.993467330933, "cylinder", 4, 255, 0, 0, 0)
        addEventHandler("onMarkerHit", playerMarker, handlePlayerMarker)
end)

function handlePlayerMarker(hitElement)
    local elementType = getElementType(hitElement)
    destroyElement(playerMarker)
end

 

Link to comment
On 06/08/2022 at 12:41, Firespider said:
Why destroyElement doesn't detect playerMarker
 
 
 
-- Server Side
addEventHandler("onPlayerQuit", root,
	function()
		if isElement(vehicle[source]) then
			destroyElement(vehicle[source])
			vehicle[source] = nil
	end
end)

vehicle = {}

addEvent("car", true)
addEventHandler("car", root,
    function()
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) end
        local x, y, z = getElementPosition(source)
        vehicle[source] = createVehicle(579, 341.7890625, -1373.0964355469, 14.366669654846, 0, 380, 470) --599 is the vehicle's hands. Put any vehicle you want
        warpPedIntoVehicle(source, vehicle[source])
        playerMarker = createMarker(313.41094970703, -1394.2287597656, 13.993467330933, "cylinder", 4, 255, 0, 0, 0)
        addEventHandler("onMarkerHit", playerMarker, handlePlayerMarker)
end)

function handlePlayerMarker(hitElement)
    local elementType = getElementType(hitElement)
    destroyElement(playerMarker)
end

 

-- Server Side
addEventHandler("onPlayerQuit", root,
    function()
        if isElement(vehicle[source]) then
            destroyElement(vehicle[source])
            vehicle[source] = nil
    end
end)

vehicle = {}

addEvent("car", true)
addEventHandler("car", root,
    function()
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) end
        local x, y, z = getElementPosition(source)
        vehicle[source] = createVehicle(579, 341.7890625, -1373.0964355469, 14.366669654846, 0, 380, 470) --599 is the vehicle's hands. Put any vehicle you want
        warpPedIntoVehicle(source, vehicle[source])
        playerMarker = createMarker(313.41094970703, -1394.2287597656, 13.993467330933, "cylinder", 4, 255, 0, 0, 0)
        addEventHandler("onMarkerHit", playerMarker, handlePlayerMarker)
end)

function handlePlayerMarker(hitElement)
    local elementType = getElementType(hitElement)
    destroyElement(source)--you should source
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...