GregRUS 10 Posted October 7, 2010 (edited) Hello everyone! I have a problem in my script with "nearestobject" command; I used -showscripterrors and got: '...cts [getpos player, ["LandVehicle"], 5] |#|select 1);_vcl1 distance _vcl2 <=10 and...' Error Whole string in script file is: _player addaction["Attach Vehicle","attact.sqf",["attach", "var1", 2,"tow"],1,false,true,"",'_vcl1 = (nearestobjects [getpos player, ["LandVehicle"], 5] select 0);_vcl2 = (nearestobjects [getpos player, ["LandVehicle"], 5] select 1);_vcl1 distance _vcl2 <= 10 and (((typeof _vcl1 in towarray and !(typeof _vcl2 in towarray)) or !((typeof _vcl1 in towarray) and typeof _vcl2 in towarray))) and (player == vehicle player)']; Actually it works anyway but I dont want to leave any errors in my scripts. Hope the answer will be simple xD UPD: Of course there was no vehicles nearby. Also tried to put that string before: if (isnil (nearestobjects [getpos player, ["LandVehicle"], 5] select 1))exitwith {}; ... didnt helped ;( Edited October 7, 2010 by GregRUS UPD Share this post Link to post Share on other sites
HeliJunkie 10 Posted October 7, 2010 Hi GregRus! Are you shure, you want the 2nd vehicle you search for ? You use "select 1". This is the second one. To select the first one, you need "select 0". I think you want to leave, if there is no second vehicle in the list. So try the "count" statement: if ( count (nearestobjects [getpos player, ["LandVehicle"], 5]) < 1) exitwith {}; If you want to leave, if there is NO vehicle found: if ( count (nearestobjects [getpos player, ["LandVehicle"], 5]) = 0) exitwith {}; Hope this will help you. Share this post Link to post Share on other sites
GregRUS 10 Posted October 7, 2010 Hi GregRus!Are you shure, you want the 2nd vehicle you search for ? You use "select 1". This is the second one. To select the first one, you need "select 0". I think you want to leave, if there is no second vehicle in the list. So try the "count" statement: if ( count (nearestobjects [getpos player, ["LandVehicle"], 5]) < 1) exitwith {}; If you want to leave, if there is NO vehicle found: if ( count (nearestobjects [getpos player, ["LandVehicle"], 5]) = 0) exitwith {}; Hope this will help you. Thank you very much!! It helped! Share this post Link to post Share on other sites