Jump to content
Solidsnacks

How to create custom respawn inventory loadouts per unit

Recommended Posts

As the name implies, I'm asking advice on how to create custom respawn inventories per unit using BIS_fnc_addRespawnInventory. So here's the situation:

 

I have a group placed in the editor, the group is named and each unit belongs to the group and has "US_ARMY_FT = group this" in their inits so they all belong to the same group. Each member is individually named "US_ARMY_FTL, AR etc. So they all have a specific variable name with a similar naming convention.

 

Here's where it gets confusing. I'm able to use BIS_fnc_addRespawnInventory to give the group respawn inventories without a hiccup. The following is what I use for the loadouts.

Spoiler

============initServer.sqf======================

[US_ARMY_FT, 1] call BIS_fnc_respawnTickets;

[missionNamespace, ["TL",1,1]] call BIS_fnc_addRespawnInventory;
[missionNamespace, ["TL2",1,1]] call BIS_fnc_addRespawnInventory;
[missionNamespace, ["TL3",1,1]] call BIS_fnc_addRespawnInventory;
[missionNamespace, ["AR",1,1]] call BIS_fnc_addRespawnInventory;
[missionNamespace, ["AR2",1,1]] call BIS_fnc_addRespawnInventory;
[missionNamespace, ["GL",1,1]] call BIS_fnc_addRespawnInventory;
[missionNamespace, ["GL2",1,1]] call BIS_fnc_addRespawnInventory;
[missionNamespace, ["R",1,1]] call BIS_fnc_addRespawnInventory;
[missionNamespace, ["R2",1,1]] call BIS_fnc_addRespawnInventory;
[missionNamespace, ["R3",1,1]] call BIS_fnc_addRespawnInventory;
[missionNamespace, ["R4",1,1]] call BIS_fnc_addRespawnInventory;
[missionNamespace, ["S",1,1]] call BIS_fnc_addRespawnInventory;

Everything's fine when I use this method, but I wanted to fine tune it so there would be more emphasis on role selection in the lobby and also to force players to use equipment appropriate to their class.

So then I came up with this, which is more or less the same as above but references the unit's variable name.

Spoiler

[US_ARMY_FT, 1] call BIS_fnc_respawnTickets;
[US_ARMY_FTL, ["TL",1]] call BIS_fnc_addRespawnInventory;
[US_ARMY_FTL, ["TL2",1]] call BIS_fnc_addRespawnInventory;
[US_ARMY_FTL, ["TL3",1]] call BIS_fnc_addRespawnInventory;

 

=========ALSO THIS===============

 

[US_ARMY_FTL, "TL"] call BIS_fnc_addRespawnInventory;

 

=====ALSO GIVES ME THE SAME ERROR========
 

Whenever I try this second method it gives me an error saying that "us_army_ftl" is an undefined variable, which is ironic considering that it says nothing about the group I reference for respawn tickets. Additionally, I have other scripts and functions that reference the unit names I've applied and I've received no error messages about them and nothing has been logged in the RPT other than the undefined variable error to indicate anything has gone wrong.

 

It's worth noting that despite the game throwing that specific script error on mission start and it  not behaving the way I want it to it still gives me the custom classes that I defined in the Description.ext based on the entries above.

 

So my questions are: How do you make a respawn menu with loadouts custom to the unit/object. Can you do that? Why does the script think my variable is undefined? Thanks in advance!

Share this post


Link to post
Share on other sites

Thanks for the reply. I mustn't have been clear when I said that the script works fine in the first example. I've gone over the above page you've linked many times and I can't figure out why it can't produce a specific loadout for a specific unit/object as per the function's parameters and posted my example to see if anyone else could spot what I've done wrong or explain why it wouldn't work. 

Thanks!

Share this post


Link to post
Share on other sites

So let's take a look.

Spoiler
Syntax:
[target, inventory] call BIS_fnc_addRespawnInventory;
Parameters:
target: Receiver of the respawn loadout
Namespace - use missionNamespace to add the loadout to everyone
Side
Group
Object
inventory: String - CfgRespawnInventory class
Return Value:
Array - format [target,id] (used in BIS_fnc_removeRespawnInventory)

Examples

The target in this case is a unit placed in the editor given the name: US_ARMY_FTL. For some wild reason unbeknownst to me, the script seems to think that US_ARMY_FTL is an undefined variable.

 

Can anyone comment on why my logic is wrong?

 

To be clear: the script works if I use missionNamespace, Side, and Group. it DOES NOT work when I try to reference a specific unit. 

Share this post


Link to post
Share on other sites

Okay, so you have already defined that loadout in your description.ext correct?

 

when is this being called? is the unit alive / not created at the time of execution?

Share this post


Link to post
Share on other sites

This is the relevant stuff.

Spoiler

respawn = "BASE";
respawnDelay = 15;
respawnDialog = 1;
respawnTemplates[] = {"MenuPosition","MenuInventory","Tickets","Spectator","Endmission"};
respawnOnStart = 1;

showMap = 1;
enableDebugConsole = 1;

class CfgRoles
{
    class S
    {
        displayName = "Sniper";
        icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa";
    };
    class R
    {
        displayName = "Rifleman";
        icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa";
    };
    class GL
    {
        displayName = "Grenadier";
        icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa";
    };
    class AR
    {
        displayName = "Automatic Rifleman";
        icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\corporal_gs.paa";
    };
    class TL
    {
        displayName = "Team Leader";
        icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa";
    };
    
};
 
