huyjvguyen Posted August 1, 2015 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
huyjvguyen Posted August 1, 2015 Author 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?
#Madara Posted August 1, 2015 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 )
huyjvguyen Posted August 1, 2015 Author 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
#Madara Posted August 1, 2015 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)
GTX Posted August 1, 2015 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 )
huyjvguyen Posted August 2, 2015 Author 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 ??
GTX Posted August 2, 2015 Posted August 2, 2015 Put your coordinates. EDIT: Marker = createMarker(x, y, z, "cylinder", 4.0, 255, 0, 0, 255)
huyjvguyen Posted August 3, 2015 Author Posted August 3, 2015 yep i was, the marker created but not spawm vehiel ??
huyjvguyen Posted August 3, 2015 Author 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
huyjvguyen Posted August 3, 2015 Author Posted August 3, 2015 Works. Tested. well, i was tried. it's not spawm any car,can you give me this full file.?
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