home *** CD-ROM | disk | FTP | other *** search
- /*
- **
- ** _vote.qc (Vote Code, 1.0)
- **
- ** Copyright (C) 1996 Johannes Plass
- **
- ** This program is free software; you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation; either version 2 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program; if not, write to the Free Software
- ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- **
- ** Author: Johannes Plass (plass@dipmza.physik.uni-mainz.de)
- **
- */
-
- void(entity player) VoteInfo =
- {
- if (!USE_MODULE_VOTE) return;
-
- // 123456789#123456789#123456789#12345678
- sprint(player,"# Vote: decide by voting.\n");
- sprint(player," Type 'help-vote' for help.\n");
- };
-
- void(entity player) VoteInit =
- {
- if (!USE_MODULE_VOTE) return;
-
- stuffcmd(player,"alias help-vote \"impulse 211\";\n");
- if (USE_SUBMODULE_VOTE_EXIT) {
- stuffcmd(player,"alias vote-exit \"impulse 212\";\n");
- }
- if (USE_SUBMODULE_VOTE_EXIT) {
- stuffcmd(player,"alias vote-exitrules \"impulse 213\";\n");
- }
- };
-
- void(entity player) VoteHelp =
- {
- if (!USE_MODULE_VOTE) return;
-
- if ( !USE_SUBMODULE_VOTE_EXIT
- && !USE_SUBMODULE_VOTE_EXITRULES) //#jp#(ExitRules)
- return;
-
- // 123456789#123456789#123456789#12345678
- sprint(player,"# Vote: vote via one of the commands\n");
- VoteExitHelp(player);
- VoteExitRulesHelp(player); //#jp#(ExitRules)
- };
-
- float() VoteCheckVotes =
- {
-
- if (!USE_MODULE_VOTE) {
- vote_checktime = vote_checktime + 500000;
- return(0);
- }
- if (!vote_checktime) {
- vote_checktime = time + 30;
- return(0);
- }
- vote_checktime = vote_checktime + 10;
-
- if ( !USE_SUBMODULE_VOTE_EXIT
- && !USE_SUBMODULE_VOTE_EXITRULES) //#jp#(ExitRules)
- return(0);
-
- // dprint("VoteCheckVotes: executing\n");
- {
- local float n_exitrules,n_exit,p;
- local entity e;
- e = find(world, classname, "player");
- p = n_exitrules = n_exit = 0;
- while (e) {
- if (e.deadflag != DEAD_DEAD) {
- n_exitrules = n_exitrules + e.vote_exitrules;
- n_exit = n_exit + e.vote_exit;
- p = p + 1;
- }
- e = find(e, classname, "player");
- }
- if (p && n_exit && (n_exit >= p * 0.5)) {
- VoteExitExit();
- return(1);
- }
- if (p && n_exitrules && (n_exitrules >= p * 0.5)) {//#jp#(ExitRules)
- VoteExitRulesDisable(); //#jp#(ExitRules)
- return(1); //#jp#(ExitRules)
- } //#jp#(ExitRules)
- return(0);
- }
- };
-
- /*
- ===============================================================
- Voting for exiting immediately
- ===============================================================
- */
-
- void(entity player) VoteExitHelp =
- {
- if (!USE_MODULE_VOTE) return;
- if (!USE_SUBMODULE_VOTE_EXIT) return;
- // 123456789#123456789#123456789#12345678
- sprint(player," vote-exit: the majority may decide\n");
- sprint(player," to exit the level immediately.\n");
- };
-
- void(entity player) VoteExitVote =
- {
- if (!USE_MODULE_VOTE) return;
- if (!USE_SUBMODULE_VOTE_EXIT) return;
-
- // voting is not sensible on startlevel
- if (world.model == "maps/start.bsp") {
- // 123456789#123456789#123456789#12345678
- sprint(player,"Voting for exiting not possible on\nthe start level.\n");
- return;
- }
-
- if (player.vote_exit) {
- player.vote_exit = 0;
- sprint(player,"Vote against exiting accepted\n");
- } else {
- player.vote_exit = 1;
- sprint(player,"Vote for exiting accepted\n");
- }
- };
-
- void() VoteExitExit =
- {
- if (!USE_MODULE_VOTE) return;
- if (!USE_SUBMODULE_VOTE_EXIT) return;
- bprint ("The majority decided to exit.\n");
- if (USE_MODULE_SERVERCONSOLE) { //#jp#(ServerConsole)
- dprint ("The majority decided to exit.\n"); //#jp#(ServerConsole)
- } //#jp#(ServerConsole)
- NextLevel();
- };
-
- /*
- ===============================================================
- Voting for disabling ExitRules
- //#jp#(ExitRules)
- ===============================================================
- */
-
- void(entity player) VoteExitRulesHelp =
- {
- if (!USE_MODULE_VOTE) return;
- if (!USE_SUBMODULE_VOTE_EXIT) return;
- // 123456789#123456789#123456789#12345678
- sprint(player," vote-exitrules: the majority may \n");
- sprint(player," disable the current ExitRules.\n");
- };
-
- void(entity player) VoteExitRulesVote =
- {
- if (!USE_MODULE_VOTE) return;
- if (!USE_MODULE_EXITRULES) return;
- if (!USE_SUBMODULE_VOTE_EXITRULES) return;
-
- if (!exitrules_inited) { ExitRulesSetValues(); }
- if ( exitrules_status != EXITRULES_STATUS_TIGHT
- || world.model == "maps/start.bsp") {
- // 123456789#123456789#123456789#12345678
- sprint(player,"ExitRules are disbled on this level,\nvoting is not necessary.");
- return;
- }
- // 123456789#123456789#123456789#12345678
- sprint(player,"Vote for disabling ExitRules accepted\n");
- player.vote_exitrules = 1;
- };
-
- void() VoteExitRulesDisable =
- {
- // dprint("VoteExitRulesDisable: executing\n");
- if (!USE_MODULE_EXITRULES) return;
- if (!USE_SUBMODULE_VOTE_EXITRULES) return;
- if (!exitrules_inited) { ExitRulesSetValues(); }
- if (exitrules_status != EXITRULES_STATUS_TIGHT) return;
-
- // 123456789#123456789#123456789#12345678
- bprint ("The majority disbled ExitRules, you\nmay exit at any time.\n");
- if (USE_MODULE_SERVERCONSOLE) { //#jp#(ServerConsole)
- dprint ("The majority disabled ExitRules.\n"); //#jp#(ServerConsole)
- } //#jp#(ServerConsole)
- exitrules_status = EXITRULES_STATUS_SOFT;
- };
-
-