Home   Help Search Login Register  

Author Topic: Respawn with same weapons you had before dying using while "" do {} command  (Read 4538 times)

0 Members and 1 Guest are viewing this topic.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Not really a question, but a tip. I'm not sure if this is worthy of being a code snippet, or if someone hasnt allready submitted it, so I figured I'd post it here.

I'm not a programmer by any means, so when I first heard about the new functions of OFP scripting, I didn't get too excited. Yesterday, the value of the new scripting abilities in 1.85 became evident to me when I wanted to write a script that would, upon respawning, give a unit the same weapons that they had when they died.

Using the new - while "" do {} - ability in 1.85 makes this much easier than writing a loop.

Here is the code that will give the unit named "w1" his weapons back when he respawns.

Note that you have to make a script for each player in a MP game with the player's name in the script, or the script will not be able to detect when he respawns.[/u]


Code: [Select]
#respawnloop
@!alive w1
_guns = weapons w1
_guncount = count weapons w1
_mags = magazines w1
_magcount = count magazines w1
@alive w1
w1 removeWeapon "m16";w1 removeMagazines "m16";
_c = 0
while "_c <= (_magcount - 1)" do {w1 addmagazine (_mags select _c); _c = _c + 1}
_c = 0
while "_c <= (_guncount - 1)" do {w1 addweapon (_guns select _c); _c = _c + 1}
w1 selectweapon primaryweapon w1
goto "respawnloop"
exit
« Last Edit: 05 Nov 2002, 02:14:36 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Same code, but different
« Reply #1 on: 05 Nov 2002, 02:13:25 »
Here is the same piece of code, modified to give the player the same weapons he started the game with every time, instead of the weapons he died with. See the post above for how to use the code in MP games.

Code: [Select]
_guns = weapons w1
_guncount = count weapons w1
_mags = magazines w1
_magcount = count magazines w1

#respawnloop
@!alive w1
@alive w1
w1 removeWeapon "m16";w1 removeMagazines "m16";
_c = 0
while "_c <= (_magcount - 1)" do {w1 addmagazine (_mags select _c); _c = _c + 1}
_c = 0
while "_c <= (_guncount - 1)" do {w1 addweapon (_guns select _c); _c = _c + 1}
w1 selectweapon primaryweapon w1
goto "respawnloop"
exit
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Frosty Slamander

  • Guest
This would be great exept for 2 things.

1. I really don't know how to exec this and if i just do this exec "a1.sqs" he doesn't have any weapons at the start!


2. I was using this for a WW2 level with the WW2 teams stuff and they respawn with a AK74 or M16!


Frosty Salamander

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
You have to run the script in Each players init field, and change w1 to the players name....

You might have to put a little delay (~0.1) in the start of the script for the second script it to pick up his weapons at the start.

For example, if your soldier is named "soldier1" you would put:
[] exec "thisscript.sqs" in his init field and change "w1" in the script to "soldier1".

Hope that helps.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Or you could do it this way toadlife:
in the init.sqs:

Code: [Select]
~1
_guns = weapons player
_guncount = count weapons player
_mags = magazines player
_magcount = count magazines player

#respawnloop
@!alive player
@alive player
Removeallweapons player
_c = 0
while "_c <= (_magcount - 1)" do {player addmagazine (_mags select _c); _c = _c + 1}
_c = 0
while "_c <= (_guncount - 1)" do {player addweapon (_guns select _c); _c = _c + 1}
player selectweapon primaryweapon player
goto "respawnloop"
exit

I put a one-second delay in there. Usually, I use init.sqs to launch a cutscene that runs while I do some MP housekeeping (negotiating viewdistance and such).  This is one of those tasks that could be done during that time.
Dinger/Cfit

Mike

  • Guest
wouldn't this work better than making a million scripts:

Code: [Select]
;rearm.sqs

_player = _this select 0

~1
_guns = weapons _player
_guncount = count weapons _player
_mags = magazines _player
_magcount = count magazines _player

