Jump to content

[HELP]Vehicle respawn


rafull6

Recommended Posts

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 

Link to comment

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.

Link to comment
No, he want it to spawn at creation position.

You're right! :D

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 :D. Looks very easy :D :

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) 

Link to comment
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.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...