kewiiNNN Posted February 10, 2015 Posted February 10, 2015 how to make a marker and when you go in the marker it will spawn you any random cars in fast cars in f1 create section? and when the vehicle its empty it will be destroyed like vanish in 2 min
BlueTheFurry Posted February 10, 2015 Posted February 10, 2015 Create the marker, a Table with the cars, start an timer when it was created example table: local cars = { {411}, {410}, {412} }
kewiiNNN Posted February 10, 2015 Author Posted February 10, 2015 can you paste me the whole example cause i dont know anything about scripting ?
BlueTheFurry Posted February 10, 2015 Posted February 10, 2015 local cars = { {411}, {410}, {412} } carmarker = createMarker( x,y,z, "cylinder", 2, 255, 255, 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, x,y,z ) warpPedintoVehicle( hitElement ) setTimer( function() destroyElement( car ) end, 120000, 1 end end addEventHandler("onMarkerHit", carmarker, carmarkerhit ) didnt test if it works, you also have to replace the coordinates to your's
kewiiNNN Posted February 10, 2015 Author Posted February 10, 2015 i just replaced coordinates and it will work?
BlueTheFurry Posted February 10, 2015 Posted February 10, 2015 you need to replace carmarker = createMarker( x,y,z, "cylinder", 2, 255, 255, 255, 210, root ) from x,y,z to your coordinates and also car = createVehicle( carid, x,y,z ) x,y,z to the coordinates where the car should spawn
Ryancit2 Posted February 10, 2015 Posted February 10, 2015 Fixed @BlueTheFurry's code: local cars = { {411}, {410}, {412} } carmarker = createMarker( x,y,z, "cylinder", 2, 255, 255, 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, x,y,z) warpPedintoVehicle(hitElement) setTimer(function() destroyElement(car) end, 120000, 1) end end addEventHandler("onMarkerHit", carmarker, carmarkerhit)
kewiiNNN Posted February 10, 2015 Author Posted February 10, 2015 ERROR: MarkerCarspawn\login.lua:14: attempt to call global ' warpPedintoVehicle' (a nil value) now it wont warp in the car:s
Tomas Posted February 10, 2015 Posted February 10, 2015 local cars = { {411}, {410}, {412} } carmarker = createMarker( x,y,z, "cylinder", 2, 255, 255, 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, x,y,z) warpPedIntoVehicle(hitElement,car) setTimer(function() destroyElement(car) end, 120000, 1) end end addEventHandler("onMarkerHit", carmarker, carmarkerhit)
novo Posted February 10, 2015 Posted February 10, 2015 That's because i is lowercase and it's supposed to be upper (warpPedIntoVehicle), as Lua is not case-sensitive.
kewiiNNN Posted February 10, 2015 Author Posted February 10, 2015 all working but is there a way to add so while you driving you cant spawn a new vehicle? only while walking local cars = { {429}, {402}, {541}, {415}, {480}, {562}, {587}, {565}, {411}, {559}, {603}, {560}, {506}, {451}, {558}, {555}, {477} } carmarker = createMarker( -1316.7326660156,-29.210359573364,13.2, "cylinder", 2, 255, 0, 0, 210, root ) function carmarkerhit(hitElement) if (isElement(hitElement) and getElementType(hitElement) == "player") then randomcar = math.random(#cars) carid = cars[randomcar][1] car = createVehicle(carid, -1329.3344726563,-37.078189849854,14.1484375) warpPedIntoVehicle(hitElement,car) setTimer(function() destroyElement(car) end, 120000, 1) end end addEventHandler("onMarkerHit", carmarker, carmarkerhit)
Ryancit2 Posted February 10, 2015 Posted February 10, 2015 Add this before or after Line#25: if (isPedInVehicle(hitElement)) then return end
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