OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: Mr.Peanut on 15 Jul 2010, 19:05:14

Title: publicVariable and object namespaces [solved]
Post 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?
Title: Re: publicVariable and object namespaces
Post by: Mandoble on 15 Jul 2010, 21:20:07
It dpends
if you used object setVariable ["xxx", 24, true];
then yes, last false/true means dont broadcast / broadcast.
Title: Re: publicVariable and object namespaces
Post by: kju on 16 Jul 2010, 08:13:36
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.
Title: Re: publicVariable and object namespaces
Post by: Mr.Peanut on 16 Jul 2010, 13:39:16
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...
Title: Re: publicVariable and object namespaces
Post by: kju on 16 Jul 2010, 14:01:04
what do you mean by that?

Quote
publicvariable event handler on the object
Title: Re: publicVariable and object namespaces
Post by: Mr.Peanut on 16 Jul 2010, 14:22:31
That,
Code: [Select]
myUnit setVariable ["paranoia",15,true]will cause
Code: [Select]
"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?
Title: Re: publicVariable and object namespaces
Post by: Loyalguard on 16 Jul 2010, 18:04:06
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):

Code: [Select]
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.
Title: Re: publicVariable and object namespaces
Post by: kju on 16 Jul 2010, 18:42:46
By value.
Title: Re: publicVariable and object namespaces
Post by: Mr.Peanut on 16 Jul 2010, 21:03:03
k. thanks. solved.