From c055d44dcdb87e8db49fb23e632fc086aa44cce6 Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 11 Jun 2026 19:53:22 +0300 Subject: init --- Common/Functions/Common_GetCommanderFromVotes.sqf | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Common/Functions/Common_GetCommanderFromVotes.sqf (limited to 'Common/Functions/Common_GetCommanderFromVotes.sqf') diff --git a/Common/Functions/Common_GetCommanderFromVotes.sqf b/Common/Functions/Common_GetCommanderFromVotes.sqf new file mode 100644 index 0000000..c0210f6 --- /dev/null +++ b/Common/Functions/Common_GetCommanderFromVotes.sqf @@ -0,0 +1,36 @@ +Private["_AI","_commander","_count","_highest","_highestTeam","_side","_teams","_tie","_total","_vote","_votes"]; + +_side = _this Select 0; + +_AI = 0; +_teams = (Format["WFBE_%1TEAMS",str _side] Call GetNamespace); +_total = Count _teams; + +_votes = []; +for [{_count = 0},{_count < _total},{_count = _count + 1}] do {_votes = _votes + [0]}; + +//Count votes. +for [{_count = 0},{_count < _total},{_count = _count + 1}] do { + if (isPlayer (leader (_teams Select _count))) then { + _vote = Call Compile Format ["%1Team%2Vote",Str _side,_count + 1]; + if (_vote != -1) then { + _votes Set[_vote,(_votes Select _vote) + 1]; + } else { + _AI = _AI + 1; + }; + }; +}; + +_count = 0; +_highest = 0; +_highestTeam = -1; +_tie = false; +{if (_x == _highest && _x > 0) then {_tie = true};if (_x > _highest) then {_highestTeam = _count;_highest = _x;_tie = false};_count = _count + 1} ForEach _votes; + +_commander = ObjNull; + +if (!_tie && _highest > _AI && _highestTeam != -1) then { + _commander = _teams select _highestTeam; +}; + +_commander \ No newline at end of file -- cgit v1.3.1