Jump to content
Jacob Anderson

Keep inventory on player respawn

Recommended Posts

A quick warning, my knowledge of scripting is on par with that of a rock.
I'm trying to make a mission for myself and a group of friends who are all new and just want to have a good time. Most of my questions I've been able to figure out through youtube videos and forum posts. But no matter how many different times I try, I can't for the life of me figure out what to do when someone pulls up notepad++ outside of Eden editor and shows me a paragraph of code to put in. I was wondering If someone more knowledgeable than me on the subject could help walk me through how to keep player inventories when they respawn.

Share this post


Link to post
Share on other sites

yes, but that's a little bit old and used for inventory same as start.

Question is: same loadout as at start or just before death?

You can use getUnitLoadout and setUnitLoadout instead of BI functions, now.

 

in initPlayerLocal.sqf:
 

sameAsDeath = TRUE;  // false for loadout at start
loadoutAtStart = getUnitLoadout player;

addMissionEventHandler ["EntityKilled", {
  params ["_victim","_killer","_instigator"];
  if (isPlayer _victim) then {
    _victim setVariable ["ldout",getUnitLoadout _victim];
    _victim setVariable ["MGI_weapon",currentWeapon _victim];
  };
}];


addMissionEventHandler ["EntityRespawned", {
  params ["_unit","_corpse"];
  if (isPlayer _unit && local _unit) then {
    if (sameAsDeath) then {
      _unit setUnitLoadout (_corpse getVariable ["ldout",getUnitLoadout _unit]);
      _unit selectWeapon (_unit getVariable "MGI_weapon");
    } else {
      _unit setUnitLoadout loadoutAtStart;
    };
    {deleteVehicle _x} forEach nearestObjects [(getPosATL _corpse),["WeaponHolderSimulated","groundWeaponHolder"],5];
    deleteVehicle _corpse;
  };
}];

 

  • Like 1

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

×