Jump to content
gc8

Detect object variable change

Recommended Posts

Hi

Is it possible to know when variable set to an object is changed in another machine? For example server sets global variable on player and client needs to know when it has changed?

 

I mean this:

 

_player setVariable ["test", 123, true]; // On server

 

With public variables it would be possible to detect the change with addPublicVariableEventHandler but what about these object variables?

 

I could make a loop on client to detect the change but that wouldn't be ideal.

 

thx!

 

Share this post


Link to post
Share on other sites

afaik it's not possible this way.

2 alternative options:

1. use a missionnamespace variable and publish it and then detect its change with the event handler.

2. u could use remoteExec and remotely execute whatever should be executed on variable change. (maybe u don't need the entire setVariable thing then)

Share this post


Link to post
Share on other sites
14 minutes ago, sarogahtyp said:

1. use a missionnamespace variable and publish it and then detect its change with the event handler.

2. u could use remoteExec and remotely execute whatever should be executed on variable change. (maybe u don't need the entire setVariable thing then)

 

ideally I would want to have stacked event handler for the variable change because I need the value of the variable in multiple GUIs and need to update the current GUI when the variable changes

Share this post


Link to post
Share on other sites

I think u could do that with remoteExec and setVariable. no need for an event handler:

 // On server
_player setVariable ["test", 123, true];
remoteExec ["UpdateYourGUIs", _player];

 

Share this post


Link to post
Share on other sites
3 minutes ago, sarogahtyp said:

I think u could do that with remoteExec and setVariable. no need for an event handler:


 // On server
_player setVariable ["test", 123, true];
remoteExec ["UpdateYourGUIs", _player];

 

 

Maybe, but that reminds me of one problem. how do you know variable "test" is updated by the time remoteExec function is called on client?

could just pass the variable needed as argument though...

 

Share this post


Link to post
Share on other sites
4 minutes ago, gc8 said:

could just pass the variable needed as argument though...

this ;-)

Share this post


Link to post
Share on other sites

Imho, the "public"  _player setVariable ["test", 123, true]; is the only thing to keep on mind. And probably conceived to make it smart and light for networks.

There are so much causes to load the network, if you can skip another useless remoteExec...

So, yes a simple test in a loop, local on client of course, is the best thing to do.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×