using a killed eventhandler attached to all Playersl run the following code
INIT.sqstx_weapons = weapons player
tx_ammo = ammunition player
tx_prim = primaryweapon player
player addEventHandler ["killed", {_this exec "respawn.sqs"}]
Respawn.sqsplayer 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