OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Papa Pro on 05 Aug 2008, 21:14:21

Title: Help with Rearming Units
Post by: Papa Pro on 05 Aug 2008, 21:14:21
Dear all,

I am totally lost after trying, searching and reading on this forum for an aswer to rearming my units and I just can't do it.  I tried Chris OFP editor and the ReamEast Script to no avail.  I just don't understand it.  I even e-mailed Chris but I am sure the guy has enough to do.  So I am asking here if anyone can help.

I used Chris's OFP editor to make this script for my 11 units (P1 to P11 use this same script)

Code: [Select]
; ** ORIGINAL FILE NAME: RGP.sqs
; ** INSTRUCTIONS: Run script from the INITIALIZATION box of the unit
; ** RUN CODE: [this] Exec "RGP.sqs"
; ***********************************************************************

; Get the unit parameter given
_unit = _this Select 0

; Strip the units current gear
RemoveAllWeapons _unit

; Add the new gear to the unit
_unit AddMagazine "RPGLauncher"
_unit AddMagazine "RPGLauncher"
_unit AddMagazine "RPGLauncher"
_unit AddMagazine "RPGLauncher"
_unit AddMagazine "RPGLauncher"
_unit AddWeapon "RPGLauncher"
_unit AddMagazine "SkorpionMag"
_unit AddMagazine "SkorpionMag"
_unit AddMagazine "SkorpionMag"
_unit AddMagazine "SkorpionMag"
_unit AddWeapon "Skorpion"
_unit AddWeapon "Binocular"

Exit
What I really want is to use this same script but add each player to rearm with RGP ammo automaticly when they run out of ammo.  This is for a SP game I am making  Any help would be fantastic but I have tried Chris OFP Editor and even that is to complecated for me.  So please go easy with me.

Cheers,

Richard
Title: Re: Help with Rearming Units
Post by: Mr.Peanut on 07 Aug 2008, 18:58:58
How about a one-liner of code that will replace each rpg round as it is fired?
Title: Re: Help with Rearming Units
Post by: Papa Pro on 08 Aug 2008, 12:10:49
Yes please! How do I do that? Could you PLEASE write down the code so I can copy it?

Any help apreciated.

Cheers,

Richard
Title: Re: Help with Rearming Units
Post by: Mr.Peanut on 08 Aug 2008, 14:06:05
Try this first. Add the following to the init field of the unit.
Code: [Select]
this addeventhandler ["fired",{if ((_this select 4)=="RPGLauncher") then {(_this select 0) addmagazine "RPGLauncher" }}]
Title: Re: Help with Rearming Units
Post by: Papa Pro on 08 Aug 2008, 19:40:03
Thanks sooo much for helping but it did not work  :( In put the code into the init for the unit but no joy.  I use an RPG soldier.  He run out of ammo very quicky.  Should I have made an SQS file first?

Any other ideas would be fantsastic.

Cheers,

Rich
Title: Re: Help with Rearming Units
Post by: bedges on 08 Aug 2008, 20:06:13
First of all, welcome to OFPEC!

Secondly, please give the forum guidelines (http://www.ofpec.com/index.php?action=read_on&id=122) a read.

Thirdly, the code should actually be

Code: [Select]
this addeventhandler ["fired",{if ((_this select 4)=="RPG") then {(_this select 0) addmagazine "RPGLauncher" }}]
Tested and works fine.
Title: Re: Help with Rearming Units
Post by: Papa Pro on 09 Aug 2008, 01:37:07
Thank you sooo much! Really happy as it worked!

I will read the rules over the weekend.  So sorry but I don't have time right now (00:30am London).  But I did a quick check and it worked.  My men were a bit lazy but hell.  I'm not complaining.

Take care,

RIchard