1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
private ["_exit","_name","_playerSlots","_refresh","_count","_reselect","_total","_selection","_selected","_selectedTeam",
"_lastVotes","_AI","_lastTeams","_lastTeam","_commanderTeam","_voteTime","_votes"];
_voteTime = WF_Logic getVariable Format ["%1CommanderVoteTime",sideJoinedText];
if (_voteTime <= 0) exitWith {};
_name = "";
_lastTeams = [];
_lastTeam = -2;
_lastVotes = [sideJoined] Call GetCommanderVotes;
while {true} do {
sleep 0.1;
if (!(alive player) || Side player != sideJoined) exitWith {CloseDialog 0;_exit = true};
if !(dialog) exitWith {};
_commanderTeam = [sideJoined] Call GetCommanderFromVotes;
if (IsNull _commanderTeam) then {_name = Localize "STR_WF_AI"} else {_name = name leader _commanderTeam};
_voteTime = WF_Logic getVariable Format ["%1CommanderVoteTime",sideJoinedText];
ctrlSetText [10007,Format ["(%1) %2: %3",_name,Localize "STR_WF_TimeLeft",_voteTime]];
if (_voteTime <= 0) exitWith {CloseDialog 0};
_refresh = false;
_playerSlots = [];
{
if !(isNil '_x') then {if (isPlayer (leader _x)) then {_playerSlots = _playerSlots + [_x]}};
} forEach clientTeams;
_count = 0;
_votes = [sideJoined] Call GetCommanderVotes;
{if (_x != (_votes Select _count)) then {_refresh = true};_count = _count + 1} ForEach _lastVotes;
{if !(_x In _lastTeams) then {_refresh = true}} ForEach _playerSlots;
{if !(_x In _playerSlots) then {_refresh = true}} ForEach _lastTeams;
if (_refresh) then {
_reselect = false;
_selected = lbCurSel 10006;
_selectedTeam = lbValue[10006,_selected];
_lastVotes = _votes;
if (_selected != -1) then {_reselect = true};
lbClear 10006;
_AI = lbAdd[10006,Format["%1 [%2]",_votes select 0,Localize "STR_WF_AI"]];
lbSetValue [10006,_AI,-1];
_count = 0;
_total = 1;
{
if !(isNil '_x') then {if (_x In _playerSlots) then {_total = _total + 1;_selection = lbAdd[10006,Format ["%1 %2",_votes select _count+1,name (leader _x)]];lbSetValue [10006,_selection,_count]}};_count = _count + 1;
} forEach clientTeams;
_lastTeams = +_playerSlots;
if (_reselect) then {
_selected = 0;
for [{_count = 0},{_count < _total},{_count = _count + 1}] do {if (lbValue[10006,_count] == _selectedTeam) then {_selected = _count}};
lbSetCurSel[10006,_selected];
};
};
_selected = lbCurSel 10006;
if (_selected != -1) then {
_selectedTeam = lbValue[10006,_selected];
if (_selectedTeam != _lastTeam) then {Call Compile Format["%1Team%2Vote = %3;publicVariable '%1Team%2Vote';",sideJoinedText,clientID,_selectedTeam]};
_lastTeam = _selectedTeam;
};
};
|