Skip to content

Commit b14779a

Browse files
committed
rtv: add ignore spectators votes
1 parent 287674e commit b14779a

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

cstrike/addons/amxmodx/configs/map_manager.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ mapm_rtv_allow_extend "0"
214214

215215
// EN: Ignores spectators when counting required votes for RTV.
216216
// RU: Игнорирует спектаторов в подсчете необходимых голосов для ртв.
217-
// 0 - disable, 1 - enable
217+
// 0 - disable, 1 - ignore as count, 2 - ignore as vote
218218
mapm_rtv_ignore_spectators "0"
219219

220220

cstrike/addons/amxmodx/scripting/map_manager_rtv.sma

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#endif
88

99
#define PLUGIN "Map Manager: Rtv"
10-
#define VERSION "0.1.5"
10+
#define VERSION "0.1.6"
1111
#define AUTHOR "Mistrick"
1212

1313
#pragma semicolon 1
@@ -35,6 +35,11 @@ enum {
3535
MODE_PLAYERS
3636
};
3737

38+
enum {
39+
IGNORE_SPECTATORS_COUNT = 1,
40+
IGNORE_SPECTATORS_FULL
41+
};
42+
3843
new g_pCvars[Cvars];
3944
new g_iMapStartTime;
4045
new bool:g_bVoted[33];
@@ -104,11 +109,33 @@ public clcmd_rtv(id)
104109
g_iVotes++;
105110
}
106111

112+
new current_votes = 0;
113+
114+
new ignore_spec = get_num(IGNORE_SPECTATORS);
115+
if(ignore_spec == IGNORE_SPECTATORS_FULL) {
116+
new team;
117+
for(new i = 1; i < sizeof(g_bVoted); i++) {
118+
if(!g_bVoted[i] || !is_user_connected(i))
119+
continue;
120+
121+
team = get_user_team(i);
122+
if(team == 1 || team == 2) {
123+
current_votes++;
124+
}
125+
}
126+
team = get_user_team(id);
127+
if(!g_bVoted[id] && (team == 1 || team == 2)) {
128+
current_votes++;
129+
}
130+
} else {
131+
current_votes = g_iVotes;
132+
}
133+
107134
new need_votes;
108135
if(get_num(MODE) == MODE_PERCENTS) {
109-
need_votes = floatround(get_players_num(get_num(IGNORE_SPECTATORS) ? -1 : 0) * get_num(PERCENT) / 100.0, floatround_ceil) - g_iVotes;
136+
need_votes = floatround(get_players_num(ignore_spec ? -1 : 0) * get_num(PERCENT) / 100.0, floatround_ceil) - current_votes;
110137
} else {
111-
need_votes = min(get_num(PLAYERS), get_players_num(get_num(IGNORE_SPECTATORS) ? -1 : 0)) - g_iVotes;
138+
need_votes = min(get_num(PLAYERS), get_players_num(ignore_spec ? -1 : 0)) - current_votes;
112139
}
113140

114141
if(need_votes <= 0) {

0 commit comments

Comments
 (0)