Jump to content
swillis12931

Respawn Unit with Name Script

Recommended Posts

Hi guys, I am working on a dynamic mission involving helicopters. I want to be able to have a script where it will rearm your co-pilot if alive, or respawn him if dead. I've messed around with trying to make a script for this but so far no luck. Would greatly appreciate it if you guys could take a look at what I have so far and give me some pointers. Thanks! 

 

Quote

#Start
HINT "GEARING UP"
~2

removeAllWeapons Pilot1; Pilot1 addMagazine "GlockMag"; Pilot1 addMagazine "GlockMag"; Pilot1 addMagazine "GlockMag"; Pilot1 addWeapon "Glock"; Pilot1 addWeapon "NVGoggles"; Pilot1 selectWeapon "Glock"

? (alive Pilot2):goto "PilotAlive"

deleteVehicle Pilot2
"SoldierWPilot" createUnit [getMarkerPos "PositionPilot2",Pilot1,"Pilot2=this",1,"LIEUTENANT"]et
Pilot2 setBehaviour "safe"
doStop Pilot2


#PilotAlive
removeAllWeapons Pilot2
Pilot2 addMagazine "GlockMag"; Pilot2 addMagazine "GlockMag"; Pilot2 addWeapon "Glock"; Pilot2 addWeapon "NVGoggles"
Pilot2 setBehaviour "safe"; Pilot2 selectWeapon "Glock"
Pilot2
[Pilot2] join Pilot1
doStop Pilot2


#End
HINT "CREW READY"
~2

HINT ""

Exit

 

Share this post


Link to post
Share on other sites

"SoldierWPilot" createUnit [getMarkerPos "PositionPilot2" , group Pilot1 , "Pilot2=this", 1 ,"LIEUTENANT"]

 

Unit will respawn if Pilot1 is still alive. if there is a possibility that Pilot1 might die then try "Pilot_Group = group Pilot1" at the very start an then try 

 

"SoldierWPilot" createUnit [getMarkerPos "PositionPilot2" , Pilot_Group , "Pilot2=this", 1 ,"LIEUTENANT"]

 

and delete "et" after your createunit line

Share this post


Link to post
Share on other sites

Hi Prototype 1479,

 

Thank you for your help. It's saying that the "Pilot2=this" is a reserved variable? Any ideas what this means? 

  • Like 1

Share this post


Link to post
Share on other sites

The third thing in createunit array is for initialization (or init for short you may find this when you are creating units on the mission editor)

 

"this" is referring to the unit that your creating so if you put "Pilot2 = this" on the unit you are creating then Pilot2 is referring to the unit that you are creating its the easiest way to put a unit inside a variable in OFP while using createUnit command

Share this post


Link to post
Share on other sites

Ahh...I figured it out. I was able to finally get the script to work. However, it seems that I can't already have a pilot named "Pilot2" in the mission for the script to work. 

I'm now trying to create a new vehicle if the original is destroyed. I think I can't have the vehicle already loaded in the mission, but this will make it hard for everything else to work... 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×