#respawnloop
@!alive _player
@alive _player
Removeallweapons _player
_c = 0
while "_c <= (_magcount - 1)" do {_player addmagazine (_mags select _c); _c = _c + 1}
_c = 0
while "_c <= (_guncount - 1)" do {_player addweapon (_guns select _c); _c = _c + 1}
_player selectweapon primaryweapon _player
goto "respawnloop"
exit


then exec for each player like...:   [unitname] exec "rearm.sqs" ? ? atleast it would work for every unit on one side?...
« Last Edit: 05 Nov 2002, 21:51:58 by Mike »

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
wouldn't this work better than making a million scripts:

I wish, but it can't work that way. You really have to make one script for each player with the player's name explicitly defined in the script. :-[

When you say "_player = _this select 0" in the script, what "_player" refers to ceases to exist upon death. In MP, upon respawning, the player becomes a new object, the only things that are the same about the player after respawning are cosmetic, like player model, face, and name.

Once the initial object that "_player" stands for is gone, the script will just wait forever for the original object to come back alive.

That's why you have to declare the players name througout the script.

@Dinger

You're right, you could put it in the init.sqs, but then it would not work for AI units.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Mike

  • Guest
 :tomato: I tried ;D

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
I do this:

Place a solder, make them Playable, and name them USA1 or whatever.  They must have a name for reference.

Then make a Trigger that runs Repeatedly.  Set its Condition to be not alive USA1 and local USA1.  Then set it's OnDeactivation to be [USA1, "Steyr"] exec "weapons.sqs".

Put this weapons.sqs script in your mission directory:
(This only works with 1.85!!!!!!!!)

Quote
_obj = _this select 0
_type = _this select 1

goto _type

#Soldier
_mag = ["M16", "M16", "M16", "M16", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["M16"]
goto "exit"

#SoldierE
_mag = ["AK74", "AK74", "AK74", "AK74", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["AK74"]
goto "exit"

#G36
_mag = ["G36aMag", "G36aMag", "G36aMag", "G36aMag", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["G36a"]
goto "exit"

#Steyr
_mag = ["SteyrMag", "SteyrMag", "SteyrMag", "SteyrMag", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["Steyr"]
goto "exit"

#XMS
_mag = ["M4", "M4", "M4", "M4", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["XMS", "NVGoggles"]
goto "exit"

#AA
_mag = ["M16", "M16", "M16", "M16", "AALauncher"]
_weapon = ["M16", "AALauncher"]
goto "exit"

#EAA
_mag = ["AK74", "AK74", "AK74", "AK74", "9K32Launcher"]
_weapon = ["AK74", "9K32Launcher"]
goto "exit"

#AT
_mag = ["M16", "M16", "M16", "M16", "CarlGustavLauncher"]
_weapon = ["M16", "CarlGustavLauncher"]
goto "exit"

#EAT
_mag = ["AK74", "AK74", "AK74", "AK74", "AT4Launcher"]
_weapon = ["AK74", "AT4Launcher"]
goto "exit"

#SaboteurXMS
_mag = ["M4", "M4", "M4", "M4", "PipeBomb", "PipeBomb", "PipeBomb"]
_weapon = ["XMS", "Binocular"]
goto "exit"

#SaboteurHG
_mag = ["UZIMag", "UZIMag", "UZIMag", "UZIMag", "PipeBomb", "PipeBomb", "PipeBomb", "GlockMag", "GlockMag", "GlockMag", "GlockMag"]
_weapon = ["UZI", "NVGoggles", "Glock"]
goto "exit"

#SaboteurS
_mag = ["HK", "HK", "HK", "HK", "PipeBomb", "PipeBomb", "PipeBomb", "GlockSMag", "GlockSMag", "GlockSMag", "GlockSMag"]
_weapon = ["HK", "NVGoggles", "GlockS"]
goto "exit"

#ESaboteurBizon
_mag = ["BizonMag", "BizonMag", "BizonMag", "BizonMag", "PipeBomb", "PipeBomb", "PipeBomb"]
_weapon = ["Bizon", "NVGoggles"]
goto "exit"

#ESaboteurHG
_mag = ["AK74", "AK74", "AK74", "AK74", "PipeBomb", "PipeBomb", "PipeBomb", "SkorpionMag", "SkorpionMag", "SkorpionMag", "SkorpionMag"]
_weapon = ["AK74SU", "NVGoggles", "Skorpion"]
goto "exit"

#Crew
_mag = ["M4", "M4", "M4", "M4", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["M4", "NVGoggles"]
goto "exit"

#ECrew
#EPilot
_mag = ["AK74", "AK74", "AK74", "AK74", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["AK74SU", "NVGoggles"]
goto "exit"

#PilotHG
_mag = ["M4", "M4", "M4", "M4", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "RevolverMag", "RevolverMag", "RevolverMag", "RevolverMag"]
_weapon = ["M4", "NVGoggles", "Revolver"]
goto "exit"

#G
_mag = ["M16", "M16", "M16", "M16", "GrenadeLauncher", "GrenadeLauncher", "GrenadeLauncher"]
_weapon = ["M16GrenadeLauncher"]
goto "exit"

#EG
_mag = ["AK74", "AK74", "AK74", "AK74", "GrenadeLauncher", "GrenadeLauncher", "GrenadeLauncher"]
_weapon = ["AK74GrenadeLauncher"]
goto "exit"

#HeavyG
_mag = ["MM1Magazine", "SmokeShell", "SmokeShell"]
_weapon = ["MM1", "Binocular"]
goto "exit"

#EHeavyG
_mag = ["6G30Magazine", "6G30Magazine", "SmokeShell", "SmokeShell"]
_weapon = ["6G30", "Binocular"]
goto "exit"

#LAW
_mag = ["M16", "M16", "M16", "M16", "LAWLauncher", "LAWLauncher", "LAWLauncher"]
_weapon = ["M16", "LAWLauncher"]
goto "exit"

#ELAW
_mag = ["AK74", "AK74", "AK74", "AK74", "RPGLauncher", "RPGLauncher", "RPGLauncher"]
_weapon = ["AK74", "RPGLauncher"]
goto "exit"

#OfficerHG
_mag = ["M16", "M16", "M16", "M16", "BerettaMag", "BerettaMag", "BerettaMag", "BerettaMag", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "SmokeShell", "SmokeShell"]
_weapon = ["M16", "Binocular", "Beretta"]
goto "exit"

#OfficerEHG
_mag = ["AK74", "AK74", "AK74", "AK74", "TokarevMag", "TokarevMag", "TokarevMag", "TokarevMag", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "SmokeShell", "SmokeShell"]
_weapon = ["AK74", "Binocular", "Tokarev"]
goto "exit"

#Sniper
_mag = ["M21", "M21", "M21", "M21"]
_weapon = ["M21"]
goto "exit"

#ESniper
_mag = ["SVDDragunov", "SVDDragunov", "SVDDragunov", "SVDDragunov"]
_weapon = ["SVDDragunov"]
goto "exit"

#MG
_mag = ["M60", "M60", "M60", "M60", "M60"]
_weapon = ["M60"]
goto "exit"

#EMG
_mag = ["PK", "PK", "PK", "PK", "PK"]
_weapon = ["PK"]
goto "exit"

#Medic
_mag = ["M16", "M16", "M16", "M16"]
_weapon = ["M16"]
goto "exit"

#EMedic
_mag = ["AK74", "AK74", "AK74", "AK74"]
_weapon = ["AK74"]
goto "exit"

#Mortar
_mag = ["M16", "M16", "M16", "M16", "Mortar", "Mortar", "Mortar"]
_weapon = ["M16"]
goto "exit"

#exit
removeAllWeapons _obj
"_obj addMagazine _x" forEach _mag
"_obj addWeapon _x" forEach _weapon
_obj selectWeapon (_weapon select 0)

exit

Pick the appropriate #Label for each of your guys.  So with this script each player will need a name (USA1, RUS1, etc.) and each will need their own Trigger!!  This is as easy as it gets, I believe.  You don't have to have 20 scripts all running as loops, instead you just have 20 triggers. :P

Doolittle
« Last Edit: 06 Nov 2002, 23:17:11 by Doolittle »

Offline Sui

  • Former Staff
  • ****
    • OFPEC
...You don't have to have 20 scripts all running as loops, instead you just have 20 triggers. :P

Err... that's not necessarily any better...
Why have 20 triggers, when all you need is one?

Trigger

Radius: 0,0
Condition: none (repeatedly)
Condition Field: Alive player
OnActivation Field: [] exec "Rearm.sqs"

Rearm.sqs

? player in [w1,w4,w5,w8]: goto "WGrenadier"
? player in [e1,e4,e5,e8]: goto "EGrenadier"
? player in [w2,w6]: goto "WMGunner"
.... etc.

That way you need only one script (that only activates when the each individual player dies) and one trigger. It'll save you a lot of CPU time, the only draw back being you have to name all your players. (And it won't work with group respawn).

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Pick the appropriate #Label for each of your guys.  So with this script each player will need a name (USA1, RUS1, etc.) and each will need their own Trigger!!  This is as easy as it gets, I believe.  You don't have to have 20 scripts all running as loops, instead you just have 20 triggers. :P

Doolittle

Woah there cowboy! That's a hefty piece of code there! When you put down 20 triggers on a MP map, each player has to process every trigger, regarless of weather or not he will ever meet the condition. If you put a script on the init feild of each player, then each player only has to run his own script, and doesn't have to process the other  players' scripts.

The script I posted also allows for custom weapon loadouts (remember addon units!), not the just the standard soldier equipment.

"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline Sui

  • Former Staff
  • ****
    • OFPEC

If you put a script on the init feild of each player, then each player only has to run his own script, and doesn't have to process the other  players' scripts.

:hmm:

Actually, toadie... every client will be running all player scripts as you have it there. Just because the script is executed in the player's init field doesn't mean other clients won't be running it. However it could be that way :D

Throw in a line:

? player != w1: exit

in there and it will work just as you've said ;)

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Quote
Actually, toadie... every client will be running all player scripts as you have it there. Just because the script is executed in the player's init field doesn't mean other clients won't be running it. However it could be that way

I was, and still am under the impression that scripts that are executed in a unit's init field only execute on the machine that the unit is local to. I'm curious and will do a little test tonight just to make sure. If I'm wrong, then add that little line I will.

Your method of using one trigger would work great for human players, but I'm almost positive that it wouldn't work for AI units, because the server controls them and doesn't regard them as "players".

Not that people use AI that much in MP, but they do sometimes.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Sui, good point.  I was making a mission as I posted that and having to edit 20 triggers for all the players got to be annoying.  Here's a way to do it with NONE...

toadlife, yeah 20 triggers does suck and isn't clean/elegant.  Here's a script that does allow for custom weapon loadouts, addon units, whatever.  It is just one loop that is run by the server alone (???).  Two .sqs files are needed, one Game Logic unit to start the loop, and nameing of each soldier (and editing of serverloop.sqs for each soldier).  (I created this after last post above because of what you guys pointed out...thanks for the motivation.)

Pasted from http://www.flashpoint1985.com/cgi-bin/ikonboard301/ikonboard.cgi?s=3dca00b05181ffff;act=ST;f=7;t=22156;st=0

Here's some script I wrote.  It works with AI too.  You need these two files...

weapons.sqs
Quote
;Reload a soldier when they respawn
;by Doolittle

_obj = _this select 0
_type = _this select 1

goto _type

#Soldier
_mag = ["M16", "M16", "M16", "M16", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["M16"]
goto "exit"

#SoldierE
_mag = ["AK74", "AK74", "AK74", "AK74", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["AK74"]
goto "exit"

#G36
_mag = ["G36aMag", "G36aMag", "G36aMag", "G36aMag", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["G36a"]
goto "exit"

#Steyr
_mag = ["SteyrMag", "SteyrMag", "SteyrMag", "SteyrMag", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["Steyr"]
goto "exit"

#XMS
_mag = ["M4", "M4", "M4", "M4", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["XMS", "NVGoggles"]
goto "exit"

#AA
_mag = ["M16", "M16", "M16", "M16", "AALauncher"]
_weapon = ["M16", "AALauncher"]
goto "exit"

#EAA
_mag = ["AK74", "AK74", "AK74", "AK74", "9K32Launcher"]
_weapon = ["AK74", "9K32Launcher"]
goto "exit"

#AT
_mag = ["M16", "M16", "M16", "M16", "CarlGustavLauncher"]
_weapon = ["M16", "CarlGustavLauncher"]
goto "exit"

#EAT
_mag = ["AK74", "AK74", "AK74", "AK74", "AT4Launcher"]
_weapon = ["AK74", "AT4Launcher"]
goto "exit"

#SaboteurXMS
_mag = ["M4", "M4", "M4", "M4", "PipeBomb", "PipeBomb", "PipeBomb"]
_weapon = ["XMS", "Binocular"]
goto "exit"

#SaboteurHG
_mag = ["UZIMag", "UZIMag", "UZIMag", "UZIMag", "PipeBomb", "PipeBomb", "PipeBomb", "GlockMag", "GlockMag", "GlockMag", "GlockMag"]
_weapon = ["UZI", "NVGoggles", "Glock"]
goto "exit"

#SaboteurS
_mag = ["HK", "HK", "HK", "HK", "PipeBomb", "PipeBomb", "PipeBomb", "GlockSMag", "GlockSMag", "GlockSMag", "GlockSMag"]
_weapon = ["HK", "NVGoggles", "GlockS"]
goto "exit"

#ESaboteurBizon
_mag = ["BizonMag", "BizonMag", "BizonMag", "BizonMag", "PipeBomb", "PipeBomb", "PipeBomb"]
_weapon = ["Bizon", "NVGoggles"]
goto "exit"

#ESaboteurHG
_mag = ["AK74", "AK74", "AK74", "AK74", "PipeBomb", "PipeBomb", "PipeBomb", "SkorpionMag", "SkorpionMag", "SkorpionMag", "SkorpionMag"]
_weapon = ["AK74SU", "NVGoggles", "Skorpion"]
goto "exit"

#Crew
_mag = ["M4", "M4", "M4", "M4", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["M4", "NVGoggles"]
goto "exit"

#ECrew
#EPilot
_mag = ["AK74", "AK74", "AK74", "AK74", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade"]
_weapon = ["AK74SU", "NVGoggles"]
goto "exit"

#PilotHG
_mag = ["M4", "M4", "M4", "M4", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "RevolverMag", "RevolverMag", "RevolverMag", "RevolverMag"]
_weapon = ["M4", "NVGoggles", "Revolver"]
goto "exit"

#G
_mag = ["M16", "M16", "M16", "M16", "GrenadeLauncher", "GrenadeLauncher", "GrenadeLauncher"]
_weapon = ["M16GrenadeLauncher"]
goto "exit"

#EG
_mag = ["AK74", "AK74", "AK74", "AK74", "GrenadeLauncher", "GrenadeLauncher", "GrenadeLauncher"]
_weapon = ["AK74GrenadeLauncher"]
goto "exit"

#HeavyG
_mag = ["MM1Magazine", "SmokeShell", "SmokeShell"]
_weapon = ["MM1", "Binocular"]
goto "exit"

#EHeavyG
_mag = ["6G30Magazine", "6G30Magazine", "SmokeShell", "SmokeShell"]
_weapon = ["6G30", "Binocular"]
goto "exit"

#LAW
_mag = ["M16", "M16", "M16", "M16", "LAWLauncher", "LAWLauncher", "LAWLauncher"]
_weapon = ["M16", "LAWLauncher"]
goto "exit"

#ELAW
_mag = ["AK74", "AK74", "AK74", "AK74", "RPGLauncher", "RPGLauncher", "RPGLauncher"]
_weapon = ["AK74", "RPGLauncher"]
goto "exit"

#OfficerHG
_mag = ["M16", "M16", "M16", "M16", "BerettaMag", "BerettaMag", "BerettaMag", "BerettaMag", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "SmokeShell", "SmokeShell"]
_weapon = ["M16", "Binocular", "Beretta"]
goto "exit"

#OfficerEHG
_mag = ["AK74", "AK74", "AK74", "AK74", "TokarevMag", "TokarevMag", "TokarevMag", "TokarevMag", "HandGrenade", "HandGrenade", "HandGrenade", "HandGrenade", "SmokeShell", "SmokeShell"]
_weapon = ["AK74", "Binocular", "Tokarev"]
goto "exit"

#Sniper
_mag = ["M21", "M21", "M21", "M21"]
_weapon = ["M21"]
goto "exit"

#ESniper
_mag = ["SVDDragunov", "SVDDragunov", "SVDDragunov", "SVDDragunov"]
_weapon = ["SVDDragunov"]
goto "exit"

#MG
_mag = ["M60", "M60", "M60", "M60", "M60"]
_weapon = ["M60"]
goto "exit"

#EMG
_mag = ["PK", "PK", "PK", "PK", "PK"]
_weapon = ["PK"]
goto "exit"

#Medic
_mag = ["M16", "M16", "M16", "M16"]
_weapon = ["M16"]
goto "exit"

#EMedic
_mag = ["AK74", "AK74", "AK74", "AK74"]
_weapon = ["AK74"]
goto "exit"

#Mortar
_mag = ["M16", "M16", "M16", "M16", "Mortar", "Mortar", "Mortar"]
_weapon = ["M16"]
goto "exit"

#exit
removeAllWeapons _obj
"_obj addMagazine _x" forEach _mag
"_obj addWeapon _x" forEach _weapon
_obj selectWeapon (_weapon select 0)

exit

serverloop.sqs
Quote
;Check to see when the soldier dies
;by Doolittle

;_obj = [USA1, USA2, RUS1]
;_obj must be after #Beginning
_type = ["OfficerHG", "XMS", "SoldierE"]
;This would mean USA1 is an OfficerHG, USA2 is an XMS dude, and RUS1 is a SoldierE
;Make up your own loadout for peeps and make up whatever name you want in the weapons.sqs file
_count = count _type
;_alive must be same length as _type and _obj and make it all zeros
_alive = [0, 0, 0]

#Beginning
_i = 0
;This MUST be here inside the loop
_obj = [USA1, USA2, RUS1]

~1
#Next

~0.01
_o = _obj select _i

? not alive _o : _alive set [_i, 0]
? _alive select _i == 0 and alive _o : [_o, _type select _i] exec "weapons.sqs"; _alive set [_i, 1]

_i = _i + 1
? _i == _count : goto "Beginning"
goto "Next"
Then make a Game Logic object and in its Initialization put [] exec "serverloop.sqs".  Now, for the soldiers you want to get weapons on respawn, name them (like USA1, USA2, RUS1, etc.).  Then edit serverloop.sqs and make the _obj, _type, and _alive what you want according to the soldiers' names and what type weapon configuration you want them to have.

Enjoy! :D

Doolittle

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Wow for some reason it takes 10 years to load this post.

Anyways.  HEY MY CODE ABOVE STINKS.  IT DOESN'T WORK SO DON'T BOTHER WITH MY STUFF.  I just tested it last night with my brother over multiplayer and it was giving weird results.  :'(

Doolittle