wld427 1705 Posted February 21, 2008 am using this script to protect a Ah-1Z that orbits my FOB. The problem is after a while the chopper runs out of fuel and crashes into my base blowing everything up but the chopper. Is there anyway to "setfuel" or "set ammo" init="this addeventhandler [""dammaged"",{(_this select 0) setdamage 0}]; this addeventhandler [""hit"",{(_this select 0) setdamage 0}];{_x addEventHandler[""dammaged"",{(_this select 0) setdamage 0}];_x addEventHandler[""hit"",{(_this select 0) setdamage 0}];} forEach (crew this)"; Share this post Link to post Share on other sites
charliereddog 9 Posted February 21, 2008 Didn't look very hard in Biki if you missed this! Biki Setfuel Just have a script which loops through every 5 minutes or so to save resources. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">choppername setfuel 1 The ammo I believe can be dealt with in the same script with addmagazine but I haven't ever done rearming vehicles. Share this post Link to post Share on other sites
Pulverizer 1 Posted February 21, 2008 // this execVM "chopper.sqf"; _v=_this; _mags=magazines _v; while{true}do{ {if(not(_x in magazines _v))then{_v addmagazine _x;};}foreach _mags; _v setfuel 1; sleep(10); }; Share this post Link to post Share on other sites
wld427 1705 Posted February 22, 2008 (_x should i put the name of the magazine here? Share this post Link to post Share on other sites
Pulverizer 1 Posted February 22, 2008 Nope. Just save it as it is into the mission folder. It reads the vehicle's magazine types in the beginning and stores them to _mags. _x is a special variable inside the forEach's scope that is the current element of the array which is its parameter. There's one mistake though, you need to add something to catch the script handle when you use execVM from an init line or you get a syntax error. Change that to like: foo=this execVM "chopper.sqf"; Share this post Link to post Share on other sites
wld427 1705 Posted February 22, 2008 ok now how would i place the init line code i wrote into this scrip without disturbing the loop to refuel every 5 minutes. Share this post Link to post Share on other sites
wld427 1705 Posted February 23, 2008 {_x addEventHandler[""lowfuel"",{(_this select 0) setfuel 1}]; would this work? Share this post Link to post Share on other sites
Squint 0 Posted February 29, 2008 Why would you need to place the init line into that script? Leave it in the mission.sqm and you should be fine. Also, there is no "lowFuel" event handler in ArmA; that's why folks are telling you to make a loop. I'm not sure how vehicle magazines work, but Pulverizer's code will definitely keep a flying chopper fueled. Share this post Link to post Share on other sites