Firespider Posted August 6, 2022 Share Posted August 6, 2022 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
#\_oskar_/# Posted August 6, 2022 Share Posted August 6, 2022 playerMarker = {} function handlePlayerMarker(hitElement) if getElementType(hitElement) == "player" then if isElement(playerMarker[hitElement]) then destroyElement(playerMarker[hitElement]) end end end Link to comment
Shady1 Posted August 9, 2022 Share Posted August 9, 2022 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
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