Jump to content
Sign in to follow this  
Holden93

How can I change an object's name via script?

Recommended Posts

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

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
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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×