Page MenuHomeFeedback Tracker

Strange behavior with CreateInInventory
Assigned, UrgentPublic

Description

I am not sure if this is a bug but i realized a strange behavior wirth the CreateInInventory function under following conditions:

  1. I Created a custom clothing item that can be attached to the player with its config class (in this example its a black shirt):
class CfgPatches
{
	class Sample_Tops
	{
		units[]=
		{
			"Shirt_CheckRed",
			"Hoodie_Blue",
			"Hoodie_Black",
			"Hoodie_Brown",
			"Hoodie_Green",
			"Hoodie_Grey",
			"Hoodie_Red",
			"MaleTorso",
			"FemaleTorso"
		};
		weapons[] = {};
		requiredVersion = 0.1;
		requiredAddons[] = { "DZ_Characters" };
	};
};

class CfgVehicles
{
	class TShirt_ColorBase;
	class TShirt_Sample: TShirt_ColorBase
    {
        scope=2;
        displayName="Sample Shirt";
        descriptionShort="Sample Shirt";
		visibilityModifier=0.85000002;
        hiddenSelectionsTextures[]=
        {
			"\DZ\characters\tops\Data\tshirt_ground_black_co.paa",
			"\DZ\characters\tops\Data\tshirt_black_co.paa",
			"\DZ\characters\tops\Data\tshirt_black_co.paa"
        };
    };
};
  1. Tried to attach and create the item on the player character in the EquipCharacter fucntion within the MissionServer class like this:
modded class MissionServer
{
	override void EquipCharacter()
	{
		m_player.GetInventory().CreateInInventory("TShirt_Sample");
		
		StartingEquipSetup(m_player, false);
	}
}

With this the character will never spawn in with this item attached to his body (top slot) at all.
If i spawn the shirt in the world the character can see and wear the shirt just fine.

Only when i added a scripted class for the item CreateInInventory will work and the player spawns in with the shirt attached to his body:

class TShirt_Sample extends TShirt_ColorBase {};

Details

Severity
Block
Resolution
Open
Reproducibility
Always
Operating System
Windows 10
Category
General
Steps To Reproduce

Use this simple mod to override the EquipCharacter function within the MissionServer class and test with and without the scripted class for the custom clothing item:

Event Timeline

Salutesh created this task.Sep 17 2020, 9:58 AM
Salutesh updated the task description. (Show Details)
Geez changed the task status from New to Assigned.Sep 17 2020, 4:38 PM
Salutesh updated the task description. (Show Details)Sep 17 2020, 4:49 PM
Salutesh updated the task description. (Show Details)
Salutesh added a comment.EditedSep 20 2020, 2:39 PM

Same issue exists for me when using "CreateAttachmentEx" with the correct InvetorySlot like for example:

m_player.GetInventory().CreateAttachmentEx("TShirt_Sample", InventorySlots.BODY);