blackberry Posted June 7, 2011 Share Posted June 7, 2011 I made a function that respawn cars when they explode (For My Freeroam server) Its simple, when the car explodes, it respawn one at the same place where it exploded. But What I really want is to respawn car at their original spawn when they move (hit or drive) or are damaged Here is my function: function respawnVehicle( vehicle ) spawnVehicle ( vehicle, getElementData( vehicle, "posX" ), getElementData( vehicle, "posY" ), getElementData( vehicle, "posZ" ), getElementData( vehicle, "rotX" ), getElementData( vehicle, "rotY" ), getElementData( vehicle, "rotZ" ) ) end function onVehicleSpawn () local x,y,z = getElementPosition (source) setElementData (source,"posX",x) setElementData (source,"posY",y) setElementData (source,"posZ",z) end addEventHandler ("onVehicleExplode",getRootElement(),onVehicleSpawn) function onVehicleExplode () setTimer( respawnVehicle, 5000, 1, source ) end addEventHandler("onVehicleExplode", getRootElement(), onVehicleExplode) Thanks Link to comment
Jaysds1 Posted June 7, 2011 Share Posted June 7, 2011 Do you have the car original place? Link to comment
blackberry Posted June 8, 2011 Author Share Posted June 8, 2011 Yes I have, but I have more than 30 spawn.... Please Someone , help me!!!!! Link to comment
Castillo Posted June 8, 2011 Share Posted June 8, 2011 addEventHandler("onVehicleExplode", getRootElement(), function () setTimer(respawnVehicle, 5000, 1, source) end) This should respawn the vehicle when it explodes after 5 seconds. Link to comment
diegofkda Posted June 8, 2011 Share Posted June 8, 2011 I'll recreate your script, it's too easy: function getElementsOnExplode() model = getElementModel ( source ) x, y, z, rx, ry, rz = getElementPosition ( source ) driver = getVehicleOccupant ( source ) driverskin = getElementModel ( driver ) setTimer ( spawnPlayerAfterExplode, 1000, 1 ) end addEventHandler("onVehicleExplode", getRootElement(), getElementsOnExplode) function spawnPlayerAfterExplode() spawnPlayer ( driver, 0, 0, 0 ) setElementModel ( driver, driverskin ) newvehicle = createVehicle ( model, x, y, z, rx, ry, rz ) warpPedIntoVehicle ( driver, newvehicle ) end Not tested, but that must work Link to comment
Castillo Posted June 8, 2011 Share Posted June 8, 2011 If i'm right, what he want's is to respawn a VEHICLE but a PLAYER, let's wait and see. Link to comment
blackberry Posted June 8, 2011 Author Share Posted June 8, 2011 I will try tonight, So this n may respawn at the Original spawn right? And what about respawn if vehicle is left for mmore than 2 minutes ? Set respawn delay right? Link to comment
Dark Dragon Posted June 8, 2011 Share Posted June 8, 2011 i'm pretty sure respawnVehicle respawns the vehicle at the given spawn point, at least if you created it within a map file. Link to comment
blackberry Posted June 8, 2011 Author Share Posted June 8, 2011 What you mean with Mapfile? I see all car respawn in th .map files, but I made spawn with map editor as usual. 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