ADuke 1 Posted December 28, 2009 OK guys, I searched for how to do this and found some handy bits of sqf script to use but am having trouble with this script I am writing, this is my first time writing a script from scratch so please excuse any obvious mistakes I am making. I just want my script to monitor the vehicle that I am executing it on, and when the vehicle is empty (crew == 0). Then I want the vehicle to be destroyed. Here is my script.... if (!isServer) exitWith {}; _vehicle = _this select 0; _run = true; while {_run} do { if (count crew _vehicle == 0) then {_vehicle setDamage 1}; and here is how I execute it on the vehicle... nul = [this] execVM "destroy.sqf" I appreciate any help you could give me. -AD Share this post Link to post Share on other sites
Przemek_kondor 14 Posted December 28, 2009 if (!isServer) exitWith {}; _vehicle = _this select 0; _run = true; while {_run} do { if ((count (crew _vehicle)) == 0) then { _vehicle setDamage 1; _run = false; }; }; Share this post Link to post Share on other sites
ADuke 1 Posted December 28, 2009 if (!isServer) exitWith {}; _vehicle = _this select 0; _run = true; while {_run} do { if ((count (crew _vehicle)) == 0) then { _vehicle setDamage 1; _run = false; }; }; Awesome, worked perfectly, thanks a lot :) Share this post Link to post Share on other sites
Przemek_kondor 14 Posted December 28, 2009 Oh, it's recommended to add some sleeping in "while" loop, because currently it checks several times per second what is unnecesary heavy. Better: if (!isServer) exitWith {}; _vehicle = _this select 0; _run = true; while {_run} do { if ((count (crew _vehicle)) == 0) then { _vehicle setDamage 1; _run = false; }; sleep 1; }; Share this post Link to post Share on other sites
ADuke 1 Posted December 29, 2009 Thank you for that sleep suggestion, cuts down on the resources. How might I add an or statement in this script so that it also executes when either the driver or gunner are dead? Thanks, -AD Share this post Link to post Share on other sites
Przemek_kondor 14 Posted December 29, 2009 use those commands: http://community.bistudio.com/wiki/or http://community.bistudio.com/wiki/alive http://community.bistudio.com/wiki/gunner http://community.bistudio.com/wiki/driver and parenthesis in "if" statement Share this post Link to post Share on other sites