OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: jphilapy on 23 Dec 2005, 02:17:24

Title: Disable ammo in chooper via script?
Post by: jphilapy on 23 Dec 2005, 02:17:24
Hi,

I'm creating a chopper in game. I need to know how to create it without any ammo at all.

Thanks,
Jeff
Title: Re:Disable ammo in chooper via script?
Post by: Raptorsaurus on 23 Dec 2005, 08:20:58
Code: [Select]
{helo removeMagazine _x} forEach (magazines helo)Where helo is it name of the chopper who's ammo you want removed.

If you want to add back the ammo at a latter time then try this:
Code: [Select]
helo_mags = magazines helo
{helo removeMagazine _x} forEach helo_mags
then later to put the magazines back:
Code: [Select]
{helo addMagazine _x} forEach helo_mags
Title: Re:Disable ammo in chooper via script?
Post by: jphilapy on 23 Dec 2005, 21:19:50
Hi, When I use the code, I get invalid # in expression. Any idea why?

Thanks,
Jeff
Title: Re:Disable ammo in chooper via script?
Post by: Planck on 23 Dec 2005, 21:50:59
Did you name your chopper as helo or did you give it another name?

If you gave it another name just replace helo with the name you used.

Also, it would be better to quote the error message you get.   ;)


Planck
Title: Re:Disable ammo in chooper via script?
Post by: Terox on 23 Dec 2005, 22:39:15

in the init field of the air unit place
removeallweapons this

or in a script use
removeallweapons heloname

will remove both weapons and ammo, if thats what you are after, that way a chopper cant rearm at a reammo truck either
Title: Re:Disable ammo in chooper via script?
Post by: jphilapy on 23 Dec 2005, 23:10:46
Sorry the error message I get is "invalid # in expression"

or maybe "invalid number in expression".

I replaced the word helo with the word chopper1 because when I create a chopper in the mission, that is the name i give it. I am creating the chopper within the ini field of the player.

Thanks,
Jeff

Did you name your chopper as helo or did you give it another name?

If you gave it another name just replace helo with the name you used.

Also, it would be better to quote the error message you get.   ;)


Planck
Title: Re:Disable ammo in chooper via script?
Post by: jphilapy on 23 Dec 2005, 23:12:40
hi,


I tried your advice and it works for the mission. However I still like to understand the other way that is prescribed to me. As I dont want to be limited to doing only in editor things.

Thanks,
Jeff


in the init field of the air unit place
removeallweapons this

or in a script use
removeallweapons heloname

will remove both weapons and ammo, if thats what you are after, that way a chopper cant rearm at a reammo truck either
Title: Re:Disable ammo in chooper via script?
Post by: jphilapy on 23 Dec 2005, 23:38:11
Hi, quick correction. What you gave me works on 1.96. I am trying to implement code that works on 1.46. Sorry I should have stated that in the first post.

What I did so far on 1.46 is:

chopper1 removeMagazine "Rocket57x192"; Thanks for the previous post that helped me to discover this.

That works, but the foreach throws an error as I stated earlier.

Jeff


in the init field of the air unit place
removeallweapons this

or in a script use
removeallweapons heloname

will remove both weapons and ammo, if thats what you are after, that way a chopper cant rearm at a reammo truck either