acat0970 10 Posted November 6, 2013 i am trying to make a towing script for my missions and i want to make it so a certain vehicle cant tow any vehicle. here is what I've got: car1 distance _vehicle < 5; _vehicle attachTo car1 [0,-1,2]; removeAction 11; the vehicle i want to attach things to is car1. _vehicle is meant to be any vehicle but i know i am wrong. if any on could help i would appreciate it. Thanks!!! :) Share this post Link to post Share on other sites
Waffle_SS 11 Posted November 11, 2013 If you want it to only tow cars: while {alive car1} do { if ((car1 distance _vehicle) < 5) then { if (_vehicle isKindOf "Car") then { _vehicle attachTo [car1,[0,-1,2]]; removeAction 11; hint "car attached"; }; }; }; Share this post Link to post Share on other sites
galzohar 31 Posted November 11, 2013 Well obviously you will need to tell the script what _vehicle is. It can't read your mind and decide which vehicle you want to tow. How to decide which vehicle to attach is up to you. There are many scripting commands that can help you and the ones you should use depend on what you actually want to happen in the mission... For example you could use an addAction to add an action menu entry that will run the script and nearObjects to filter for cars within a certain radius of the towing vehicle. But that's just 1 way to do it out of many. Share this post Link to post Share on other sites
Beldum 3 Posted November 15, 2013 (edited) Put this in Vehicle init - this addaction["Tow Vehicle","TowScript.sqf"]; Create a script called TowScript.sqf to execute Put the below script in it _Towtruck= _this select 0;_vehicle = nearestObjects [_Towtruck, ["Car"], 5];//Returns an array of all vehicles in "Car" within 5m _vehicle = _vehicle select 0;//Selects the first car (Closest one) if ((_Towtruck distance _vehicle) < 5) then {//Double check the distance if (_vehicle isKindOf "Car") then {//Double check that it's in "Car" array _vehicle attachTo [_Towtruck,[0,-1,2]];//Attach it hint "car attached"; }; }; I haven't tested it but it should work. Let me know if it doesn't Edited November 15, 2013 by nick103 Share this post Link to post Share on other sites
acat0970 10 Posted November 26, 2013 thanks every one Share this post Link to post Share on other sites