class CfgRespawnInventory
{
    class TL
    {
        displayName = "Team Leader"; // Name visible in the menu
        icon = ""; // Icon displayed next to the name
        role = "TL";

        // Loadout definition, uses same entries as CfgVehicles classes
        weapons[] = {
            "arifle_SPAR_01_snd_F",
            "hgun_P07_F",
            "ACE_Vector",
            "ACE_NVG_GEN1"
        };
        magazines[] = {
            "30Rnd_556x45_Stanag_red",
            "30Rnd_556x45_Stanag_red",
            "30Rnd_556x45_Stanag_red",
            "30Rnd_556x45_Stanag_red",
            "30Rnd_556x45_Stanag_red",
            "30Rnd_556x45_Stanag_red",
            "30Rnd_556x45_Stanag_red",
            "16Rnd_9x21_Mag",
            "16Rnd_9x21_Mag",
            "16Rnd_9x21_Mag",
            "HandGrenade",
            "HandGrenade",
        };
        items[] = {
            "ACE_fieldDressing",
            "ACE_mapTools",
            "ACE_DAGR"
        };
        linkedItems[] = {
            "V_PlateCarrier1_rgr",
            "H_HelmetB_light_snakeskin",
            "ACE_OPTIC_HAMR_PIP",
            "ACC_Pointer_IR",
            "ItemMap",
            "ItemCompass",
            "ItemWatch",
            "ItemRadio"
        };
        uniformClass = "U_B_CombatUniform_mcam";
        backpack = "B_Kitbag_mcamo";
    };

The unit is placed in the editor with "US_ARMY_FTL = group this" in its init. Technically, it's alive at mission start. 

 

I've considered a switch (true) do alternative  to sort it out, but it would seem the base FUNCTIONality has my bases covered, unfortunately it does not

 

I've tried calling it from different events: init.sqf, unit server etc. all with the same result: that the variable US_ARMY_FTL is undefined

 

Share this post


Link to post
Share on other sites
On 9/17/2017 at 3:25 PM, Solidsnacks said:

This is the relevant stuff.

  Reveal hidden contents

respawn = "BASE";
respawnDelay = 15;
respawnDialog = 1;
respawnTemplates[] = {"MenuPosition","MenuInventory","Tickets","Spectator","Endmission"};
respawnOnStart = 1;

showMap = 1;
enableDebugConsole = 1;

class CfgRoles
{
    class S
    {
        displayName = "Sniper";
        icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa";
    };
    class R
    {
        displayName = "Rifleman";
        icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa";
    };
    class GL
    {
        displayName = "Grenadier";
        icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa";
    };
    class AR
    {
        displayName = "Automatic Rifleman";
        icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\corporal_gs.paa";
    };
    class TL
    {
        displayName = "Team Leader";
        icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa";
    };
    
};
 
class CfgRespawnInventory
{
    class TL
    {
        displayName = "Team Leader"; // Name visible in the menu
        icon = ""; // Icon displayed next to the name
        role = "TL";

        // Loadout definition, uses same entries as CfgVehicles classes
        weapons[] = {
            "arifle_SPAR_01_snd_F",
            "hgun_P07_F",
            "ACE_Vector",
            "ACE_NVG_GEN1"
        };
        magazines[] = {
            "30Rnd_556x45_Stanag_red",
            "30Rnd_556x45_Stanag_red",
            "30Rnd_556x45_Stanag_red",
            "30Rnd_556x45_Stanag_red",
            "30Rnd_556x45_Stanag_red",
            "30Rnd_556x45_Stanag_red",
            "30Rnd_556x45_Stanag_red",
            "16Rnd_9x21_Mag",
            "16Rnd_9x21_Mag",
            "16Rnd_9x21_Mag",
            "HandGrenade",
            "HandGrenade",
        };
        items[] = {
            "ACE_fieldDressing",
            "ACE_mapTools",
            "ACE_DAGR"
        };
        linkedItems[] = {
            "V_PlateCarrier1_rgr",
            "H_HelmetB_light_snakeskin",
            "ACE_OPTIC_HAMR_PIP",
            "ACC_Pointer_IR",
            "ItemMap",
            "ItemCompass",
            "ItemWatch",
            "ItemRadio"
        };
        uniformClass = "U_B_CombatUniform_mcam";
        backpack = "B_Kitbag_mcamo";
    };

The unit is placed in the editor with "US_ARMY_FTL = group this" in its init. Technically, it's alive at mission start. 

 

I've considered a switch (true) do alternative  to sort it out, but it would seem the base FUNCTIONality has my bases covered, unfortunately it does not

 

I've tried calling it from different events: init.sqf, unit server etc. all with the same result: that the variable US_ARMY_FTL is undefined

 

I would define that variable upon execution of that function,

otherwise I believe that variable isn't available globally. 

Share this post


Link to post
Share on other sites

Although this topic is pretty old (about 4 years old!), I have the same issue. The problem is probably what @Midnighters actually said. The loadouts are defined before the objects. Supposedly there is a condition that you can set when you define the class of the respawnInventory using the "show = " but this one doesn't seem to work either! Although I found that on BI's wiki about respawn! IF I find anything I will let you know! I case you have found a solution to this one, please, let me know. Cheers

 

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

×