Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Take away fuel

  1. #1
    Just wondering how I can remove a certain amount of fuel from a large list of vehicles. Since there is no 'getFuel' command so I can't get the amount of fuel and then remove say 0.30 fuel so just wondering are there any other ways of doing this?

    Or am I just missing something really obvious which is most likely since I have not done much scripting for ArmA in a long time so I'm a tad rusty.

  2. #2
    Well you might get the value from the 'dialog' that shows the
    amount (top left). Not sure though.




  3. #3
    http://community.bistudio.com/wiki/fuel

    that checks how much fuel a unit has.

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    unitname setfuel &#40;&#40;fuel unitname&#41; -0.3&#41;[/QUOTE]

    for a list I&#39;d use the foreach command, but not sure if you can make it check each individual fuel level via a trigger, unless you did it via a script

    trigger covering all units you want, activation anyone:
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    {&#91;_x&#93; exec &#34;fuelscript.sqs&#34;} foreach units &#40;list this&#41;[/QUOTE]

    and then the script could be:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    _unit = _this select 0

    _currentfuel = fuel _ unit

    _unit setfuel &#40;_currentfuel -0.3&#41;

    exit[/QUOTE]

    [edit]

    Forgot to say this is untested and off the top of my head, and yes, sqf is better, but I haven&#39;t a clue how all that works, so sqs it is.




  4. #4
    Sergeant Major
    Join Date
    Dec 21 2004
    Posts
    1,907
    Author of the Thread
    Thanks a lot Messiah works perfectly.

    Edit - Just wondering is it possible to do the same thing but with ammo? Like just set enemy in a trigger area to %50 ammo?




  5. #5
    Glad to hear it worked. It means the editing brain isn&#39;t totally rusty just yet. Just to mention that you can also add a side check into the script if you only wanted it to hapen to a certain side, for instance, or a class check if you only wanted it for cars, tanks, aircraft, etc. Also, if this is for MP, the script would be executed on all clients, which means that its likely the unit would end up with 0 fuel once all the clients had run the script. I&#39;m at work at present, but I have a Client/Server check bit of code back home, that I can insert into the script.

    Its certainly possible for ammo, but I have a feeling it wouldn&#39;t be quite as simple. You would have to check what weapon the unit was carrying, what ammo that weapon used and how much of that ammo he was carrying, and then remove that ammunition. Unless of course there&#39;s a command in ArmA that acts like the ammunition slider in the unit edit screen, and can set things to 0.5 etc - I&#39;m not totally sure.

    I&#39;ll have a think about it and come back later with something (hopefully) - In the mean time perhaps someone quicker/better may have a solution.

  6. #6
    Sergeant Major
    Join Date
    Dec 21 2004
    Posts
    1,907
    Author of the Thread
    Ahh yeah the script is for MP, so will I just need to add
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? &#33;&#40;local server&#41; &#58; exit[/QUOTE]
    To the front of the script to make it run just on the server?

  7. #7
    yes, you&#39;ll need to add that, lest all the fuel be gone.

  8. #8
    the ammo one is a little out of my experience, but I&#39;ve been thinking it over a little:

    I&#39;d say you&#39;d obviously want to use the magazines command to check the ammo the units are carrying. So, same as before, trigger, set to detect enemy, and then the same activation code but of course a new script name.

    There probably a better was of doing this, but I&#39;m not sure how to get the script to take 50% ammo, round it to the nearest whole number, and take away... so:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    ? &#33;&#40;local server&#41; &#58; exit
    _unit = _this select 0
    _mags = &#40;magazines _unit&#41;
    _count == 3
    _loopcount == 0
    _mag1 = &#40;_mags select 0&#41;
    _mag2 = &#40;_mags select 1&#41;
    _mag3 = &#40;_mags select 2&#41;
    _mag4 = &#40;_mags select 3&#41;

    _unit removemagazines _mag1
    _unit removemagazines _mag2
    _unit removemagazines _mag3
    _unit removemagazines _mag4

    #loop
    ?_loopcount = _count &#58; exit
    _unit addmagazine _mag1
    _unit addmagazine _mag2
    _unit addmagazine _mag3
    _unit addmagazine _mag4
    _loopcount == &#40;_loopcount + 1&#41;
    goto &#34;loop&#34;
    [/QUOTE]

    there&#39;s definitly a better way to do it, but my scripting is simple and direct, rather than clever and correct . Essentially the script checks the mags the unit has, and this returns an array. I&#39;ve assumed that any given unit is at max going to have 4 different magazines on him at any given time - if this is wrong, then you just need to add more mag selections in the script. The script then removes all these magazines and then adds a set number back again (as defined by _count). Not exactly 50%, but a similiar end result.

    again, hopefully someone who knows what they&#39;re doing and provide a better example.

  9. #9
    Staff Sergeant
    Join Date
    Jan 25 2002
    Location
    Manchester, GB
    Posts
    348
    Quote Originally Posted by (456820 @ Aug. 06 2008,18:52)
    Ahh yeah the script is for MP, so will I just need to add
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? &#33;&#40;local server&#41; &#58; exit
    To the front of the script to make it run just on the server?[/QUOTE]
    If you using arma v1.08 + (may even be lower) you can use the IsServer command instead of the local command.

    Cheers
    GC

  10. #10
    Warrant Officer ck-claw's Avatar
    Join Date
    Oct 29 2005
    Location
    On The End Of A Bottle Of Cider-Somerset - UK
    Posts
    2,241
    Quote Originally Posted by (Messiah @ Aug. 05 2008,16:35)
    http://community.bistudio.com/wiki/fuel



    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    unitname setfuel &#40;&#40;fuel unitname&#41; -0.3&#41;
    [/QUOTE]
    Thanks ,that works a treat for me in the &#39;On Act&#39; a trigger to make a Landie run outta fuel when it hits the trigger&#33;
    Changing the -0.3 to -10.0


    How Ppl Treat Me Is Their Path, How I Respond Is Mine...

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •