Jump to content

Recommended Posts

I need some help for respawn loadouts. I'll make a server for me n my crew play and enjoy it. I make the base, vehicel respanws, put the player slots set up the server. Everythign was fine but respawn it have a problem.

I change the player special states "enable stamina off" ofcourse. Put the infantry respawn module set delay bla bla.. Whatever. when i test in game to respawn i killed myself with a granade and force respawn screen come on my screen. I'll hold the space bar and forced respawn has correct work. But when i dead and take respawn my character has reset, reset loadout, reset my edits, everything have reseted on player. 

I'll try that scripts on server file;

 

initPlayerLocal.sqf

pLoadout = getUnitLoadout player;

 

onPlayerRespawn.sqf

player setUnitLoadout pLoadout;

 

 

This does not work and i search some different scripts and find this;

 

PlayerKilled

[player, [missionNamespace, "inventory_var"]] call BIS_fnc_saveInventory;

 

PlayerRespawn

[player, [missionNamespace, "inventory_var"]] call BIS_fnc_loadInventory;

 

but this scripts not work maybe make mistakes but dont think so. How can i fix this issiue????

Share this post


Link to post
Share on other sites

In the init.sqf :

 

waitUntil { !isNull player };


addMissionEventHandler ["EntityKilled", {
	params ["_unit", "_killer", "_instigator", "_useEffects"];
	
	if(isPlayer _unit)then{
		[_unit, [profileNamespace, "inventory_var"]] call BIS_fnc_saveInventory;
	}else{
		[_unit, [missionNamespace, "inventory_var"]] call BIS_fnc_saveInventory;
	};
}];

addMissionEventHandler ["EntityRespawned", {
	params ["_entity", "_corpse"];
	if(isPlayer _entity)then{
		[_entity, [profileNamespace, "inventory_var"]] call BIS_fnc_loadInventory;
	}else{
		[_entity, [missionNamespace, "inventory_var"]] call BIS_fnc_loadInventory;
	};
}];

It might pop up an error at the beggining. It does work though. The "error" only occurred after a game update.

Share this post


Link to post
Share on other sites
9 hours ago, Bnb.Andrew said:

 

initPlayerLocal.sqf

pLoadout = getUnitLoadout player;

 

onPlayerRespawn.sqf

player setUnitLoadout pLoadout;

 

 

PlayerKilled

[player, [missionNamespace, "inventory_var"]] call BIS_fnc_saveInventory;

PlayerRespawn

[player, [missionNamespace, "inventory_var"]] call BIS_fnc_loadInventory;

 

but this scripts not work maybe make mistakes but dont think so. How can i fix this issiue????

 

the get/setUnitLoadout works.

But the initPlayerLocal.sqf will run when the player starts to play mission, not when he dies/respawns.

You're right with your 2nd approach killed/respawned:

 

In initPlayerLocal.sqf:

private _stamina = "stamina" call BIS_fnc_getParamValue;  // if any in your MP description.ext, 0 if not present  More here.
player enableStamina ([false,true] select _stamina);
if (_stamina == 0) then {
  player setCustomAimCoef 0;
};

 

in initPlayerLocal or init.sqf (init.sqf is fine if you want to treat dead AIs on server also) Anyway, the code will run everywhere the MEH is present. The MEH code is local but for setUnitLoadout, no problem, the command is AG EG.

 

addMissionEventHandler ["Entitykilled", {
  params ["_victim","_killer","_instigator"];
  // optional________________________________

if (isNull _instigator) then {
    _instigator = UAVControl vehicle _killer select 0
  };
  if (isNull _instigator) then {_instigator = _killer};

//__________________________________________
   removeAllActions _victim; // optional
   if (local _victim && _victim in (playableUnits + switchableUnits)) then {  // my filter to run this EH for dying player PC only, you can change it

     _victim setVariable ["loadout",getUnitLoadout _victim];
   };
}];

 

addMissionEventHandler ["EntityRespawned", {
  params ["_unit","_corpse"];

  if (local _unit && isPlayer _unit) then { // there is no reason to run that on each PC

     _unit setUnitLoadout (_corpse getVariable ["loadout",getUnitLoadout _unit]);
     _stamina = "stamina" call BIS_fnc_getParamValue;
     _unit enableStamina ([false,true] select _stamina);
     if (_stamina == 0) then {
       _unit setCustomAimCoef 0;
     };
  };
  if (local _corpse) then {
    {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

×