Home   Help Search Login Register  

Author Topic: How can i rearm a chopper via SCRIPTING?[Maybe SOLVED]  (Read 1815 times)

0 Members and 1 Guest are viewing this topic.

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
I have a large scale battle mission (check forum)
I have made an air strike but i don't know how to rearm the chopper via SCRIPTING method......

How can i rearm the chopper every three minutes so that it doesn't run out of ammo? ???

Haroon1992...............
« Last Edit: 02 Aug 2009, 12:58:21 by haroon1992 »
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: How can i rearm a chopper via SCRIPTING?
« Reply #1 on: 30 Jul 2009, 18:43:54 »
You need a script like this one here:

Code: [Select]
_chopper = _this select 0

#Status

?NOT (SomeAmmo _chopper): goto "Rearm"

goto "Status"

#Rearm


_chopper addmagazine "HellfireLauncherCobra"
_chopper addmagazine "ZuniLauncher38"


goto "status"

exit

This script is called from the init line of the chopper:

Code: [Select]
[this] exec "rearm.sqs"
However, i dont know a command that can restore a vehicle's ammo without adding the weapons manually. Which is quite difficult as i dont know the different types of weapons  :confused:

If only there was a command like 'setvehicleammo'  :(

(Ive tried SetAmmoCargo but nothing happens  :no: )

Hope this helps

Gruntage
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: How can i rearm a chopper via SCRIPTING?
« Reply #2 on: 31 Jul 2009, 14:29:01 »
At least this adds some ammo to my chopper....
Thanks...... ;)
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re: How can i rearm a chopper via SCRIPTING?
« Reply #3 on: 31 Jul 2009, 22:50:44 »
Here is a more general script that will work on any vehicle with any ammo type. The script must be run before the unit runs out of ammo so that it "knows" the magazine types before they are expended.
Code: [Select]
;reload.sqs by Raptorsaurus

_craft = _this select 0
_mags = magazines _craft

#start
@ (! (someAmmo _craft) || ! alive _craft
? ! alive _craft : exit
{_craft removeMagazine _x} forEach _mags
{_craft addMagazine _x} forEach _mags

? alive _craft : goto "start"
exit

To run the script just use: [this] exec "reload.sqs" in the init field of the vehicle that you want to have perpetual ammo. This will work for soldiers also.
« Last Edit: 31 Jul 2009, 22:55:14 by Raptorsaurus »

Walter_E_Kurtz

  • Guest
Re: How can i rearm a chopper via SCRIPTING?
« Reply #4 on: 01 Aug 2009, 02:58:39 »
I think using the someAmmo command will prove more trouble than it's worth, because it only becomes not true when the vehicle is out of all possible magazines. In other words, your chopper may use up its rockets but, as long as it can fire its gun, it won't rearm.

Use the majority of Raptosaurus' script, but, as you originally wanted, have it looping every three minutes:
Code: (reload.sqs) [Select]
_craft = _this select 0
_mags = magazines _craft

#start
? ! alive _craft : exit
{_craft removeMagazine _x} forEach _mags
{_craft addMagazine _x} forEach _mags

~180
goto "start"

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: How can i rearm a chopper via SCRIPTING?
« Reply #5 on: 01 Aug 2009, 15:05:37 »
Thanks you very much for the help (both of you) :clap:

I have been confused that i can't find the ammo class for FFAR missiles.....
With this ,i think it will work ,thanks....everyone
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: How can i rearm a chopper via SCRIPTING?
« Reply #6 on: 01 Aug 2009, 15:40:26 »
Here.


Planck
I know a little about a lot, and a lot about a little.

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: How can i rearm a chopper via SCRIPTING?
« Reply #7 on: 01 Aug 2009, 15:47:35 »
Can you tell me which one is the FFAR.....? ???
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Walter_E_Kurtz

  • Guest
Re: How can i rearm a chopper via SCRIPTING?
« Reply #8 on: 01 Aug 2009, 16:07:13 »
ZuniLauncher38

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: How can i rearm a chopper via SCRIPTING?
« Reply #9 on: 01 Aug 2009, 16:13:20 »
Thanks Walter.................................................................. :D
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(