rikjuuh 10 Posted June 27, 2011 I've used the search option but I can't find anything, so I'm sorry if there is already a thread like this. so here's my question: is there a script or something to force a vehicle (Warrior) to stop moving on dirt? and if it doesn't stay on the road his tracks will be damaged? Share this post Link to post Share on other sites
le_culto 0 Posted June 27, 2011 (edited) Made this a little time ago, if the driver is too far from the road for more than 10 seconds, one wheel is damaged: /* * Function to test if a vehicle is near the road or not */ is_near_road = { private ["_veh","_ret","_rad"]; _veh = _this select 0; _rad = 100; if ((count _this) > 1) then {_rad = _this select 1}; _ret = false; if (_veh != vehicle _veh) then { _veh = vehicle _veh; }; if (isOnRoad getPos _veh) then { _ret = true; } else { if ( (count (_veh nearRoads _rad)) > 0 ) then { _ret = true; }; }; _ret; }; while {alive player} do { if (player != vehicle player) then { if ( (player == driver vehicle player) && ! ([vehicle player] call is_near_road) ) then { _debut = time; hintSilent "Rapproche toi de la route !"; while { (player != vehicle player) && ! ([vehicle player] call is_near_road) } do { _temps = time - _debut; if ( _temps >= 10 ) then { (vehicle player) setHit ["wheel_1_1_steering", 1]; }; sleep 1; }; }; sleep 1; } else { sleep 5; }; }; Edited June 27, 2011 by Le_CuLtO Share this post Link to post Share on other sites
rikjuuh 10 Posted June 27, 2011 (edited) okay thank you very much! ---------- Post added at 04:37 PM ---------- Previous post was at 04:36 PM ---------- guess just create for excample damageifnotonroad.sqf and add execVM "damageifnotonroad.sqf"; to the init.sqf right? and what do I need to place in the name of the Warrior? Edited June 27, 2011 by rikjuuh Share this post Link to post Share on other sites
kylania 546 Posted June 27, 2011 Pretty sure that script is just included in the init.sqf file. It'll check for any vehicle the player is in. Share this post Link to post Share on other sites
rikjuuh 10 Posted June 28, 2011 (edited) ok thanks, does it also check for fighter jets and a chinook? because I've got 1 AV-98 (or something like that) and a chinook in the mission and I'd like to know if it get damaged if it isn't near a road Edited June 28, 2011 by rikjuuh Share this post Link to post Share on other sites
le_culto 0 Posted June 28, 2011 (edited) You're right, it doesn't check if the vehicle is an airplane or a chopper. Replace the "is_near_road" function by this one, it should work (not tested): /* * Function to test if a vehicle is near the road or not */ is_near_road = { private ["_veh","_ret","_rad","_type"]; _veh = _this select 0; _rad = 100; if ((count _this) > 1) then {_rad = _this select 1}; _ret = false; if (_veh != vehicle _veh) then { _veh = vehicle _veh; }; _type = getText (configFile >> "CfgVehicles" >> (typeOf _veh) >> "vehicleClass"); if (_type == "Air") then { if (isOnRoad getPos _veh) then { _ret = true; } else { if ( (count (_veh nearRoads _rad)) > 0 ) then { _ret = true; }; }; }; _ret; }; Edited June 28, 2011 by Le_CuLtO Share this post Link to post Share on other sites
rikjuuh 10 Posted June 28, 2011 okay, thank you very much! Share this post Link to post Share on other sites
le_culto 0 Posted June 28, 2011 oups made a mistake :p: /* * Function to test if a vehicle is near the road or not */ is_near_road = { private ["_veh","_ret","_rad","_type"]; _veh = _this select 0; _rad = 100; if ((count _this) > 1) then {_rad = _this select 1}; _ret = false; if (_veh != vehicle _veh) then { _veh = vehicle _veh; }; _type = getText (configFile >> "CfgVehicles" >> (typeOf _veh) >> "vehicleClass"); if (_type != "Air") then { if (isOnRoad getPos _veh) then { _ret = true; } else { if ( (count (_veh nearRoads _rad)) > 0 ) then { _ret = true; }; }; }; _ret; }; Share this post Link to post Share on other sites
rikjuuh 10 Posted June 28, 2011 so this is the good one then? ;) Share this post Link to post Share on other sites