OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: JPSelter on 31 Aug 2005, 14:39:34

Title: Weapons and Vehicles disappear after respawn
Post by: JPSelter on 31 Aug 2005, 14:39:34
This is really strange: I made a simple multiplayer mission. At the respawn site I have an empty truck (5t BWMod), an empty Mi-17 helicopter and 3 soldiers on my side. When I test the respawn and kill 2 soldiers they shoot me and I respawn after 10 seconds... so far so good... but then the Mi-17 has disappeared but the truck is still there. I also lost my G36 and got the standard rifle. What is wrong?
Title: Re:Weapons and Vehicles disappear after respawn
Post by: JPSelter on 31 Aug 2005, 14:57:08
LOL please donÂ't slap me! The chopper disappeared because it rolled down the hill into the sea behind my back... I was looking at my mates :D

So please forget about about the "disappearing" vehicles :D But I still lose my G36 after respawning. My default soldier type is BWMod Squad Leader.
Title: Re:Weapons and Vehicles disappear after respawn
Post by: nominesine on 31 Aug 2005, 15:36:01
I would guess that you respawn with the default weapon of the default BWmod squad leader, am I correct? When you respawn, you need to change the weapon manually if you want a different one than the default selection.
Title: Re:Weapons and Vehicles disappear after respawn
Post by: JPSelter on 31 Aug 2005, 17:25:18
Hmmmm I start the mission as a default squad leader. I have a G36, hand granates and a binocular. When I kill myself and respawn I have only the standard M16, no hand granates and no binocular. IÂ'm able to pick up the "old" weapons but that doesnÂ't make sense. So why are my weapons gone after a respawn? A bug? Do I need to configure my weapons loadout somewhere else?
Title: Re:Weapons and Vehicles disappear after respawn
Post by: Terox on 31 Aug 2005, 18:22:32
using a killed eventhandler attached to all Playersl run the following code

INIT.sqs
Quote
tx_weapons = weapons player
tx_ammo = ammunition player
tx_prim = primaryweapon player
player addEventHandler ["killed", {_this exec "respawn.sqs"}]


Respawn.sqs
Quote
player removealleventhandlers "Killed"

@ alive player
removeallweapons player
player addEventHandler ["killed", {_this exec "respawn.sqs"}]

{player addMagazine _x} forEach tx_ammo
{player addWeapon _x} forEach tx_weapons
player selectWeapon tx_primary

this will reload the player with the weapons he started with ingame

if you want the weapons the unit died with, then that can also be done by:

a) remove all the lines except the addeventhandler "killed" in ther INIT.sqs

and add them to just before the "@ alive Player" line in the respawn.sqs
If this system is used then you can change the variable names from global to local

eg from
tx_weapons
to
_weapons

Title: Re:Weapons and Vehicles disappear after respawn
Post by: JPSelter on 31 Aug 2005, 19:56:02
Phew... this goes deep into programming. I did create these two files and inserted the code into them. In the mission editor I gave my player the name "player". But when I start the mission I get the error "tx_ammunition |#|player" - unknown operator player". Is your above syntax correct? Are any ; or " missing?
Title: Re:Weapons and Vehicles disappear after respawn
Post by: JPSelter on 01 Sep 2005, 14:37:31
I tested a bit more and came to this: Everything in init.sqs and respawn.sqs is working except for line 2 in init.sqs

"tx_ammo = ammunition Player" --> unknown operator |#|Player

So why is tx_weapons working but not tx_ammo? Now I have my G36 and my binoculars back after respawn, but with no ammunition.
Title: Re:Weapons and Vehicles disappear after respawn
Post by: JPSelter on 01 Sep 2005, 15:15:13
OK, I found the error... itÂ's magazines not ammunitions. And tx_prim has to be tx_primary. Thanks though, itÂ's working now :)
Title: Re:Weapons and Vehicles disappear after respawn
Post by: Terox on 01 Sep 2005, 16:31:36
sorry about syntax errors m8, I wrote the code on the fly
Title: Re:Weapons and Vehicles disappear after respawn
Post by: JPSelter on 01 Sep 2005, 23:09:10
No problem :)