kewiiNNN Posted February 14, 2015 Posted February 14, 2015 I maked vehicle creator with a marker but i want to fix something: 1.You can't spawn any vehicle's while driving. 2.When you created the new one the old one is destroyed local cars = { {429}, {402}, {541}, {415}, {480}, {562}, {587}, {565}, {411}, {559}, {603}, {560}, {506}, {451}, {558}, {555}, {477} } carmarker = createMarker( -2670.2495117188,632.93334960938,13.5, "cylinder", 1.5, 0, 0, 255, 210, root ) function carmarkerhit(hitElement) if (isElement(hitElement) and getElementType(hitElement) == "player") then randomcar = math.random(#cars) carid = cars[randomcar][1] car = createVehicle(carid, -2674.5383300781,630.00115966797,13.862801551819, 0, 0, 90) warpPedIntoVehicle(hitElement,car) setTimer(function() destroyElement(car) end, 120000, 1) end end addEventHandler("onMarkerHit", carmarker, carmarkerhit)
Castillo Posted February 14, 2015 Posted February 14, 2015 To check if the player is currently in a vehicle, use isPedInVehicle, and to destroy the previously spawned vehicle, you would need to create a table and store the vehicles there.
LaCosTa Posted February 14, 2015 Posted February 14, 2015 try this local cars = { {429}, {402}, {541}, {415}, {480}, {562}, {587}, {565}, {411}, {559}, {603}, {560}, {506}, {451}, {558}, {555}, {477} } carmarker = createMarker( -2670.2495117188,632.93334960938,13.5, "cylinder", 1.5, 0, 0, 255, 210, root ) createBlipAttachedTo(carmarker,25) theVehicle = {} function carmarkerhit(hitElement) if isElement(theVehicle[hitElement]) then return destroyElement(theVehicle[hitElement]) end if getElementType(hitElement) == "player" and not isPedInVehicle(hitElement) then randomcar = math.random(#cars) carid = cars[randomcar][1] theVehicle[hitElement] = createVehicle(carid, -2674.5383300781,630.00115966797,13.862801551819, 0, 0, 90) warpPedIntoVehicle(hitElement,theVehicle[hitElement]) end end addEventHandler("onMarkerHit", carmarker, carmarkerhit)
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