ArtVandelay 1 Posted October 15, 2013 (edited) I don't have a proper dedicated server or enough friends to help me test, so I thought I'd better ask. How often is too often to synchronise a public variable? Eg.: while {true} do { ... ... ... MyVehicle = true; publicVariable "MyVehicle"; ... ... sleep 1; }; I'm pretty sure that is far too often and the server would chug along for the entire mission. If so, what would the minimum value for the sleep? I ask because some code that can only be run by the server is needed to update some HUD information for clients. Thanks, -Art Edited October 15, 2013 by ArtVandelay Share this post Link to post Share on other sites
kylania 568 Posted October 15, 2013 Is that value likely to change every second, if not, why are you looping it? If it something like current vehicle, well there's already an engine command for that. Would you be able to replace the variable loop with waitUntils instead? Does everyone need to know the value of that, if not why not use publicVariableServer instead? For your HUD stuff the server can use publicVariableClient to pass data just to the one client since it's UI that's all that needs to know. Share this post Link to post Share on other sites
ArtVandelay 1 Posted October 15, 2013 Thanks for responding. That code was just an example (and probably not the best one to give) the real thing is: while {true} do { _westCount = [_territory, west] call fnc_playerCount; _eastCount = [_territory, east] call fnc_playerCount; switch (true) do { case (_westCount > _eastCount): { sleep 1; _westCount = [_territory, west] call fnc_playerCount; _eastCount = [_territory, east] call fnc_playerCount; _rate = BaseCapRate * (_westCount - _eastCount); _cap = TerritoryArray select _territory; TerritoryArray set [_territory, (_cap + _rate)]; if (((getMarkerColor _marker) != "ColorGreen") AND {(TerritoryArray select _territory) >= 50}) then { if ((StatusArray select _territory) == "OPFOR") then { EastTerritories = EastTerritories - 1; _eastRespawn = format ["respawn_east_%1", _territory]; deleteMarker _eastRespawn; }; _marker setMarkerBrush "DiagGrid"; _marker setMarkerColor "ColorGreen"; StatusArray set [_territory, "NEUTRAL"]; publicVariable "StatusArray"; }; }; case(_westCount < _eastCount): { sleep 1; _westCount = [_territory, west] call fnc_playerCount; _eastCount = [_territory, east] call fnc_playerCount; _rate = BaseCapRate * (_westCount - _eastCount); _cap = TerritoryArray select _territory; TerritoryArray set [_territory, (_cap + _rate)]; if (((getMarkerColor _marker) != "ColorGreen") AND {(TerritoryArray select _territory) <= 50}) then { if ((StatusArray select _territory) == "BLUFOR") then { WestTerritories = WestTerritories - 1; _westRespawn = format ["respawn_west_%1", _territory]; deleteMarker _westRespawn; }; _marker setMarkerBrush "DiagGrid"; _marker setMarkerColor "ColorGreen"; StatusArray set [_territory, "NEUTRAL"]; publicVariable "StatusArray"; }; }; case ((_westCount != 0) AND (_westCount == _eastCount)): { _equal = true; }; //If no players present and the territory is neutral case (((StatusArray select _territory) == "NEUTRAL") AND (_westCount == 0) AND (_eastCount == 0)): { _neutral = true; }; }; if ((TerritoryArray select _territory) >= 100) exitWith {[_territory, west] spawn territoryCapped}; if ((TerritoryArray select _territory) <= 0) exitWith {[_territory, east] spawn territoryCapped}; if (_equal) exitWith { [_territory] spawn capTerritory; //diag_log format ["TERRITORIES - Player count is equal at Territory %1. BLUFOR: %2, OPFOR: %3", _territory, _westCount, _eastCount]; }; if (_neutral) exitWith { [_territory] spawn fnc_returnToNeutral; [_territory, _triggerType] spawn createTrg; //diag_log format ["TERRITORIES - All players are dead or left Territory %1 at the same time, creating a new trigger", _territory]; }; }; Yeah problem is, everyone in the area needs to know the current value of TerritoryArray select _territory, to update the capture progress on their HUD. I was thinking of adding publicVariable "TerritoryArray". If spamming publicVariable once per second is far, far too often then I'll have to rethink how to go about updating the HUD. Thanks, -Art Share this post Link to post Share on other sites
iceman77 18 Posted October 15, 2013 (edited) Why not broadcast the score / capture meter update every 10 or so seconds instead? Edited October 15, 2013 by Iceman77 Share this post Link to post Share on other sites
Tajin 349 Posted October 15, 2013 Depends on the size of the variable, once per second shouldn't really be a problem in your case. Share this post Link to post Share on other sites
dmarkwick 261 Posted October 15, 2013 Couldn't you monitor the variable and broadcast it when it's different? Share this post Link to post Share on other sites
Tajin 349 Posted October 15, 2013 That, or you only send the changed values instead of the whole array. Share this post Link to post Share on other sites
Hypnomatic 10 Posted October 15, 2013 Don't have a lot of first-hand testing/experience on the matter, but this ticket did raise a concern that you may need to take into account: http://feedback.arma3.com/view.php?id=15391 Basically, it claims that arrays have a fairly large overhead when broadcasted via publicVariable. Haven't had time to verify/test for myself, so I don't know how the overhead scales with bigger arrays and such, but it's worth keeping in mind. Bit pressed for time at the moment, so I can't offer a super-proper response now, but I'll look again later. Share this post Link to post Share on other sites
ArtVandelay 1 Posted October 18, 2013 (edited) Thanks for the responses, considering the network load sending only the changed variable is probably the better idea. Thanks to all of you again Edited October 18, 2013 by ArtVandelay Share this post Link to post Share on other sites