Jump to content
Sign in to follow this  
Lordmann

deleteVehicle issue

Recommended Posts

I want to add an addAction in my vehicle init, so when I click it the vehicle gets deleted. I want a single script for every car, without need to name the vehicle (if possible)

The problem is that I don't know how arrays exactly work, so what should I put in the bold part (code below)

hint "Deleting vehicle...";

sleep 5;

deletevehicle this;

hint "Vehicle deleted";

exit;

I tried with "this" referring to the vehicle where I'm executing the script, but it doesn't work. Any idea?

Thank you!

Edited by Lordmann

Share this post


Link to post
Share on other sites

Oh shit, I didn't remember to say that I want a single script to be used for every vehicle. So when I put the addAction in another unnamed vehicle, it will work.

OP EDITED

Share this post


Link to post
Share on other sites

this addAction [("<t color=#66FF33'>" + ("Delete Vehicle") + "</t>"),"deleteVehicle.sqf];

deleteVehicle.sqf

_host = _this select 0;
_id = _this select 2;

_host removeAction _id;

deleteVehicle _host;
hintSilent "Your vehicle has been deleted";

Share this post


Link to post
Share on other sites
this addAction [("<t color=#66FF33'>" + ("Delete Vehicle") + "</t>"),"deleteVehicle.sqf];

deleteVehicle.sqf

_host = _this select 0;
_id = _this select 2;

_host removeAction _id;

deleteVehicle _host;
hintSilent "Your vehicle has been deleted";

Could you please explain a little bit how does it work? Thank you anyways!

Share this post


Link to post
Share on other sites
Could you please explain a little bit how does it work? Thank you anyways!

Well, that involves two commands. Obviously, addAction is being used to execute the script. The _this select X you see in the first 2 lines are the defining of variables as passed arguments. Click the addAction hyperlink for info on that. Then, removeAction is being used to delete the action from the player (instead of just hiding it, it also wipes the ID (this is clean)) by using previously defined variables from the passed arguments. Then, deleteVehicle is used to delete the vehicle, specifically the one that the addAction was placed on (_host, in this case). I encourage you to look into all of those commands.

Share this post


Link to post
Share on other sites
Could you please explain a little bit how does it work? Thank you anyways!

_host is the truck or vehicle

_caller that wasnt in this script because it wasnt needed would be the person calling the action

_id is the action ID

I would recommend going to the wiki and looking for addaction and removeaction.

You can rename _host, _caller, _id to whatever you want.

---------- Post added at 05:50 ---------- Previous post was at 05:41 ----------

Here is another example for you:

_host = _this select 0;
_caller = _this select 1;
_id = _this select 2;

_host removeAction _id;

deleteVehicle _host;
hintSilent format ["%1 your vehicle has been deleted", name _caller];

Share this post


Link to post
Share on other sites

Ok thank you Grimes [3rd ID] and cobra4v320 for your response.

Now I have another 2 problems, is any way of placing code into a respawned vehicle init?

I am trying to place a vehicle far away from me with a script, a simple setPosATL, so the vehicle is far from me enough to respawn. I noticed that I need to "update" the vehicle, either mounting or driving it so the vehicle can respawn. If I just execute the script, the vehicle will go to the selected position but stay there even if I set the respawn to execute when the vehicle is 100m away from a player or left for 60 seconds. If I drive it and then execute the script, it'll work but just once, when the vehicle is respawned the action won't be avaliable.

I found out that placing code into the respawned vehicle init could be a possible solution, yet I don't know how to do it.

Any solution for these 2 problems?

Thank you!

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  

×