Holden93 12 Posted May 15, 2014 Hello, I'm working on a script that respawns a vehicle once it is destroyed but there is a problem, here's the code _vehicle = HUNTER_1; _respawnPos = "marker"; _vehicleType = typeOf _vehicle; waitUntil{!alive _vehicle}; hint "Mobile vehicle has been destroyed!"; sleep 5; deleteVehicle _vehicle; sleep 15; hint "Mobile vehicle got repaired!"; _vehicle = _vehicleType createVehicle (getMarkerPos _respawnPos); _vehicle execVM "vehicleRespawn.sqf"; When the code gets executed again, the _vehicle variable stores HUNTER_1, the problem is that when HUNTER_1 gets destroyed it does not exist anymore and the code will always spawn vehicles. How can I change the new spawned vehicle's name? Thanks. Share this post Link to post Share on other sites
pellejones 1 Posted May 15, 2014 change: _vehicle = HUNTER_1; to: _vehicle = _this select 0; change: _vehicle execVM "vehicleRespawn.sqf"; to: [_vehicle] execVM "vehicleRespawn.sqf"; and the run the script on the init of the vehicle like so: nu = [this] exec VM "vehicleRespawn. sqf"; Share this post Link to post Share on other sites
Holden93 12 Posted May 15, 2014 change: _vehicle = HUNTER_1; to: _vehicle = _this select 0; change: _vehicle execVM "vehicleRespawn.sqf"; to: [_vehicle] execVM "vehicleRespawn.sqf"; and the run the script on the init of the vehicle like so: nu = [this] exec VM "vehicleRespawn. sqf"; Thanks so much! Share this post Link to post Share on other sites