OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: Mr.Peanut on 15 Jul 2010, 19:05:14
-
Are the contents of an object's namespace sent when the object is broadcast with publicVariable? Or does the namespace remain local to the object?
-
It dpends
if you used object setVariable ["xxx", 24, true];
then yes, last false/true means dont broadcast / broadcast.
-
No it does not transfer the complete namespace - from what I know.
As mando says, you need to setVar public each variable on your own.
-
I see. I did not know that option for broadcasting existed. I presume the default would be "False"?
Next question. If broadcast is set to "True" will a publicvariable event handler on the object pick up the change? Suspect yes...
-
what do you mean by that?
publicvariable event handler on the object
-
That,
myUnit setVariable ["paranoia",15,true]
will cause
"myUnit" addPublicVariableEventHandler {hint str(_this select 1)};
to fire (on other clients).
BTW. Is the _this select 1 in the addPublicVariableEventHandler passed by reference or value?
-
As far as I can tell, using setVariable with true for public broadcast will NOT fire a PVEH. You would probably have to run a separate monitoring loop script to check for changes. Example (untested):
while {true} do
{
_cur = myUnit getVariable "paranoia";
waitUntil {_cur != (myUnit getVariable "paranoia")};
hint str(myUnit getVariable "paranoia");
sleep .01;
};
Not sure if still relevant, but with addPublicVariableEventHandler, _this select 0 always refer to the name of the variable, _this select 1 is always the value of the variable.
-
By value.
-
k. thanks. solved.