huyjvguyen Posted August 1, 2015 Share Posted August 1, 2015 script to add a pulic vehicle when player hit marker and when player out car, the car will be auto delete in 10s. help me Link to comment
GTX Posted August 1, 2015 Share Posted August 1, 2015 setTimer -- Events "onVehicleExit" "onMarkerHit" Link to comment
huyjvguyen Posted August 1, 2015 Author Share Posted August 1, 2015 setTimer -- Events "onVehicleExit" "onMarkerHit" Marker {} Marker[1] = createMaker (x,y,x,"vehicle",255 , 0, 0) Veh {} function spawmvehicle(thePlayer) local px,py,pz = getPlayerPosition(thePlayer) Veh = createVehicle(id, px, py, pz) end addEventHandler("onMarkerHit", Marker, spawmvehicle) addEventHandler("onVehicleExit", Veh, function() destroyElement(veh(thePlayer)) end) It is right? Link to comment
#Madara Posted August 1, 2015 Share Posted August 1, 2015 Try This : Marker {} local Marker[1] = createMarker (x,y,x,"cylinder",255,0, 0,255) Veh {} function spawmvehicle(thePlayer) if isElement(Veh[thePlayer]) then return end local px,py,pz = getElementPosition(thePlayer) Veh[thePlayer] = createVehicle(id, px, py, pz) end addEventHandler("onMarkerHit", Marker[1], spawmvehicle) addEventHandler("onVehicleExit",root, function() if ( source == Veh[thePlayer] ) then setTimer(destroyElement,10000,1,Veh[thePlayer]) end end ) Link to comment
huyjvguyen Posted August 1, 2015 Author Share Posted August 1, 2015 Try This : Marker {} local Marker[1] = createMarker (x,y,x,"cylinder",255,0, 0,255) Veh {} function spawmvehicle(thePlayer) if isElement(Veh[thePlayer]) then return end local px,py,pz = getElementPosition(thePlayer) Veh[thePlayer] = createVehicle(id, px, py, pz) end addEventHandler("onMarkerHit", Marker[1], spawmvehicle) addEventHandler("onVehicleExit",root, function() if ( source == Veh[thePlayer] ) then setTimer(destroyElement,10000,1,Veh[thePlayer]) end end ) it's not work, marker not created Link to comment
#Madara Posted August 1, 2015 Share Posted August 1, 2015 Try This : Marker {} local Marker[1] = createMarker (x,y,x,"cylinder",255,0, 0,255) Veh {} function spawmvehicle(thePlayer) if isElement(Veh[thePlayer]) then return end local px,py,pz = getElementPosition(thePlayer) Veh[thePlayer] = createVehicle(id, px, py, pz) end addEventHandler("onMarkerHit", Marker[1], spawmvehicle) addEventHandler("onVehicleExit",root, function() if ( source == Veh[thePlayer] ) then setTimer(destroyElement,10000,1,Veh[thePlayer]) end end ) it's not work, marker not created you put position x,y,z ? in local Marker[1] = createMarker (x,y,x,"cylinder",255,0, 0,255) Link to comment
GTX Posted August 1, 2015 Share Posted August 1, 2015 Marker = createMarker (x,y,z,"cylinder",255,0, 0,255) Veh = {} function spawmvehicle(thePlayer) if getElementType(thePlayer) ~= "player" then return end if isElement(Veh[thePlayer]) then return end local px,py,pz = getElementPosition(thePlayer) Veh[thePlayer] = createVehicle(id, px, py, pz) end addEventHandler("onMarkerHit", Marker, spawmvehicle) addEventHandler("onVehicleExit",root, function() if ( source == Veh[source] ) then setTimer(destroyElement,10000,1,Veh[source]) end end ) Link to comment
huyjvguyen Posted August 2, 2015 Author Share Posted August 2, 2015 Marker = createMarker (x,y,z,"cylinder",255,0, 0,255) Veh = {} function spawmvehicle(thePlayer) if getElementType(thePlayer) ~= "player" then return end if isElement(Veh[thePlayer]) then return end local px,py,pz = getElementPosition(thePlayer) Veh[thePlayer] = createVehicle(id, px, py, pz) end addEventHandler("onMarkerHit", Marker, spawmvehicle) addEventHandler("onVehicleExit",root, function() if ( source == Veh[source] ) then setTimer(destroyElement,10000,1,Veh[source]) end end ) the marker is not created ?? Link to comment
GTX Posted August 2, 2015 Share Posted August 2, 2015 Put your coordinates. EDIT: Marker = createMarker(x, y, z, "cylinder", 4.0, 255, 0, 0, 255) Link to comment
huyjvguyen Posted August 3, 2015 Author Share Posted August 3, 2015 yep i was, the marker created but not spawm vehiel ?? Link to comment
huyjvguyen Posted August 3, 2015 Author Share Posted August 3, 2015 yes. it't not spawm Link to comment
huyjvguyen Posted August 3, 2015 Author Share Posted August 3, 2015 Works. Tested. Marker = createMarker ( 1693.478515625, 1447.8671875, 10,"cylinder",0.5,255,0, 0,255) Veh = {} function spawmvehicle(thePlayer) if getElementType(thePlayer) ~= "player" then return end if isElement(Veh[thePlayer]) then return end local px,py,pz = getElementPosition(thePlayer) Veh[thePlayer] = createVehicle(533, px, py, pz ) end addEventHandler("onMarkerHit", Marker, spawmvehicle) addEventHandler("onVehicleExit",root, function() if ( source == Veh[source] ) then setTimer(destroyElement,10000,1,Veh[source]) end end ) this, it's not spawm any vehicle Link to comment
GTX Posted August 3, 2015 Share Posted August 3, 2015 It does. I tested it. Put it server side. Link to comment
huyjvguyen Posted August 3, 2015 Author Share Posted August 3, 2015 Works. Tested. well, i was tried. it's not spawm any car,can you give me this full file.? 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