Jump to content

Vehicle Creator


kewiiNNN

Recommended Posts

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) 
  

Link to comment

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) 

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