Page MenuHomeFeedback Tracker

Assigning global variable to object immediately after its creation doesn't make the variable global
Closed, ResolvedPublic

Description

If you create an object on the client and assign variable with global flag to it in the same frame, it will not make the variable global. Introducing delay with assignment solves the problem.

Details

Legacy ID
2044874407
Severity
None
Resolution
Fixed
Reproducibility
Always
Category
Multiplayer
Steps To Reproduce

start dedicated server
execute on client

obj = createVehicle ["C_Offroad_01_F", position player, [], 0, "NONE"];
obj setvariable ["myvar","test",true];
publicVariable "obj";

diconnect and reconnect:
hint str [obj getvariable "myvar"]; //[<null>]

delete vehicle:
deleteVehicle obj;

execute on client:

  • spawn {

obj = createVehicle ["C_Offroad_01_F", position player, [], 0, "NONE"];
sleep 0.1;
obj setvariable ["myvar","test",true];
publicVariable "obj";
}

diconnect and reconnect:
hint str [obj getvariable "myvar"]; //["test"]

Event Timeline

Killzone_Kid edited Additional Information. (Show Details)
Killzone_Kid set Category to Multiplayer.
Killzone_Kid set Reproducibility to Always.
Killzone_Kid set Severity to None.
Killzone_Kid set Resolution to Fixed.
Killzone_Kid set Legacy ID to 2044874407.May 7 2016, 5:55 PM
Killzone_Kid edited a custom field.
Bohemia added a subscriber: Dwarden.Feb 8 2014, 2:48 PM

Doesn't matter if vehicle is created on the client or server

Todays update "Fixed: Problem with setVariable command sending empty value"

Does not fix this issue.

Fank added a subscriber: Fank.May 7 2016, 5:55 PM
Fank added a comment.Mar 13 2014, 2:10 PM

It's very easy reproduceable:
use
setVariable ["test123", true];
on every building in the map for example Altis
and create a addaction that will only show if the variable test123 on the cursorTarget exist.
And ull see it will work sometimes.

@Fank your example has very little to do with this ticket. Map placed buildings are streamed, this is why setting variable on them is unreliable. I think this is mentioned onwiki somewhere too.

Edit...yeah, look at setvariable page on wiki, there is a note about it.

This seems to also happen on mission start during init phase (time = 0)

  • spawn {

waitUntil {time > 0}; //<- to make sure we passed init
obj = createVehicle ["C_Offroad_01_F", position player, [], 0, "NONE"];
obj setvariable ["myvar","test",true];
publicVariable "obj";
};

This of course is a workaround, real fix is needed.

This looks like a multiple cause problem.

The variable doesnt broadcast if time == 0
If var is assigned immediately it does broadcast but when object changes locality the variable stops broadcasting, unless it was not assigned immediately.

So in order for variable to broadcast reliably

it cannot be assigned during init (time == 0)
it cannot be assigned to object immediately after object creation

Please fix this already this is embarrassing!

seems fixed in latest dev

R3vo added a subscriber: R3vo.May 7 2016, 5:55 PM
R3vo added a comment.Sep 21 2014, 11:12 PM

Wow, I was searching for mistake in my script, and now I see it was a bug afterall...

Mass-closing all resolved issues not updated in the last month.

Please PM me in BI Forums (http://forums.bistudio.com/member.php?55374-Fireball) if you feel your bug was closed in error.