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.
Description
Details
- Legacy ID
- 2044874407
- Severity
- None
- Resolution
- Fixed
- Reproducibility
- Always
- Category
- Multiplayer
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
Todays update "Fixed: Problem with setVariable command sending empty value"
Does not fix this issue.
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!
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.