Nagger_VoteCountChanged();
// add up all the votes from each connected client
- FOREACH_CLIENT(IS_REAL_CLIENT(it) && IS_CLIENT(it), {
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
++vote_player_count;
- if (IS_PLAYER(it)) ++vote_real_player_count;
+ if (IS_PLAYER(it) || INGAME(it)) ++vote_real_player_count;
switch (it.vote_selection)
{
case VOTE_SELECT_REJECT:
- { ++vote_reject_count;
- { if (IS_PLAYER(it)) ++vote_real_reject_count; } break;
- }
+ ++vote_reject_count;
+ if (IS_PLAYER(it) || INGAME(it)) ++vote_real_reject_count;
+ break;
case VOTE_SELECT_ACCEPT:
- { ++vote_accept_count;
- { if (IS_PLAYER(it)) ++vote_real_accept_count; } break;
- }
+ ++vote_accept_count;
+ if (IS_PLAYER(it) || INGAME(it)) ++vote_real_accept_count;
+ break;
case VOTE_SELECT_ABSTAIN:
- { ++vote_abstain_count;
- { if (IS_PLAYER(it)) ++vote_real_abstain_count; } break;
- }
+ ++vote_abstain_count;
+ if (IS_PLAYER(it) || INGAME(it)) ++vote_real_abstain_count;
+ break;
default: break;
}
});
print_to(caller, strcat("You can call a vote for or execute these commands: ^3", autocvar_sv_vote_commands, "^7 and maybe further ^3arguments^7"));
}
+bool VoteCommand_checkclients()
+{
+ float c = 0, nc = 0;
+ FOREACH_CLIENT(true,
+ {
+ //if(!IS_DISCONNECTED_CLIENT(it)) c++;
+ if(!IS_BOT_CLIENT(it)) c++; // test code, counts bots as unconnected
+ else nc++;
+ });
+ LOG_INFOF("^x8f0 %d / %d\n", c, nc);
+ if (!nc)
+ return false;
+ // if true vote is not allowed
+ // connessi 2 non connessi 1 false allowed
+ // connessi 3 non connessi 1 false allowed
+ // connessi 2 non connessi 2 true not allowed
+ // connessi 3 non connessi 2 true not allowed
+ // connessi 5 non connessi 3 true not allowed
+ // connessi 5 non connessi 2 false allowed
+ // if the not connected are half or less
+ return (c < nc * 2);
+}
+
void VoteCommand_call(int request, entity caller, int argc, string vote_command) // BOTH
{
switch (request)
{
print_to(caller, "^1Vote calling is not allowed before the match has started.");
}
+ else if (time < 10) // test, change to 4 or somthing
+ {
+ print_to(caller, "^1Vote calling is not allowed in the very first seconds of the game.");
+ }
else if (vote_called)
{
print_to(caller, "^1There is already a vote called.");
{
print_to(caller, "^1Only players can call a vote.");
}
+ else if (VoteCommand_checkclients())
+ {
+ print_to(caller, "^1Too many unconnected clients.");
+ }
else if (caller && !IS_CLIENT(caller))
{
print_to(caller, "^1Only connected clients can vote.");