Page MenuHomeFeedback Tracker

uniformContainer / vestContainer / backpackContainer return nil
Closed, ResolvedPublic


Hello there,

I have encountered a problem where uniformContainer / vestContainer / backpackContainer *sometimes* return nil. What I do is to add a uniform, vest or backpack to a player object and then get the new container.

The weird thing is, that it works a couple of times without problems, but later in the game it just returns nil. It does not seem to be related to the player object, as this one is fine :)

What can I do?


Legacy ID
Steps To Reproduce

player forceAddUniform "U_B_FullGhillie_lsh";
_uniformContainer = uniformContainer player;

if (isNil "_uniformContainer") then
diag_log "Oh noes!";

Event Timeline

Eichi edited Steps To Reproduce. (Show Details)Jul 24 2015, 2:13 PM
Eichi set Category to Scripting.
Eichi set Reproducibility to Sometimes.
Eichi set Severity to None.
Eichi set Resolution to Fixed.
Eichi set Legacy ID to 1355317495.May 8 2016, 12:26 PM
Grim added a subscriber: Grim.May 8 2016, 12:26 PM
Grim added a comment.Jul 24 2015, 2:15 PM

Putting a "uiSleep 0.1" between it fixes it.

but thats a hack that i really dont want to resort to

Adam added a comment.Jul 27 2015, 1:19 PM

If you are going call a command on non-local unit, then the command needs to go through server to the owner of the unit and then the command gets triggered. So uiSleep is not that big of a hack ;)

Are you calling AddUniform on soldier that is local? If not then there is not much we can do unfortunately.

Eichi added a subscriber: Eichi.May 8 2016, 12:26 PM
Eichi added a comment.Jul 27 2015, 1:54 PM

Yes, the unit is of course local :)

Adam added a comment.Jul 27 2015, 2:26 PM

If the unit is local then the repro should be 100% am i right?

Eichi added a comment.Jul 27 2015, 2:35 PM

Unfortunately, it isnt. This makes things a little more complicated. This only happens after the server has been up for some time. The code is running purely server side. I can send you a log file if you want to.

Server side and unit is local? So you're speaking about direct hosting(no dedicated server)?

Eichi added a comment.Jul 27 2015, 4:10 PM

It is a dedicated server. The unit is created on the server and then additional gear is added, thus the unit is local.

Just a thought beside that: Why should a function ever return nil? That just does not sound right to me :)

well If your repro is valid and if you run it under Dedicated server so its obvious that you will get nil. Just because command player should return null-object on dedi

Eichi added a comment.Jul 27 2015, 8:23 PM

I am not sure if I got you. I am not using the player command. The above snippet is from client code, where the same problem occurs. To reproduce it regardless of peer type, use createUnit + forceAddUniform + uniformContainer.

look I'm trying to help, but its way difficult due to a lack of good clue. Repro doesn't say if your problem is related to MP or SP. Then you said something about server side.. well okay server side scripts can't use player(it always returns null-object), so we have a solution.. but now you're speaking about client code. Quite confusing, isn't? Please can you attach your log? Maybe it will help

let me give you an insider advice(just two cents): better repro we get --> bigger chance to add problem into our TODO list ;-)

DEV. 131649(will be distributed tomo)
I changed xxxContainer commands. Now their returns valid object or nullObject when failed. So you can use something like:
player forceAddUniform "U_B_FullGhillie_lsh";
waitUntil {!isNull uniformContainer player};

there is no other easy way how manage it

Eichi added a comment.Jul 28 2015, 3:29 PM

@japa: I thought this is a general problem, but if it is system architecture related, let me describe what I do:

It runs in a dedicated server. The code is invoked in non-scheduled environment to run as fast as possible. It is used to load player gear from a database. The server creates a new unit to spawn a player object. Then it adds uniform, vest and backpack to the new player object. After that, it populates the content of these containers.

This works fine 90% of the time, but *sometimes* uniformContainer/backpackContainer/vestContainer return nil.

Here is an overview of what it does:

_group = createGroup independent;

_player = _group createUnit ["Exile_Unit_Player", _position, [], 0, "CAN_COLLIDE"];
_player setDir _direction;
_player setPosATL _position;
_player disableAI "FSM";
_player disableAI "MOVE";
_player disableAI "AUTOTARGET";
_player disableAI "TARGET";

// [...]

_player forceAddUniform _uniform;
_uniformContainer = uniformContainer _player;

if (isNil "_uniformContainer") then
// Here is the problem

I dont understand how or why it can fail if you get the container right after you created it.

Using waitUntil is maybe a bit problematic in non-scheduled environment :)

You probably exceed 144 groups, so no unit is created

"Using waitUntil is maybe a bit problematic in non-scheduled environment :)"


Eichi added a comment.Jul 28 2015, 8:08 PM

@KK: This was my thinking too. But according to the docs: "In Arma 3 when last unit leaves a group, the group gets auto deleted." it should not be the case. I have added a lot of debug logging and the unit is there. Everything works fine, except the container functions returning nil.

I think autodeletion is bugged, may fail occasionally

always check

_group = createGroup independent;
if (isNull _group) exitWith {error};

Doesn't return nil anymore