You need a init.sqf file and two more sqf files below, for your position and gear - create then place these files in your mission file:
INIT.SQF:
all compile preprocessFile "staticData.sqf";
if(isServer) then {
waitUntil {!isNil "ALiVE_STATIC_DATA_LOADED"};
call compile (preprocessFileLineNumbers "staticData.sqf");
};
addMissionEventHandler ["entityKilled", {
_victim = _this select 0;
if (local _victim) then {
[_victim, [missionNamespace, name _victim]] call BIS_fnc_saveInventory;
_victim setVariable ["MGI_ammo1",_victim ammo (primaryWeapon _victim)];
_victim setVariable ["MGI_ammo2",_victim ammo (handgunWeapon _victim)];
_victim setVariable ["MGI_ammo3",_victim ammo (secondaryWeapon _victim)];
_victim setVariable ["MGI_mags",magazinesAmmoFull _victim];
_victim setVariable ["MGI_weapon",currentWeapon _victim];
};
}];
addMissionEventHandler ["entityRespawned", {
_unit = _this select 0;
_corpse = _this select 1;
if (local _unit) then {
[_unit, [missionNamespace, name _unit]] call BIS_fnc_loadInventory;
{_unit removeMagazine _x} forEach magazines _unit;
_unit setAmmo [primaryWeapon _unit, 0];
_unit setAmmo [handGunWeapon _unit, 0];
_unit setAmmo [secondaryWeapon _unit, 0];
{
if (((_unit getVariable "MGI_mags") select _foreachindex select 3) <= 0) then {
_unit addMagazine [_x select 0,_x select 1]
}
} forEach (_unit getVariable "MGI_mags");
_unit setAmmo [primaryWeapon _unit,_unit getVariable "MGI_ammo1"];
_unit setAmmo [handGunWeapon _unit,_unit getVariable "MGI_ammo2"];
_unit setAmmo [secondaryWeapon _unit,_unit getVariable "MGI_ammo3"];
_unit selectWeapon (_unit getVariable "MGI_weapon");
removeAllWeapons _corpse;
removeBackpackGlobal _corpse;
removeVest _corpse;
removeAllAssignedItems _corpse;
removeAllItems _corpse;
removeGoggles _corpse;
removeHeadgear _corpse;
{deleteVehicle _x} forEach nearestObjects [(getPosATL _corpse),["WeaponHolderSimulated","groundWeaponHolder"],5];
};
}];
waituntil {(player getvariable ["alive_sys_player_playerloaded",false])};
sleep 2;
{
if !(isPlayer _x) then {
if !(_x getVariable ["Persistent_Teleport", false]) then {
_x setPos (getPos player);
_x setVariable ["Persistent_Teleport", true, true];
sleep .5;
};
};
} forEach units group player;
Then the two other SQF below:
onPlayerKilled.sqf:
player setVariable["Saved_Loadout",getUnitLoadout player];
onPlayerRespawn:
removeAllWeapons player;
removeGoggles player;
removeHeadgear player;
removeVest player;
removeUniform player;
removeAllAssignedItems player;
clearAllItemsFromBackpack player;
removeBackpack player;
player setUnitLoadout(player getVariable["Saved_Loadout",[]]);