Home   Help Search Login Register  

Author Topic: Help with Rearming Units  (Read 1233 times)

0 Members and 1 Guest are viewing this topic.

Offline Papa Pro

  • Members
  • *
Help with Rearming Units
« 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
« Last Edit: 08 Aug 2008, 19:58:17 by bedges »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Help with Rearming Units
« Reply #1 on: 07 Aug 2008, 18:58:58 »
How about a one-liner of code that will replace each rpg round as it is fired?
urp!

Offline Papa Pro

  • Members
  • *
Re: Help with Rearming Units
« Reply #2 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
« Last Edit: 08 Aug 2008, 19:58:26 by bedges »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Help with Rearming Units
« Reply #3 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" }}]
urp!

Offline Papa Pro

  • Members
  • *
Re: Help with Rearming Units
« Reply #4 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
« Last Edit: 08 Aug 2008, 19:58:34 by bedges »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Help with Rearming Units
« Reply #5 on: 08 Aug 2008, 20:06:13 »
First of all, welcome to OFPEC!

Secondly, please give the forum guidelines 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.

Offline Papa Pro

  • Members
  • *
Re: Help with Rearming Units
« Reply #6 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