rafull6 Posted June 18, 2011 Posted June 18, 2011 Hey, guys! Probably you think that it is another one topic with a stupid question "how to respawn vehicle after it blew up" but i created this topic because i didn't find answer for the next question: How to respawn vehicle at the source point (point where it was created)? All the community resources respawn a car at the same place where it was destroyed, but i need something another. For example: Car was created near LS department. Someone took it and destroyed in other part of the city. After 5 seconds it respawned at the same place near LS department. How to make it? P.S. For vehicle creation we can use this (for example): ewvehicle = createVehicle ( 400, 1452.7392578125, -1747.4951171875, 13.29686832428 ) vehicle
JR10 Posted June 18, 2011 Posted June 18, 2011 respawnVehicle(ewvehicle) respawn vehicle will spawn it in the creation position
rafull6 Posted June 18, 2011 Author Posted June 18, 2011 respawnVehicle(ewvehicle) respawn vehicle will spawn it in the creation position Respawn at the position where it was destroyed... =( Can you post whole code, please
JR10 Posted June 18, 2011 Posted June 18, 2011 Ok, then are you using a map file or... any way do this bool setVehicleRespawnPosition ( vehicle theVehicle, float x, float y, float z, [float rx, float ry, float rz ] ) use it onresourcestart and set the respawn position to the creation position.
AGENT_STEELMEAT Posted June 18, 2011 Posted June 18, 2011 Simple: addEventHandler("onVehicleExplode", root, function() local vx, vy, vz, vrx, vry, vrz = getElementPosition(source), getElementRotation(source); spawnVehicle(vx, vy, vz, vrx, vry, vrz); end)
rafull6 Posted June 19, 2011 Author Posted June 19, 2011 No, he want it to spawn at creation position. You're right! JR10 if you can, post whole scipt please (it's shouldn't be large), because i tried a lot and get fail. Please, i need your help ---------------------------------------------------------------------- ADDED: Made such scrip successfully . Looks very easy : local vehicle = createVehicle ( 400, 1452.6813964844, -1747.5430908203, 13.29686832428 ) -- create us a new vehicle function respawnExplodedVehicle() setTimer(respawnVehicle, 5000, 1, source) end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle)
JR10 Posted June 19, 2011 Posted June 19, 2011 addEventHandler('onResourceStart', resourceRoot, function() for i, v in ipairs(getElementsByType('vehicle')) do local x, y, z = getElementPosition(v) local rx, ry, rz = getElementRotation(v) setVehicleRespawnPosition ( v, x, y, z, rx, ry, rz) end end ) addEventHandler('onVehicleExplode', root, function() setTimer(respawnVehicle, 3000, 1, source)--3000 is 3 seconds you can increase it end ) This will respawn the vehicle after 3 seconds of explode.
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