thy_ 183 Posted January 8 I'm sure there's a smarter and maybe lighter way to broadcast organized data (as in this case, in arrays) that will change during the game! (from 0 to 10 times, but probably never 20 times per side in multiplayer games. For single-player this number is reduced drastically, around 0-2) Can you suggest a better way to broadcast the example seen through both functions below? THY_fnc_bananasCounter = { params [...]; private [...]; // Initial values: _cntr = []; // Addressing each side-array in THY_allBananas = [[blu], [opf], [ind], [civ]] = [[0],[0],[0],[0]] switch (side _player) do { case BLUFOR: { _cntr = THY_allBananas # 0 }; case OPFOR: { _cntr = THY_allBananas # 1 }; case INDEPENDENT: { _cntr = THY_allBananas # 2 }; case CIVILIAN: { _cntr = THY_allBananas # 3 }; }; // Increasing the side amount: if (...) then { _cntr = [(_cntr # 0) + 1]; }; switch (side _player) do { case BLUFOR: { THY_allBananas = [_cntr, THY_allBananas # 1, THY_allBananas # 2, THY_allBananas # 3] }; case OPFOR: { THY_allBananas = [THY_allBananas # 0, _cntr, THY_allBananas # 2, THY_allBananas # 3] }; case INDEPENDENT: { THY_allBananas = [THY_allBananas # 0, THY_allBananas # 1, _cntr, THY_allBananas # 3] }; case CIVILIAN: { THY_allBananas = [THY_allBananas # 0, THY_allBananas # 1, THY_allBananas # 2, _cntr] }; }; // Broadcasting the new value: publicVariable "THY_allBananas"; // Return: true }; THY_fnc_reportingBananasAmount = { params [...]; private [...]; // Initial values: _cntr = []; // Addressing each side-array in THY_allBananas = [[blu], [opf], [ind], [civ]] = [[0],[0],[0],[0]] switch (side _player) do { case BLUFOR: { _cntr = THY_allBananas # 0 }; case OPFOR: { _cntr = THY_allBananas # 1 }; case INDEPENDENT: { _cntr = THY_allBananas # 2 }; case CIVILIAN: { _cntr = THY_allBananas # 3 }; }; // Showing the bananas amount by side: systemChat format ["The %1 side has %2 banana(s) available!", side _player, _cntr # 0]; // Return: true }; I tried the setVariable / getVariable logic, but I'm unsure if it would work like that or if I'm tripping because I don't understand Namespaces yet. Spoiler // SOMEWHERE ELSE? missionNamespace setVariable ["THY_bananasBLU", 0, true]; missionNamespace setVariable ["THY_bananasOPF", 0, true]; missionNamespace setVariable ["THY_bananasIND", 0, true]; missionNamespace setVariable ["THY_bananasCIV", 0, true]; THY_fnc_bananasCounter = { params [...]; private [...]; //??????? // Return: true }; THY_fnc_reportingBananasAmount = { params [...]; private [...]; //??????? // Return: true }; Share this post Link to post Share on other sites
pierremgi 4944 Posted January 8 if isServer then { missionNameSpace setVariable ["THY_bananas",createHashMapFromArray [[WEST, 0], [EAST,0], [INDEPENDENT, 0],[CIVILIAN,0]],TRUE]; }; This initialize hashmap of 4 counters for 4 sides from server (and not by each JIP clients) In game for some condition (and repeatable loop)... If (somethingTrue) then { private _hashCounter = missionNameSpace getVariable "THY_bananas"; _hashCounter set [side player, (_hashCounter get side player) +1]; missionNameSpace setVariable ["THY_bananas", _hashCounter,TRUE]; hint str (missionNameSpace getVariable "THY_bananas"); }; 1 1 Share this post Link to post Share on other sites
thy_ 183 Posted January 8 2 hours ago, pierremgi said: (...) This initialize hashmap of 4 counters for 4 sides from server (and not by each JIP clients) If (somethingTrue) then { private _hashCounter = missionNameSpace getVariable "THY_bananas"; _hashCounter set [side player, (_hashCounter get side player) +1]; missionNameSpace setVariable ["THY_bananas", _hashCounter,TRUE]; hint str (missionNameSpace getVariable "THY_bananas"); }; What a great command this createHashMapFromArray. And I didn't know about the get command either. This will help me A LOT. Share this post Link to post Share on other sites