Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
lv1234

How do you map a respawn backpack to a unit? (local multiplayer)

Recommended Posts

I am trying to make my player spawn with a respawn backpack w/sleeping bag attached to him  . Does anyone know how to do it specifically with the addbackpack command?

Share this post


Link to post
Share on other sites

The easiest way:

Choose your loadout in 3den (your player with one of the respawn tent/sleep bag). You can script something with addBackpackGlobal but it's same for the following:

When respawning the loadout becomes the default one for the unit.

 

So I suggest you to do all choices you want in 3den and add in the init field of the unit:

if (isServer) then {this setVariable ["loadout", getUnitLoadout this]; this addEventHandler ["respawn",{ params ["_unit"]; _unit setUnitLoadout (_unit getVariable ["loadout",[]])}]};

You'll retrieve the same loadout as start. If you want the same loadout at death, it's possible but it needs some extra lines.

Share this post


Link to post
Share on other sites
2 hours ago, pierremgi said:

The easiest way:

Choose your loadout in 3den (your player with one of the respawn tent/sleep bag). You can script something with addBackpackGlobal but it's same for the following:

When respawning the loadout becomes the default one for the unit.

 

So I suggest you to do all choices you want in 3den and add in the init field of the unit:

if (isServer) then {this setVariable ["loadout", getUnitLoadout this]; this addEventHandler ["respawn",{ params ["_unit"]; _unit setUnitLoadout (_unit getVariable ["loadout",[]])}]};

You'll retrieve the same loadout as start. If you want the same loadout at death, it's possible but it needs some extra lines.

Would the "loadout" be the name of the loadout? 

Share this post


Link to post
Share on other sites

It's the name of the variable attached to the unit/player. You can replace (in both cases) by what you want. The getUnitLoadout command returns an array, not a "name".

Share this post


Link to post
Share on other sites
19 minutes ago, pierremgi said:

It's the name of the variable attached to the unit/player. You can replace (in both cases) by what you want. The getUnitLoadout command returns an array, not a "name".

So would that be the backpack we are talking about? 

Share this post


Link to post
Share on other sites
5 hours ago, lv1234 said:

So would that be the backpack we are talking about? 

You can find this backpack in 3den editor (right click on a unit then edit loadout) I can't say better. You set your unit as you like, click OK Add the line I gave you in its inti field for respawn case. The name of the variable doesn't matter. It's your reminder to recall it: "blabla" "myBackpack" "kesako" "redeyedRabbit"...

Share this post


Link to post
Share on other sites

×