Jump to content
Sign in to follow this  
r71

Respawn unit name

Recommended Posts

I used this script---

;;BEGIN vrs.sqs

;;By KaRRiLLioN

;;VehicleType Loop by Sefe

;;Original script by Backoff

;;Updated for 1.75 by Jaeger Neo

;;IMPORTANT: ADD A GAMELOGIC NAMED Server

;;to the mission to prevent multispawn

?!(local Server): Goto "end"

_vcl = _this select 0

_respawndelay = 10

_dir=Getdir _vcl

_position=Getpos _vcl

_Vehicles=[]

_WTrucks=["Truck5tOpen","Truck5tRepair","Truck5tReammo","Truck5t

Refuel","Truck5t"]

_ETrucks=["UralRepair","UralReammo","UralReFuel","Ural"]

_CivTrucks=["TruckV3SGCivil","TruckV3SGRefuel","TruckV3SGRepair","

TruckV3SGReammo","Bus","TruckV3SG"]

_Jeeps=["JeepMG","GJeep","HMMWV","UAZ","SGUAZG"

,"UAZG","JeepPolice","Jeep"]

_Cars=["Tractor","Rapid","RapidY","Skoda","SkodaBlu

e","SkodaRed","SkodaGreen","Trabant","Jawa"]

_Helos=["Cobra","AH64","CH47D","OH58","UH60MG",

"UH60","Kamov","Mi24","Mi17"]

_Planes=["Cessna","A10LGB","A10","SU25"]

_WArmor=["M1Abrams","M60","Bradley","M113Ambul","Vulc

an","M2StaticMGE","M2StaticMG","M113","BoatW"

]

_GArmor=["T80Res","T72Res"]

_EArmor=["T80","T72","BMP2","BMPAmbul","BMP",&am

p;am

p;qu

ot;BRDM","BoatE","ZSU","T55G"]

_Other=["Mash"]

_Vehicles=_WTrucks+_ETrucks+_CivTrucks+_Jeeps+_Cars+_Helos+_Planes+_WArmor+_GArmor+_EArmor+_Other

_i = 0

#Loop

? (_i > (Count _Vehicles)) : Goto "Skip"

_VehicleType = _Vehicles Select _i

_VehicleTypeDoesMatch = ((_VehicleType CountType _this) == 1)

? _VehicleTypeDoesMatch : _type = _VehicleType

? _VehicleTypeDoesMatch : Goto "Skip"

_i = _i + 1

Goto "Loop"

#start

~2

@!(Canmove _vcl)

~_respawndelay

deleteVehicle _vcl

_vcl = _type createVehicle _position

_vcl setdir _dir

#Skip

?(_type=="cessna"):goto "cessna"

?(_type=="Mi17"):goto "Mi17"

Goto "start"

#Mi17

_vcl removemagazines "Rocket57x192"

_vcl removeweapon "Rocket57x192"

_vcl addweapon "MachineGun30"

_vcl addmagazine "MachineGun30"

goto "start"

#cessna

_vcl addmagazine "MachineGun30"

_vcl addweapon "MachineGun30"

_vcl addmagazine "MachineGun30"

_vcl addweapon "MachineGun30"

goto "start"

#end

Exit

;;END vrs.sqs

The problem I have is that when the unit comes back it does not keep its name. I use triggers to add a unit recall so you dont have to walk far to get your car or plane if you die.

the trigger I use needs to have a name for the unit. p3spawn=true <-- this is what I use in the activation field of the trigger. The other triggers would take care of the spawn and the location. So when you die you spawn back at your base. If you wanted your car back you would just walk in a tent I had set up and it would trigger the spawn for that car. I dont know much about this stuff so if anyone knows a better way.........  biggrin.gif

maybe there is a way to set the name in the script so I can still use the triggers, or how to keep the info I put in the name and init. line of the unit?

Share this post


Link to post
Share on other sites

Well one way to do it is if each vehicle that is being respawned is unique.  In other words, is there more than one of each type of vehicle?

If not, then you can reassign the variable name to a vehicle.

For example, let's say that you have a JeepMG named Jeep.  In the respawn script you would add this line:

....

#start

?(_type=="JeepMG"):Jeep=_vcl

~2

@!(Canmove _vcl)

~_respawndelay

.....

Basically since this is the only JeepMG in the mission, then you can filter out that one jeep with the respawn script and give it a GLobalVariable name so that it could be picked upon by a trigger.

Now here's a more complicated way to do it if you have several vehicles of the same type:

First of all, assign a name to each vehicle that you want to respawn.

Now assign the soldier that you'll be controlling a name like W1

For an example, create a JeepMG and name it WJeep.

Now in the init field put [this]exec "vrs.sqs".

Create your Radio triggers or whatever you use to move a vehicle, change it to activate Repeatedly, and put in the onActivation field:

WJeep1 Setpos Getpos W1

Here's the script and I'll bold what I changed:

;;BEGIN vrs.sqs

;;By KaRRiLLioN

;;VehicleType Loop by Sefe

;;Original script by Backoff

;;Updated for 1.75 by Jaeger Neo

;;IMPORTANT: ADD A GAMELOGIC NAMED Server

;;to the mission to prevent multispawn

?!(local Server): Goto "end"

_vcl = _this select 0

_respawndelay = 10

_dir=Getdir _vcl

_position=Getpos _vcl

_Vehicles=[]

?(_vcl==WJeep):WJeep1=_vcl; _oldvcl=WJeep1; PublicVariable "WJeep1"

;;First this checks to see if the GlobalVariable name of the

;;_vcl is WJeep.  Since we cannot re-use that var name

;;any more, we must give it a new GlobalVariable name and

;;then make it public so that all clients will have the same

;;info if it's a multiplayer game.

;;Then I assign a new GlobalVariable (GV) name and set it =

;;to _vcl.  I then create a new LocalVariable (LV) and set it

;;= to the new GV name.  I do this because _vcl will change

;;once it hits the CreateVehicle phase of this script.

_WTrucks=["Truck5tOpen","Truck5tRepair","Truck5tReammo","Truck5t

Refuel","Truck5t"]

_ETrucks=["UralRepair","UralReammo","UralReFuel","Ural"]

_CivTrucks=["TruckV3SGCivil","TruckV3SGRefuel","TruckV3SGRepair","

TruckV3SGReammo","Bus","TruckV3SG"]

_Jeeps=["JeepMG","GJeep","HMMWV","UAZ","SGUAZG"

,"UAZG","JeepPolice","Jeep"]

_Cars=["Tractor","Rapid","RapidY","Skoda","SkodaBlu

e","SkodaRed","SkodaGreen","Trabant","Jawa"]

_Helos=["Cobra","AH64","CH47D","OH58","UH60MG",

"UH60","Kamov","Mi24","Mi17"]

_Planes=["Cessna","A10LGB","A10","SU25"]

_WArmor=["M1Abrams","M60","Bradley","M113Ambul","Vulc

an","M2StaticMGE","M2StaticMG","M113","BoatW"

]

_GArmor=["T80Res","T72Res"]

_EArmor=["T80","T72","BMP2","BMPAmbul","BMP",&am

p;qu

ot;BRDM","BoatE","ZSU","T55G"]

_Other=["Mash"]

_Vehicles=_WTrucks+_ETrucks+_CivTrucks+_Jeeps+_Cars+_Helos+_Planes+_WArmor+_GArmor+_EArmor+_Other

_i = 0

#Loop

? (_i > (Count _Vehicles)) : Goto "Skip"

_VehicleType = _Vehicles Select _i

_VehicleTypeDoesMatch = ((_VehicleType CountType _this) == 1)

? _VehicleTypeDoesMatch : _type = _VehicleType

? _VehicleTypeDoesMatch : Goto "Skip"

_i = _i + 1

Goto "Loop"

#start

~2

@!(Canmove _vcl)

~_respawndelay

deleteVehicle _vcl

_vcl = _type createVehicle _position

_vcl setdir _dir

?(_oldvcl==WJeep1):WJeep1=_vcl; _oldvcl=WJeep1; PublicVariable "WJeep1"

;;Here the _oldvcl LV is used to determine the old GV name of

;;the _vcl.  When _vcl is used to CreateVehicle, then it

;;changes to a different object.  Therefore I use the _oldvcl

;;LV to keep that value.  Now the new _vcl has the GV name

;;of WJeep1.  Again I make it a PublicVariable (PV) so that

;;all clients will have the same object info.

#Skip

?(_type=="cessna"):goto "cessna"

?(_type=="Mi17"):goto "Mi17"

Goto "start"

#Mi17

_vcl removemagazines "Rocket57x192"

_vcl removeweapon "Rocket57x192"

_vcl addweapon "MachineGun30"

_vcl addmagazine "MachineGun30"

goto "start"

#cessna

_vcl addmagazine "MachineGun30"

_vcl addweapon "MachineGun30"

_vcl addmagazine "MachineGun30"

_vcl addweapon "MachineGun30"

goto "start"

#end

Exit

;;END vrs.sqs

OK now assume you have several more vehicles that you want to add to this.  Give each one a unique name.  Let's assume that it goes something like this:

UAZ is EJeep1

Sports Car is Car1

AH-1 is WHelo1

Now, you'll need to have these lines in the 2 different places of the script:

This part goes in the first area of the script right after the part about the first jeep:

?(_vcl==EJeep1):EJeep1A=_vcl; _oldvcl=EJeep1A; PublicVariable "EJeep1A"

?(_vcl==Car1):Car1A=_vcl; _oldvcl=Car1A; PublicVariable "Car1A"

?(_vcl==WHelo1):WHelo1A=_vcl; _oldvcl=WHelo1A; PublicVariable "WHelo1A"

Again, let me clarify what each part of that does:

?(_vcl==EJeep1)--this part asks, "Is the Local Variable _vcl = to the GlobalVariable Ejeep1. Are they the same object?"

Car1A=_vcl; _oldvcl=Car1A--If the above is true, then Assign Car1A, (a new Global Var name) to be equal to the localVariable _vcl. Now make the local Var _oldvcl equal to the new GlobalVar Car1A

PublicVariable "Car1A"--This broadcasts that the global variable Car1A now exists and it is this particular object. Now all clients in a MP game will have that information and can use it if need be.

Now the following goes in the 2nd part of the script:

?(_oldvcl==EJeep1A):EJeep1A=_vcl; _oldvcl=EJeep1A; PublicVariable "EJeep1A"

?(_oldvcl==Car1A):Car1A=_vcl; _oldvcl=Car1A; PublicVariable "Car1A"

?(_oldvcl==WHelo1A):WHelo1A=_vcl; _oldvcl=WHelo1A; PublicVariable "WHelo1A"

?(_oldvcl==EJeep1A):--is the Local Var _oldvcl the same object as the object represented by the GlobalVariable EJeep1A?

EJeep1A=_vcl; _oldvcl=EJeep1A;--If so, then Reassign the local variable _vcl the same GobalVar name as before, and then do the same for _oldvcl. For some reason _oldvcl MUST be reassigned the same GlobalVar name again.

And of course for each vehicle you make, you'll have to make a corresponding method of moving them according to their GV name, i.e. radio trigger, etc. whatever you're using now.

I hope this helps.  There's probably an easier way of doing it, but I didn't have much time so I just whipped this up and tested it for a few mins and it seems to work ok.

You can name your vcls anything you want, and you can give the GV's any name you want, so long as it's unique and not like the one given in the mission editor.

Share this post


Link to post
Share on other sites

ty very much. I am looking over this now.

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
Sign in to follow this  

×