Jump to content
Sign in to follow this  
wld427

SetFuel?, Set Ammo?

Recommended Posts

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

Didn't look very hard in Biki if you missed this! biggrin_o.gif

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

// 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

(_x

should i put the name of the magazine here?

Share this post


Link to post
Share on other sites

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

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

{_x addEventHandler[""lowfuel"",{(_this select 0) setfuel 1}];

would this work?

Share this post


Link to post
Share on other sites

Why would you need to place the init line into that script? confused_o.gif 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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×