Jump to content
soldier9945

Custom Respawn Inventory Menu per player (dynamically load player's saved Virtual Arsenal loadouts)

Recommended Posts

Hi there!

 

I was initially looking to load the Virtual Arsenal while a player is in the spawn menu so that he can choose his gear with a nice visual interface. I found out that the Zeus mode has the feature to create and populate the Inventory menu with loadouts created by the Zeus player, but only for Zeus, not for all players.

 

What I want to do now is the following:

  1. User connects to the server and gets the respawn and inventory menus. I successfully implemented:
    respawnTemplates[] = {"Revive", "MenuPosition", "Tickets", "Wave", "MenuInventory"};
  2. Inventory menu is populated with standard loadouts defined in my mission (if possible, a button to load the Virtual Arsenal would be nice, if not a simple ammo crate after respawn will do the trick)
  3. If the user saved one or more loadouts in Virtual Arsenal, import them into the Menu Inventory for the next respawn of this player (ideally only the ones created on the actual server to limit incomplete loadouts due to server/mission restrictions)

I have looked for the last 5 hours through multiple sources and forums to find something similar, without luck. Note that I am just (re)starting to script and make missions for ArmA. I stopped after Cold War Crisis started to get old in... what... 2004? (ARMA NEVER GETS OLD!!! I know... shame on me)

 

I have found a thread (BI Virtual Arsenal and BI respawn. Playing nicely together?) dealing about automatically restoring the previously selected loadout at respawn and somehow revive with the last known loadout (if you threw a grenade you shouldn't be magically revived with a new nade!)... I think I'll be forced to look at that at some point.

 

What do you think? Would that be possible? I am willing to invest some time to get this working for my mission project.

 

 

 

I want to implement this "per player virtual arsenal loadout" in a sort of "mission template" I am currently trying to build

 

  • This mission preset would be similar to "Rush" in Battlefield
  • Less arcade than the mode in BF but still letting players respawn on squad leaders and respawn points to bring fast paced action to ArmA multiplayer
  • The mission has multiple steps like "Rush" but every objective has an impact on ressources of the defending or attacking team
  • The ultimate goal is to create a mission template that can be more or less easily modified by :
    • moving the mission on the map
    • modifying it's size (distance between the objectives)
    • copying it over to another island
    • changing objectives (destroying a weapons cache in a building, stealing or destroying a fuel truck, holding a zone, stealing documents)
    • changing the impact an action has on objectives (stealing the fuel truck gives your team access to a tank previously out of fuel, or destroying it to easily cut off their tank which is already low on fuel, restricting access to special weapons because a weapon cache has been taken out...)

In short I want to make ArmA accessible to more casual people and show them what they miss out not being able to create their own content, making it easyer for them to discover and adapt to the deep gameplay mechanics possible with this game.

Share this post


Link to post
Share on other sites

I need sleep... infact the thread BI Virtual Arsenal and BI respawn. Playing nicely together? is all about what I try to do, minus the possibility to save multiple loadouts and a graphical way to switch them through.

 

We need to find where the Virtual Arsenal loadout is stored, how to access it and populate the Respawn Inventory menu with those entries...

 

Well, good night, I'm out.

Share this post


Link to post
Share on other sites

We need to find where the Virtual Arsenal loadout is stored, how to access it and populate the Respawn Inventory menu with those entries.

 

 

Description.ext

respawn = 3;

respawnDelay = 2;

respawnTemplates[] = {"menuInventory"};

respawnOnStart = 1;

initPlayerLocal.sqf

_arsenalNames = [];
_arsenalDataLocal = [];
_arsenalData = profilenamespace getvariable ["bis_fnc_saveInventory_data",[]];
for "_i" from 0 to (count _arsenalData - 1) step 2 do {
    _name = _arsenalData select _i;
    _arsenalDataLocal = _arsenalDataLocal + [_name,_arsenalData select (_i + 1)];
    _nul = _arsenalNames pushBack ( format[ "missionnamespace:%1", _name ] );
};
missionnamespace setvariable ["bis_fnc_saveInventory_data",_arsenalDataLocal];
[player,_arsenalNames] call bis_fnc_setrespawninventory;
  • Like 3

Share this post


Link to post
Share on other sites

 

Description.ext

respawn = 3;

respawnDelay = 2;

respawnTemplates[] = {"menuInventory"};

respawnOnStart = 1;

initPlayerLocal.sqf

_arsenalNames = [];
_arsenalDataLocal = [];
_arsenalData = profilenamespace getvariable ["bis_fnc_saveInventory_data",[]];
for "_i" from 0 to (count _arsenalData - 1) step 2 do {
    _name = _arsenalData select _i;
    _arsenalDataLocal = _arsenalDataLocal + [_name,_arsenalData select (_i + 1)];
    _nul = _arsenalNames pushBack ( format[ "missionnamespace:%1", _name ] );
};
missionnamespace setvariable ["bis_fnc_saveInventory_data",_arsenalDataLocal];
[player,_arsenalNames] call bis_fnc_setrespawninventory;

 

Wow! Thanks a lot! I will try this asap!

 

EDIT:

 

It works like a charm!!!! Thanks alot! Where did you find / how did you deduce this?

 

Tell me if I can get you a beer or something else! (PayPal or other)

Share this post


Link to post
Share on other sites

Hi there!

 

Just another thing I found out: I can't create a custom loadout and select it on the next spawn, because the Virtual Arsenal loadouts are loaded only on the player init in initPlayerLocal.sqf

// Load Virtual Arsenal into Respawn Inventory
_arsenalNames = [];
_arsenalDataLocal = [];
_arsenalData = profilenamespace getvariable ["bis_fnc_saveInventory_data",[]];

for "_i" from 0 to (count _arsenalData - 1) step 2 do {
    _name = _arsenalData select _i;
    _arsenalDataLocal = _arsenalDataLocal + [_name,_arsenalData select (_i + 1)];
    _nul = _arsenalNames pushBack ( format[ "missionnamespace:%1", _name ] );
};
missionnamespace setvariable ["bis_fnc_saveInventory_data",_arsenalDataLocal];
[player,_arsenalNames] call bis_fnc_setrespawninventory;

To be able to load a created loadout in a running mission, also execute the same code in the onPlayerKilled.sqf event handler:

// Load Virtual Arsenal into Respawn Inventory
_arsenalNames = [];
_arsenalDataLocal = [];
_arsenalData = profilenamespace getvariable ["bis_fnc_saveInventory_data",[]];

for "_i" from 0 to (count _arsenalData - 1) step 2 do {
    _name = _arsenalData select _i;
    _arsenalDataLocal = _arsenalDataLocal + [_name,_arsenalData select (_i + 1)];
    _nul = _arsenalNames pushBack ( format[ "missionnamespace:%1", _name ] );
};
missionnamespace setvariable ["bis_fnc_saveInventory_data",_arsenalDataLocal];
[player,_arsenalNames] call bis_fnc_setrespawninventory;

That way the loadouts get reloaded into the Spawn Inventory Menu every time a player dies (just before they are needed btw...). It works also if the player chooses to respawn with the menu entry, as the respawn will simply kill the player.

  • Like 2

Share this post


Link to post
Share on other sites

 

Description.ext

respawn = 3;

respawnDelay = 2;

respawnTemplates[] = {"menuInventory"};

respawnOnStart = 1;

initPlayerLocal.sqf

_arsenalNames = [];
_arsenalDataLocal = [];
_arsenalData = profilenamespace getvariable ["bis_fnc_saveInventory_data",[]];
for "_i" from 0 to (count _arsenalData - 1) step 2 do {
    _name = _arsenalData select _i;
    _arsenalDataLocal = _arsenalDataLocal + [_name,_arsenalData select (_i + 1)];
    _nul = _arsenalNames pushBack ( format[ "missionnamespace:%1", _name ] );
};
missionnamespace setvariable ["bis_fnc_saveInventory_data",_arsenalDataLocal];
[player,_arsenalNames] call bis_fnc_setrespawninventory;

 

Can Anybody explain how to use this to me?

Share this post


Link to post
Share on other sites

 

 

initPlayerLocal.sqf

_arsenalNames = [];
_arsenalDataLocal = [];
_arsenalData = profilenamespace getvariable ["bis_fnc_saveInventory_data",[]];
for "_i" from 0 to (count _arsenalData - 1) step 2 do {
    _name = _arsenalData select _i;
    _arsenalDataLocal = _arsenalDataLocal + [_name,_arsenalData select (_i + 1)];
    _nul = _arsenalNames pushBack ( format[ "missionnamespace:%1", _name ] );
};
missionnamespace setvariable ["bis_fnc_saveInventory_data",_arsenalDataLocal];
[player,_arsenalNames] call bis_fnc_setrespawninventory;

 

Can I assume this is possible with the Virtual Garage too? 

Share this post


Link to post
Share on other sites

Can Anybody explain how to use this to me?

 

https://community.bistudio.com/wiki/Mission_Editor:_External

https://community.bistudio.com/wiki/Event_Scripts

https://community.bistudio.com/wiki/Description.ext

 

You need to create a Description.ext and an initPlayer.sqf files into a folder of a mission, and put the given texts into them.

Share this post


Link to post
Share on other sites

Is not needed any modification of the files? because it don't work for me.

 

What it does for me is just respawn my character with a random selection of the loadouts I have saved in virtual arsenal.

Share this post


Link to post
Share on other sites

What it does for me is just respawn my character with a random selection of the loadouts I have saved in virtual arsenal.

 

I guess you got both "MenuPosition" and "MenuInventory" on, and haven't pressed the small arrow thats right over the Respawn button? As you've got to choose there what you want or it will take a random one.

 

A3_respawnSelectInventory.jpg

Share this post


Link to post
Share on other sites

I'm sorry but, I doubt we're talking about the same thing. So you got to explain a bit better your situation.

Share this post


Link to post
Share on other sites

Has anyone got an idea why the NO RESPAWN POSITIONS AVAILABLE when using this script i have tried a marker and respawn module to no avail.

 

Disregard this post I'm not even going to post the solution I'm such a dunce.

 I set respawn module to OPFOR DUH.

Share this post


Link to post
Share on other sites

In onPlayerKilled.sqf

 

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

 

in onPlayerRespawn.sqf

 

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

 

maybe that helps !

Share this post


Link to post
Share on other sites

This thread was very helpful.

 

May I make one request? Is there any way to dynamically change an existing loadout?

 

Meaning, I have custom Roles and RespawnInventory loadouts in the description.ext file, Let's say I have a "Medic" loadout under the "Support" role for example. The player selects this loadout, spawns, then proceeds to a nearby ammo box that starts the Virtual Arsenal with items I've whitelisted for medics. The player makes his changes to his loadout, closes the VA, goes to play for a bit and dies. Upon respawn, is there any way for the "Medic" loadout under the "Support" role to now be updated with the changes the player made in the VA in his previous life?

 

I tried using https://community.bistudio.com/wiki/BIS_fnc_saveInventory and https://community.bistudio.com/wiki/BIS_fnc_setRespawnInventory which seems to work fine, but even if I use the same name as an existing loadout it just creates a new loadout with the same name under a "Default" role.

Share this post


Link to post
Share on other sites

You will need to force the inventory data into the correct slot of BIS_fnc_getRespawnInventories_list.

Can you show me your CfgRespawnInventory, CfgRoles and how and where exactly you are adding the respawn inventories.

This will allow me to better explain a solution for you, especially where your adding the respawn inventory as the data is shared globally and we will have to try fudging expertly coercing a local update when the arsenal is closed and see if it holds.

Share this post


Link to post
Share on other sites

I can't remember that stuff off the top of my head and I'm at work right now, so I'll post them when I get home tonight. Thanks!

 

If it helps for now, basically I have 3 custom roles ("Assault", "Support", "Recon"), and 1 custom Loadout/Inventory for each role respectively ("Rifleman","MG,"Sniper" - these are the display names and class names). These are just to test, there will be more in the future but I think there will always be only those 3 Roles, just more loadouts for each role.

 

In the initServer.sqf I have something like [west, ["Rifleman",5]] call BIS_fnc_addRespawnInventory for each of the Loadouts in the order they appear in CfgRespawnInventory.

 

I believe that's it. Everything looks and works as it should. I'd just like people to be able to modify these dynamically using the VA and keep the same look and feel for a better presentation and keep the correct limit count on those loadouts, since they have limits too if you noticed in that addRespawnInventory call.

 

In my head I imagined I would just have to get the reference to the current inventory I loaded then update it or re-create it when I quit the VA. Sounded simple. I tried looking through all the respawn inventory code this weekend myself. I actually learned a lot but didn't really get anywhere :(

 

Again, I'll post all that stuff you requested when I get home tonight.

Share this post


Link to post
Share on other sites

Can you show me your CfgRespawnInventory, CfgRoles and how and where exactly you are adding the respawn inventories.

This will allow me to better explain a solution for you, especially where your adding the respawn inventory as the data is shared globally and we will have to try fudging expertly coercing a local update when the arsenal is closed and see if it holds.

//description.ext

class CfgRespawnInventory
{
// I'm actually using #include "loadouts_west.hpp"
// but the following is the content of that file
class Rifleman
{
    displayName = "Rifleman"; // Name visible in the menu
    icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa"; // Icon displayed next to the name
    role = "Assault";

    // Loadout definition, uses same entries as CfgVehicles classes
    weapons[] = {
        "arifle_MXC_F",
        "Binocular"
    };
    magazines[] = {
        "30Rnd_65x39_caseless_mag",
        "30Rnd_65x39_caseless_mag",
        "SmokeShell"
    };
    items[] = {
        "FirstAidKit"
    };
    linkedItems[] = {
        "V_Chestrig_khk",
        "H_Watchcap_blk",
        "optic_Aco",
        "acc_flashlight",
        "ItemMap",
        "ItemCompass",
        "ItemWatch",
        "ItemRadio"
    };
    uniformClass = "U_B_CombatUniform_mcam_tshirt";
    backpack = "B_AssaultPack_mcamo";
};
class MG
{
    // Alternative configuration pointing to a CfgVehicles class. Loadout will be copied from it.
    displayName = "MG";
    icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa";
    role = "Support";

    // Loadout definition, uses same entries as CfgVehicles classes
    weapons[] = {
        "LMG_Mk200_F",
        "Binocular"
    };
    magazines[] = {
        "200Rnd_65x39_cased_Box",
        "200Rnd_65x39_cased_Box"
    };
    items[] = {
        "FirstAidKit"
    };
    linkedItems[] = {
        "V_Chestrig_khk",
        "H_Watchcap_blk",
        "optic_Aco",
        "ItemMap",
        "ItemCompass",
        "ItemWatch",
        "ItemRadio"
    };
    uniformClass = "U_B_CombatUniform_mcam_tshirt";
    backpack = "B_AssaultPack_mcamo";
};
class Sniper
{
    // Alternative configuration pointing to a CfgVehicles class. Loadout will be copied from it.
    displayName = "Sniper";
    icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa";
    role = "Recon";

    // Loadout definition, uses same entries as CfgVehicles classes
    weapons[] = {
        "srifle_LRR_F",
        "Binocular"
    };
    magazines[] = {
        "7Rnd_408_Mag",
        "7Rnd_408_Mag",
        "7Rnd_408_Mag"
    };
    items[] = {
        "FirstAidKit"
    };
    linkedItems[] = {
        "V_Chestrig_khk",
        "H_Watchcap_blk",
        "optic_LRPS",
        "ItemMap",
        "ItemCompass",
        "ItemWatch",
        "ItemRadio"
    };
    uniformClass = "U_B_GhillieSuit";
    backpack = "";
};
#include "loadouts_east.hpp"
};

class CfgRoles
{
	class Assault
	{
		displayName = "Assault";
		icon = "\A3\Ui_f\data\GUI\Cfg\RespawnRoles\assault_ca.paa";
	};
	class Support
	{
		displayName = "Support";
		icon = "\A3\Ui_f\data\GUI\Cfg\RespawnRoles\support_ca.paa";
	};
	class Recon
	{
		displayName = "Recon";
		icon = "\A3\Ui_f\data\GUI\Cfg\RespawnRoles\recon_ca.paa";
	};
};

initServer.sqf

//initServer.sqf
//Assign car limits
...

//Initialize dynamic groups
...

//Initialize assault loadouts
[west,["Rifleman",5]] call BIS_fnc_addRespawnInventory;
[east,["Rifleman",5]] call BIS_fnc_addRespawnInventory;

//Initialize support loadouts
[west,["MG",8]] call BIS_fnc_addRespawnInventory;
[east,["MG",8]] call BIS_fnc_addRespawnInventory;

//Initialize recon loadouts
[west,["Sniper",2]] call BIS_fnc_addRespawnInventory;
[east,["Sniper",2]] call BIS_fnc_addRespawnInventory;

//Player connected handler
...

//Player disconnected handler
...

Share this post


Link to post
Share on other sites

Try this test mission.

I was hoping that I could inject the new loadout into BIs metaData for the roles but it seems the roles are recalculated every time from the configs.

Instead I have made my own data structure from theirs and each time a player closes the VA it saves their loadout in my data structure next to the role they where currently using.

On dying I inject a reference to the loadout into the BIs data so as the Details part of the respawn menu displays the correct items from the saved loadout.

When the player respawns it looks at what role they chose, retrieves the saved loadout for that role and applies it to the player.

 

All you need to do is copy the LARs folder to your mission and use the include for CfgFunctions found in the description.ext of the test mission.

The system inits itself from the function library so there is nothing else to start up.

 

See how you get on with it and let me know of any problems.

  • Like 1

Share this post


Link to post
Share on other sites

Hi Larrow, I finally had a chance to try out your mission after a pretty busy few days.

 

It seems to be working great! I tried it from the MP editor and on a local dedicated server and every time I respawned I saw the updated loadout in the correct spot, amazing! I haven't had a chance to test it with a friend yet.

 

I looked through your code a bit and I'm surprised how much work it required.

 

If I really wanted to nitpick, and I do :D  , is that the new inventory icons in the respawn inventory menu don't get updated even though the "details" are correct. However, clicking on another loadout then clicking back will update said icons correctly. Is that something that can be fixed so that it shows the updated icons the first time?

 

Also, a big THANK YOU!!!

Share this post


Link to post
Share on other sites

Updated test mission in post #19. Please read the description.ext as I have added some values to enable saving.

  • Like 1

Share this post


Link to post
Share on other sites

I don't know if I will ever get this right Larrow but thanks, me getting is wrong is my fault.

 

When I look at it it looks like it will work in multiplayer.

 

Edit:  It works its just I have to separate the loadouts east and west. Right now all my loadouts that I have saved in the arsenal are available to both sides

Share this post


Link to post
Share on other sites
On 11/22/2016 at 8:38 AM, Larrow said:

Try this test mission.

I was hoping that I could inject the new loadout into BIs metaData for the roles but it seems the roles are recalculated every time from the configs.

Instead I have made my own data structure from theirs and each time a player closes the VA it saves their loadout in my data structure next to the role they where currently using.

On dying I inject a reference to the loadout into the BIs data so as the Details part of the respawn menu displays the correct items from the saved loadout.

When the player respawns it looks at what role they chose, retrieves the saved loadout for that role and applies it to the player.

 

All you need to do is copy the LARs folder to your mission and use the include for CfgFunctions found in the description.ext of the test mission.

The system inits itself from the function library so there is nothing else to start up.

 

See how you get on with it and let me know of any problems.

 

Sorry, I just tried to DL this test mission as I'm also struggling to get this all working correctly.  Unfortunately, I'm getting a 404 error.  Is it still available somewhere?

 

TIA

 

===

Never mind.  I figured out how to get it from the Examples link in your signature.

 

Thank you!  I'm looking forward to trying it out.

Edited by =jps=sgtrock
I figured out another way to get it.

Share this post


Link to post
Share on other sites
1 hour ago, =jps=sgtrock said:

Sorry, I just tried to DL this test mission as I'm also struggling to get this all working correctly.  Unfortunately, I'm getting a 404 error.

Your the second person to say this in the last couple of days, I've updated the link again, I do not know how it has become disassociated from the file as nothing has changed.

Share this post


Link to post
Share on other sites

I know this topic is old and Larrow's way works but this is simpler and it works with so little text editing.

This is in your description.ext file

respawnTemplates[] = {"MenuInventory","MenuPosition"};

 

This is in your initplayerlocal.sqf file

[player, [missionnamespace, "virtualinventory"]] call Bis_fnc_saveinventory;

 

This is in your onplayerrespawn.sqf

[player, [missionnamespace, "virtualinventory"]] call Bis_fnc_loadinventory;

 

You make sure you click save loadout in the multiplayer section of you missions attributes drop down while editing. Place soldiers on the battlefield, edit their loadout in arsenal, save it or not in arsenal, I save so they can be reused. Save the scenario after leaving arsenal and you are done creating loadouts. If you go back and change the loadout or make even more loadouts to choose from make sure you save. Those loadouts are now saved in the scenario as long as those files above are in your mission folder.

 

You don't even have to care what the soldier started out as when you placed them. After editing his loadout double click him and in the role portion of his attributes you can put a name or even a fairly long description of his loadout so people know what they are getting when they choose it in the lobby.

 

It will throw an error that is meaningless, I think it is because the menu inventory has no other inventories to choose from and the inventory shown is wrong. It doesn't matter you've named or described the the loadout in the role slot of his attributes.

 

I got most of this from one of SayUnkl's videos on youtube.

 

And now I link to my new problem. Vehicle respawn module problem

 

 

 

 

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

×