gc8 970 Posted December 4, 2018 Hi I have a little tricky question about setVariable command which I hope the BIS developers can answer if no one else does. The question is what if I set the third parameter of the command to true so that the value is sent to all machines and keep setting the same value to the variable let's say 1. Will it keep sending that 1 over and over again as long as I call setVariable or does the command understand that value is already set and there's no need to update it over net? I think this is the way it should be to save bandwidth but I see there maybe point to send the updates too even the value remains the same. thx Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted December 4, 2018 31 minutes ago, gc8 said: Hi I have a little tricky question about setVariable command which I hope the BIS developers can answer if no one else does. The question is what if I set the third parameter of the command to true so that the value is sent to all machines and keep setting the same value to the variable let's say 1. Will it keep sending that 1 over and over again as long as I call setVariable or does the command understand that value is already set and there's no need to update it over net? I think this is the way it should be to save bandwidth but I see there maybe point to send the updates too even the value remains the same. thx Why would you even want to broadcast a variable update all the time? Besides that, this seems to be nonsensical since the getVariable command can already return a default value if the variable currently does not exist on the data type (if that's what you're trying to do). Of course using the third parameter as true will force a broadcast, since that's what the intended use of the third parameter is, broadcasting it to all machines. What are you trying to do, exactly? You could probably select all clients where the value differs from your preferred value and only broadcast to those: _allTrucks = [truck1,truck2,truck3]; _allTrucksFiltered = (_allTrucks select {_x getVariable ["TAG_fnc_someValue",1] != 1}) apply {owner _x};//will return owner ID array of all trucks with value != 1 _myTruck setVariable ["myLocalVariable", ["321", _var], _allTrucksFiltered]; Not tested, but could build from there. Cheers Share this post Link to post Share on other sites
gc8 970 Posted December 4, 2018 Here's example: _nearFob = _plr getVariable ["nearFriendlyFob",false]; if(!(_isNearFrienlyFob isEqualTo _nearFob)) then // Set only if not set yet { _plr setVariable ["nearFriendlyFob",_isNearFrienlyFob,true]; }; In the above code I want setVariable to be called only when the _isNearFrienlyFob is different from the "nearFriendlyFob" variable. This way it wont keep sending the same variable values all over again Share this post Link to post Share on other sites
HazJ 1288 Posted December 4, 2018 Assuming _plr is player then why use public argument at all? Doesn't seem like you will use it on any other machine. Share this post Link to post Share on other sites
gc8 970 Posted December 4, 2018 9 minutes ago, HazJ said: Assuming _plr is player then why use public argument at all? Doesn't seem like you will use it on any other machine. There's a reason for that :) The server has some data client does not and that's why I send the variables to client Share this post Link to post Share on other sites
HazJ 1288 Posted December 4, 2018 What is it you are trying to do? Share this post Link to post Share on other sites
gc8 970 Posted December 4, 2018 Not trying, I'm doing :) I'm checking if player is near FOB in the server and sending this true/false back to client. Because only server has the FOB location data Share this post Link to post Share on other sites
HazJ 1288 Posted December 4, 2018 What do you do with the check though? When they are near FOB do what else do? It would make sense just to have FOB loc data available on client too? Share this post Link to post Share on other sites
gc8 970 Posted December 4, 2018 Just now, HazJ said: What do you do with the check though? When they are near FOB do what else do? It would make sense just to have FOB loc data available on client too? If they are near FOB the players can buy gear and vehicles. I didn't want to put the FOB data to client because there are some variables that change in the FOB data so I would constantly have to send those variables to all clients. In this approach I send only those nearFob booleans Share this post Link to post Share on other sites
fn_Quiksilver 1633 Posted December 4, 2018 you might want this sort of structure _value = player getvariable 'variable'; // whatever the value currently is _targetvalue = blah; // whatever the value should be _propagate = !(_targetvalue isEqualTo _value); // only propagate the variable if the value is different from target value player setVariable ['variable',_targetvalue,_propagate]; 2 Share this post Link to post Share on other sites
Dedmen 2581 Posted December 4, 2018 2 hours ago, gc8 said: does the command understand that value is already set and there's no need to update it over net It can't know if the variable has been set to a different value on someone elses machine. So it has to resend either way to make sure that it's set to what you are expecting everywhere. Share this post Link to post Share on other sites
gc8 970 Posted December 4, 2018 5 minutes ago, Dedmen said: It can't know if the variable has been set to a different value on someone elses machine. true but I mean that the server checks if it has the exact same value set Share this post Link to post Share on other sites
fn_Quiksilver 1633 Posted December 4, 2018 3 minutes ago, gc8 said: true but I mean that the server checks if it has the exact same value set you could use a shared namespace, like "missionnamespace" or an object namespace of a global entity. in the above example in that case, just change "player" to "missionnamespace" Share this post Link to post Share on other sites
gc8 970 Posted December 4, 2018 7 minutes ago, fn_Quiksilver said: you could use a shared namespace, like "missionnamespace" or an object namespace of a global entity. in the above example in that case, just change "player" to "missionnamespace" Not sure what that would do? I'm just hoping answer to my original question :D Share this post Link to post Share on other sites
fn_Quiksilver 1633 Posted December 4, 2018 18 minutes ago, gc8 said: Not sure what that would do? I'm just hoping answer to my original question :D well your original question was pretty vague post a bit of code so we can see wha tyou mean Share this post Link to post Share on other sites
Dedmen 2581 Posted December 4, 2018 37 minutes ago, gc8 said: true but I mean that the server checks if it has the exact same value set nope. Checking if all clients have the same value would be just as expensive as just setting the value on all clients. Thus Arma is not doing that. And because of the reason I wrote above, it also cannot skip sending it if the value is set to the same value locally, because you don't know if that's also the case remotely. Share this post Link to post Share on other sites
gc8 970 Posted December 4, 2018 1 hour ago, Dedmen said: nope. Checking if all clients have the same value would be just as expensive as just setting the value on all clients. Thus Arma is not doing that. I was talking about the server 1 hour ago, Dedmen said: And because of the reason I wrote above, it also cannot skip sending it if the value is set to the same value locally, because you don't know if that's also the case remotely. Of course, that's logical but it could still refrain sending the already set variable (in server) again. Maybe some day we have fourth parameter for that. Well to answer my own question - had to be sure - I setup a test dedi mission and can confirm that server always sends the value even if it's already the same on server. So mystery solved :) Share this post Link to post Share on other sites