diff --git a/actions_on_button_press/README.md b/actions_on_button_press/README.md index d83c834..d810ea9 100644 --- a/actions_on_button_press/README.md +++ b/actions_on_button_press/README.md @@ -33,5 +33,6 @@ The player dies when pressing the button ## camera_switch_vote_on_button_press.gsc Allows the players to toggle their vote to change the `camera_thirdPerson` dvar on the server (players vote no by default) -When everyone votes yes the server changes the dvar and resets the vote counts. +When enough players vote yes the server changes the dvar and resets the vote counts. +The amount of votes required is more than 50% of the players: 1/1 | 2/2 | 3/4 | 3/5 | 4/6 etc. Bots are ignored for the votes. diff --git a/actions_on_button_press/camera_switch_vote_on_button_press.gsc b/actions_on_button_press/camera_switch_vote_on_button_press.gsc index 889e5fe..5d56cc6 100644 --- a/actions_on_button_press/camera_switch_vote_on_button_press.gsc +++ b/actions_on_button_press/camera_switch_vote_on_button_press.gsc @@ -94,9 +94,21 @@ DisplayVoteCount() } } - level.camera_switch_vote_count_text setText("^1Votes to switch camera: " + yes_votes + "/" + human_players.size); + votes_required = 0; - if (yes_votes == human_players.size && human_players.size > 0) + // Votes required = more than 50% of the players: 1/1 | 2/2 | 3/4 | 3/5 | 4/6 etc. + if (human_players.size % 2 == 1) + { + votes_required = (human_players.size / 2 + 0.5); + } + else if (human_players.size % 2 == 0) + { + votes_required = (human_players.size / 2 + 1); + } + + level.camera_switch_vote_count_text setText("^1Votes to switch camera: " + yes_votes + "/" + votes_required); + + if (yes_votes >= votes_required && human_players.size > 0) { // Logic here setDvar( "camera_thirdPerson", !getDvarInt( "camera_thirdPerson" ) );