2 string ValidateMap(string vote);
3 void(entity e) DropFlag;
4 string MapVote_Suggest(string m);
6 .float floodcontrol_chat;
7 .float floodcontrol_team;
8 void Say(entity source, float teamsay, string msgin)
10 string msgstr, colorstr, cmsgstr, namestr;
15 if(substring(msgin, 0, 1) == " ")
16 msgin = substring(msgin, 1, strlen(msgin) - 1); // work around DP say bug (say_team does not have this!)
18 msgin = formatmessage(msgin);
23 if(source.classname != "player")
24 colorstr = "^0"; // black for spectators
26 colorstr = Team_ColorCode(source.team);
30 if(intermission_running)
34 * using bprint solves this... me stupid
35 // how can we prevent the message from appearing in a listen server?
36 // for now, just give "say" back and only handle say_team
39 clientcommand(self, strcat("say ", msgin));
44 if(cvar("g_chat_teamcolors"))
45 namestr = playername(source);
47 namestr = source.netname;
50 msgstr = strzone(strcat("\{1}\{13}", colorstr, "(^3", namestr, colorstr, ") ^7", msgin, "\n"));
51 cmsgstr = strcat(colorstr, "(^3", namestr, colorstr, ")\n^7", wordwrap(msgin, 50));
54 msgstr = strzone(strcat("\{1}", namestr, "^7: ", msgin, "\n"));
62 var .float flood_field;
66 flood_spl = cvar("g_chat_flood_spl_team");
67 flood_burst = cvar("g_chat_flood_burst_team");
68 flood_lmax = cvar("g_chat_flood_lmax_team");
69 flood_field = floodcontrol_team;
73 flood_spl = cvar("g_chat_flood_spl");
74 flood_burst = cvar("g_chat_flood_burst");
75 flood_lmax = cvar("g_chat_flood_lmax");
76 flood_field = floodcontrol_chat;
78 flood_burst = max(0, flood_burst - 1);
79 // to match explanation in default.cfg, a value of 3 must allow three-line bursts and not four!
80 lines = ceil(strlennocol(msgstr) / 75);
81 if(flood_lmax && lines > flood_lmax)
83 else if(time >= self.flood_field)
84 self.flood_field = max(time - flood_burst * flood_spl, self.flood_field) + lines * flood_spl;
91 if(cvar("g_chat_flood_notify_flooder"))
94 sprint(self, strcat("^3FLOOD CONTROL: ^7wait ^1", ftos(self.flood_field - time), "^3 seconds\n"));
96 sprint(self, "^3FLOOD CONTROL: ^7message too long\n");
100 ServerConsoleEcho(strcat("NOTE: ", playername(self), "^7 is flooding."), TRUE);
104 if(source.classname == "player")
106 FOR_EACH_REALPLAYER(head)
108 if(head.team == source.team)
110 sprint(head, msgstr);
111 centerprint(head, cmsgstr);
117 FOR_EACH_REALCLIENT(head) if(head.classname != "player")
119 sprint(head, msgstr);
120 centerprint(head, cmsgstr);
126 //when g_tourney is active and g_tourney_disable_spec_chat is set and game is in matchstage
127 //don't print the text from specs/observers to the players but only the other spectators
128 if(g_tourney && cvar("g_tourney_disable_spec_chat") && tourneyInMatchStage && source.classname != "player") {
129 FOR_EACH_REALCLIENT(head) if(head.classname != "player") {
130 sprint(head, msgstr);
135 //ServerConsoleEcho(substring(msgstr, 1, strlen(msgstr) - 2), TRUE);
141 float VoteCheckNasty(string cmd)
143 if(strstrofs(cmd, ";", 0) >= 0)
145 if(strstrofs(cmd, "\n", 0) >= 0)
147 if(strstrofs(cmd, "\r", 0) >= 0)
149 if(strstrofs(cmd, "$", 0) >= 0)
154 string GetKickVoteVictim_newcommand;
155 string GetKickVoteVictim_reason;
156 entity GetKickVoteVictim(string vote, string cmd)
163 tokens = tokenize(vote);
167 if(substring(argv(1), 0, 1) == "#")
169 ns = substring(argv(1), 1, 999);
182 GetKickVoteVictim_reason = "";
183 for(i = t; i < tokens; ++i)
184 GetKickVoteVictim_reason = strcat(GetKickVoteVictim_reason, argv(i), " ");
185 GetKickVoteVictim_reason = substring(GetKickVoteVictim_reason, 0, strlen(GetKickVoteVictim_reason) - 1);
188 if(ns == ftos(n)) if(n >= 1) if(n <= maxclients)
191 if(clienttype(e) == CLIENTTYPE_REAL)
193 GetKickVoteVictim_newcommand = strcat(argv(0), " # ", ns);
199 sprint(self, strcat("Usage: ", cmd, " ", argv(0), " #playernumber (as in \"status\")\n"));
203 void SV_ParseClientCommand(string s) {
210 if(argv(0) == "vote") {
211 if(argv(1) == "help") {
212 local string vmasterdis;
213 if(!cvar("sv_vote_master")) {
214 vmasterdis = " ^1(disabled)";
216 local string vcalldis;
217 if(!cvar("sv_vote_call")) {
218 vcalldis = " ^1(disabled)";
220 sprint(self, "^7You can use voting with \"^2cmd vote help^7\" \"^2cmd vote status^7\" \"^2cmd vote call ^3COMMAND ARGUMENTS^7\" \"^2cmd vote stop^7\" \"^2cmd vote master^7\" \"^2cmd vote do ^3COMMAND ARGUMENTS^7\" \"^2cmd vote yes^7\" \"^2cmd vote no^7\" \"^2cmd vote dontcare^7\".\n");
221 sprint(self, "^7Or if your version is up to date you can use these aliases \"^2vhelp^7\" \"^2vstatus^7\" \"^2vcall ^3COMMAND ARGUMENTS^7\" \"^2vstop^7\" \"^2vmaster^7\" \"^2vdo ^3COMMAND ARGUMENTS^7\" \"^2vyes^7\" \"^2vno^7\" \"^2vdontcare^7\".\n");
222 sprint(self, "^7\"^2help^7\" shows this info.\n");
223 sprint(self, "^7\"^2status^7\" shows if there is a vote called and who called it.\n");
224 sprint(self, strcat("^7\"^2call^7\" is used to call a vote. See the list of allowed commands.", vcalldis, "^7\n"));
225 sprint(self, "^7\"^2stop^7\" can be used by the vote caller or an admin to stop a vote and maybe correct it.\n");
226 sprint(self, strcat("^7\"^2master^7\" is used to call a vote to become a master.", vmasterdis, "^7\n"));
227 sprint(self, "^7\"^2do^7\" If you are a master you can execute a command without a vote. See the list of allowed commands.\n");
228 sprint(self, "^7\"^2yes^7\", \"^2no^7\" and \"^2dontcare^7\" to make your vote.\n");
229 sprint(self, "^7If enough of the players vote yes the vote is accepted.\n");
230 sprint(self, "^7If enough of the players vote no the vote is rejected.\n");
231 sprint(self, strcat("^7The vote will end after ", cvar_string("sv_vote_timeout"), "^7 seconds.\n"));
232 sprint(self, "^7You can call a vote for or execute these commands:\n");
233 sprint(self, strcat("^3", cvar_string("sv_vote_commands"), "^7 and maybe further ^3arguments^7\n"));
234 } else if(argv(1) == "status") {
236 sprint(self, strcat("^7Vote for ", votecalledvote_display, "^7 called by ^7", votecaller.netname, "^7.\n"));
238 sprint(self, "^1No vote called.\n");
240 } else if(argv(1) == "call") {
241 if(cvar("sv_vote_call")) {
242 if(tourneyInMatchStage && cvar("g_tourney_disable_spec_vote") && self.classname != "player") {
243 sprint(self, "^1Error: Only players can call a vote during the match-stage.\n");
245 else if(votecalled) {
246 sprint(self, "^1There is already a vote called.\n");
251 sprint(self, "^1Your vote is empty. See help for more info.\n");
252 } else if(time < self.vote_next) {
253 sprint(self, strcat("^1You have to wait ^2", ftos(self.vote_next - time), "^1 seconds before you can again call a vote.\n"));
254 } else if(VoteCheckNasty(vote)) {
255 sprint(self, "Syntax error in command.\n");
256 } else if(VoteAllowed(strcat1(argv(2)))) { // strcat seems to be necessary
257 // remap chmap to gotomap (forces intermission)
258 if(vote == "chmap" || vote == "gotomap") // won't work without arguments
260 if(substring(vote, 0, 6) == "chmap ")
261 vote = strcat("gotomap ", substring(vote, 6, strlen(vote) - 6));
262 if(substring(vote, 0, 8) == "gotomap ")
264 if(!(vote = ValidateMap(substring(vote, 8, strlen(vote) - 8))))
266 vote = strcat("gotomap ", vote);
269 // make kick and kickban votes a bit nicer (and reject them if formatted badly)
270 if(substring(vote, 0, 5) == "kick " || substring(vote, 0, 8) == "kickban ")
272 if(!(e = GetKickVoteVictim(vote, "vcall")))
274 vote = GetKickVoteVictim_newcommand;
275 votecalledvote_display = strzone(strcat("^1", vote, " (^7", e.netname, "^1): ", GetKickVoteVictim_reason));
279 votecalledvote_display = strzone(strcat("^1", vote));
281 votecalledvote = strzone(vote);
283 votecalledmaster = FALSE;
284 votecaller = self; // remember who called the vote
285 votefinished = time + cvar("sv_vote_timeout");
286 votecaller.vote_vote = 1; // of course you vote yes
287 votecaller.vote_next = time + cvar("sv_vote_wait");
288 bprint("\{1}^2* ^3", votecaller.netname, "^2 calls a vote for ", votecalledvote_display, "\n");
289 VoteCount(); // needed if you are the only one
291 sprint(self, "^1This vote is not ok. See help for more info.\n");
295 sprint(self, "^1Vote calling is NOT allowed.\n");
297 } else if(argv(1) == "stop") {
299 sprint(self, "^1No vote called.\n");
300 } else if(self == votecaller) { // the votecaller can stop a vote
302 } else if(self.vote_master) { // masters can, too
305 sprint(self, "^1You are not allowed to stop that Vote.\n");
307 } else if(argv(1) == "master") {
308 if(cvar("sv_vote_master")) {
310 sprint(self, "^1There is already a vote called.\n");
313 votecalledmaster = TRUE;
314 votecalledvote = strzone("XXX");
315 votecalledvote_display = strzone("^3master");
316 votecaller = self; // remember who called the vote
317 votefinished = time + cvar("sv_vote_timeout");
318 votecaller.vote_vote = 1; // of course you vote yes
319 votecaller.vote_next = time + cvar("sv_vote_wait");
320 bprint("\{1}^2* ^3", votecaller.netname, "^2 calls a vote to become ^3master^2.\n");
321 VoteCount(); // needed if you are the only one
324 sprint(self, "^1Vote to become master is NOT allowed.\n");
326 } else if(argv(1) == "do") {
327 if(argv(2) == "login") {
328 local string masterpwd;
329 masterpwd = cvar_string("sv_vote_master_password");
330 if(masterpwd != "") {
331 self.vote_master = (masterpwd == argv(3));
332 if(self.vote_master) {
333 ServerConsoleEcho(strcat("Accepted master login from ", self.netname), TRUE);
334 bprint("\{1}^2* ^3", self.netname, "^2 logged in as ^3master^2\n");
337 ServerConsoleEcho(strcat("REJECTED master login from ", self.netname), TRUE);
340 sprint(self, "^1You are NOT a master.\n");
341 } else if(self.vote_master) {
342 local string dovote, dovote_display;
343 dovote = VoteParse();
345 sprint(self, "^1Your command was empty. See help for more info.\n");
346 } else if(VoteCheckNasty(dovote)) {
347 sprint(self, "Syntax error in command.\n");
348 } else if(VoteAllowed(strcat1(argv(2)))) { // strcat seems to be necessary
349 if(dovote == "chmap" || dovote == "gotomap") // won't work without arguments
351 if(substring(dovote, 0, 6) == "chmap ")
352 dovote = strcat("gotomap ", substring(dovote, 6, strlen(dovote) - 6));
353 if(substring(dovote, 0, 8) == "gotomap ")
355 if(!(dovote = ValidateMap(substring(dovote, 8, strlen(dovote) - 8))))
357 dovote = strcat("gotomap ", dovote);
360 dovote_display = dovote;
361 if(substring(dovote, 0, 5) == "kick " || substring(dovote, 0, 8) == "kickban ")
363 if(!(e = GetKickVoteVictim(dovote, "vdo")))
365 dovote = GetKickVoteVictim_newcommand;
366 dovote_display = strcat("^1", dovote, " (^7", e.netname, "^1): ", GetKickVoteVictim_reason);
368 bprint("\{1}^2* ^3", self.netname, "^2 used his ^3master^2 status to do \"^2", dovote_display, "^2\".\n");
369 localcmd(strcat(dovote, "\n"));
371 sprint(self, "^1This command is not ok. See help for more info.\n");
374 sprint(self, "^1You are NOT a master.\n");
376 } else if(argv(1) == "yes") {
378 sprint(self, "^1No vote called.\n");
379 } else if(self.vote_vote == 0
380 || cvar("sv_vote_change")) {
381 sprint(self, "^1You accepted the vote.\n");
383 centerprint_expire(self, CENTERPRIO_VOTE);
384 if(!cvar("sv_vote_singlecount")) {
388 sprint(self, "^1You have already voted.\n");
390 } else if(argv(1) == "no") {
392 sprint(self, "^1No vote called.\n");
393 } else if(self.vote_vote == 0
394 || cvar("sv_vote_change")) {
395 sprint(self, "^1You rejected the vote.\n");
397 centerprint_expire(self, CENTERPRIO_VOTE);
398 if(!cvar("sv_vote_singlecount")) {
402 sprint(self, "^1You have already voted.\n");
404 } else if(argv(1) == "abstain" || argv(1) == "dontcare") {
406 sprint(self, "^1No vote called.\n");
407 } else if(self.vote_vote == 0
408 || cvar("sv_vote_change")) {
409 sprint(self, "^1You abstained from your vote.\n");
411 centerprint_expire(self, CENTERPRIO_VOTE);
412 if(!cvar("sv_vote_singlecount")) {
416 sprint(self, "^1You have already voted.\n");
420 sprint(self, "^1Unknown vote command.\n");
422 } else if(argv(0) == "autoswitch") {
423 // be backwards compatible with older clients (enabled)
424 self.autoswitch = ("0" != argv(1));
425 local string autoswitchmsg;
426 if (self.autoswitch) {
427 autoswitchmsg = "on";
429 autoswitchmsg = "off";
431 sprint(self, strcat("^1autoswitch turned ", autoswitchmsg, "\n"));
432 } else if(argv(0) == "clientversion") {
433 if (argv(1) == "$gameversion") {
434 //versionmsg = "^1client is too old to get versioninfo.\nUPDATE!!! (http://www.nexuiz.com)^8";
435 // either that or someone wants to be funny
438 self.version = stof(argv(1));
440 if(self.version != cvar("gameversion"))
442 self.classname = "observer";
445 } else if(cvar("g_campaign") || cvar("g_balance_teams") || cvar("g_balance_teams_force")) {
446 //JoinBestTeam(self, FALSE, TRUE);
447 } else if(cvar("teamplay") && !cvar("sv_spectate")) {
448 self.classname = "observer";
449 stuffcmd(self,"menu_showteamselect\n");
451 } else if(argv(0) == "reportcvar") { // old system
453 } else if(argv(0) == "sentcvar") { // new system
455 } else if(argv(0) == "spectate") {
457 return; // don't allow spectating in lms, unless player runs out of lives
458 if(self.classname == "player" && cvar("sv_spectate") == 1) {
460 DropFlag(self.flagcarried);
461 kh_Key_DropAll(self, TRUE);
462 WaypointSprite_PlayerDead();
463 DistributeFragsAmongTeam(self, self.team, 1.0);
464 self.classname = "observer";
466 sprint(self, strcat("^7You have to become a player within the next ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
469 } else if(argv(0) == "join") {
471 if (self.classname != "player" && !lockteams)
473 if(isJoinAllowed()) {
474 self.classname = "player";
476 bprint ("^4", self.netname, "^4 is playing now\n");
480 //player may not join because of g_maxplayers is set
481 centerprint_atprio(self, CENTERPRIO_MAPVOTE, PREVENT_JOIN_TEXT);
484 } else if( argv(0) == "selectteam" ) {
485 if( !cvar("teamplay") ) {
486 sprint( self, "selecteam can only be used in teamgames\n");
487 } else if(cvar("g_campaign")) {
488 //JoinBestTeam(self, 0);
489 } else if(lockteams) {
490 sprint( self, "^7The game has already begun, you must wait until the next map to be able to join a team.\n");
491 } else if( argv(1) == "red" ) {
492 DoTeamChange(COLOR_TEAM1);
493 } else if( argv(1) == "blue" ) {
494 DoTeamChange(COLOR_TEAM2);
495 } else if( argv(1) == "yellow" ) {
496 DoTeamChange(COLOR_TEAM3);
497 } else if( argv(1) == "pink" ) {
498 DoTeamChange(COLOR_TEAM4);
499 } else if( argv(1) == "auto" ) {
502 sprint( self, strcat( "selectteam none/red/blue/yellow/pink/auto - \"", argv(1), "\" not recognised\n" ) );
504 } else if(argv(0) == "ready") {
505 if(cvar("sv_ready_restart"))
507 if(!restart_countdown || cvar("sv_ready_restart_repeatable"))
510 bprint(self.netname, "^2 is ready\n");
513 sprint(self, "^1game has already been restarted\n");
516 } else if(argv(0) == "maplist") {
519 n = tokenize(cvar_string("g_maplist"));
520 sprint(self, "^7Maps in list: ");
521 for(i = 0; i < n; ++i)
527 sprint(self, strcat(col, argv(i), " "));
531 } else if(argv(0) == "lsmaps") {
532 sprint(self, "^7Maps available: ");
533 for(i = 0; i < MapInfo_count; ++i)
539 sprint(self, strcat(col, MapInfo_BSPName_ByID(i), " "));
543 } else if(argv(0) == "teamstatus") {
544 PrintScoreboard(self);
545 } else if(argv(0) == "voice") {
546 VoiceMessage(argv(1));
547 } else if(argv(0) == "say") {
548 Say(self, FALSE, substring(s, 4, strlen(s) - 4));
549 //clientcommand(self, formatmessage(s));
550 } else if(argv(0) == "say_team") {
551 Say(self, TRUE, substring(s, 9, strlen(s) - 9));
552 //clientcommand(self, formatmessage(s));
553 } else if(argv(0) == "info") {
554 cmd = cvar_string(strcat("sv_info_", argv(1)));
556 sprint(self, "ERROR: unsupported info command\n");
558 wordwrap_sprint(cmd, 1111);
559 } else if(argv(0) == "suggestmap") {
560 sprint(self, strcat(MapVote_Suggest(argv(1)), "\n"));
563 /* checks not needed any more since DP has separated clientcommands and regular commands
566 //if(cmd != "say") // handled above
567 //if(cmd != "say_team") // handled above
578 if(cmd != "playermodel")
579 if(cmd != "playerskin")
580 if(cmd != "god") if(cmd != "notarget") if(cmd != "fly") if(cmd != "give") if(cmd != "noclip")
582 ServerConsoleEcho(strcat("WARNING: Invalid clientcommand by ", self.netname, ": ", s), TRUE);
586 clientcommand(self,s);
590 string ValidateMap(string m)
593 m = MapInfo_FixName(m);
596 sprint(self, "This map is not available on this server.\n");
600 if(!cvar("sv_vote_change_gametype"))
601 if(!IsSameGametype(m))
603 sprint(self, "This server does not allow changing the game type by map votes.\n");
607 if(!cvar("sv_vote_override_mostrecent"))
610 sprint(self, "This server does not allow for recent maps to be played again. Please be patient for some rounds.\n");
614 if(!MapInfo_CheckMap(m))
616 sprint(self, strcat("^1Invalid mapname, \"^3", m, "^1\" does not support the current game mode.\n"));
620 if(!TryFile(strcat("maps/", m, ".mapcfg")))
622 sprint(self, strcat("^1Invalid mapname, \"^3", m, "^1\" does not exist on this server.\n"));
632 if(votefinished > 0 // a vote was called
633 && time > votefinished) // time is up
644 while(argv(index) != "") {
645 vote = strcat(vote, " ", argv(index));
649 // necessary for some of the string operations
650 vote = strzone(vote);
652 // now we remove some things that could be misused
656 local float votelength;
657 votelength = strlen(vote);
658 while(!found && index < votelength)
660 local string badchar;
661 badchar = substring(vote, index, 1);
671 return substring(vote, 0, index);
674 float VoteAllowed(string votecommand) {
675 tokenize(cvar_string("sv_vote_commands"));
678 while(argv(index) != "") {
679 local string allowed;
680 allowed = argv(index);
681 if(votecommand == allowed) {
692 FOR_EACH_CLIENT(player)
694 player.vote_vote = 0;
695 centerprint_expire(player, CENTERPRIO_VOTE);
700 strunzone(votecalledvote);
701 strunzone(votecalledvote_display);
705 votecalledmaster = FALSE;
710 bprint("\{1}^2* ^3", votecaller.netname, "^2's vote for ^1", votecalledvote_display, "^2 was accepted\n");
713 votecaller.vote_master = 1;
715 //in g_tourney mode and if the vote is a timelimit-change, don't change it immediately but after restart
716 if(cvar("g_tourney") && substring(votecalledvote, 0, 10) == "timelimit ") {
717 if( stof(substring(votecalledvote, 10, strlen(votecalledvote) - 10)) > 0 ) {
718 timelimit_orig = stof(substring(votecalledvote, 10, strlen(votecalledvote) - 10));
719 bprint(strcat("The timelimit will be set to ", ftos(timelimit_orig), " minutes after the next restart!\n"));
721 else //calls like "timelimit -1" can pass immediately
722 localcmd(strcat(votecalledvote, "\n"));
725 localcmd(strcat(votecalledvote, "\n"));
727 votecaller.vote_next = 0; // people like your votes, no wait for next vote
732 bprint("\{1}^2* ^3", votecaller.netname, "^2's vote for ", votecalledvote_display, "^2 was rejected\n");
737 bprint("\{1}^2* ^3", votecaller.netname, "^2's vote for ", votecalledvote_display, "^2 timed out\n");
741 void VoteStop(entity stopper) {
742 bprint("\{1}^2* ^3", stopper.netname, "^2 stopped ^3", votecaller.netname, "^2's vote\n");
743 if(stopper == votecaller) {
744 // no wait for next vote so you can correct your vote
745 votecaller.vote_next = 0;
752 if(self.vote_vote == 0)
753 centerprint_atprio(self, CENTERPRIO_VOTE, strcat("^7^3", votecaller.netname, "^2 called a vote for ", votecalledvote_display, "\n\n^2You have not voted yet!\n^2HINT: By default, F1 is yes and F2 is no."));
756 void VoteSpam(float yescount, float nocount, float abstaincount, float notvoters, float mincount)
761 s = strcat("\{1}^2* vote results: ^1", ftos(yescount), "^2:^1");
762 s = strcat(s, ftos(nocount), "^2 (^1");
763 s = strcat(s, ftos(mincount), "^2 needed), ^1");
764 s = strcat(s, ftos(abstaincount), "^2 didn't care, ^1");
765 s = strcat(s, ftos(notvoters), "^2 didn't vote\n");
769 s = strcat("\{1}^2* vote results: ^1", ftos(yescount), "^2:^1");
770 s = strcat(s, ftos(nocount), "^2 (^1");
771 s = strcat(s, ftos(abstaincount), "^2 didn't care, ^1");
772 s = strcat(s, ftos(notvoters), "^2 didn't have to vote\n");
778 local float playercount;
780 local float yescount;
784 local float abstaincount;
787 //same for real players
788 local float realplayercount;
789 local float realplayeryescount;
790 local float realplayernocount;
791 local float realplayerabstaincount;
792 realplayercount = realplayernocount = realplayerabstaincount = realplayeryescount = 0;
794 FOR_EACH_REALCLIENT(player)
796 if(player.vote_vote == -1) {
798 } else if(player.vote_vote == 1) {
800 } else if(player.vote_vote == -2) {
804 //do the same for real players
805 if(player.classname == "player") {
806 if(player.vote_vote == -1) {
808 } else if(player.vote_vote == 1) {
809 realplayeryescount++;
810 } else if(player.vote_vote == -2) {
811 realplayerabstaincount++;
817 //in tournament mode, if we have at least one player then don't make the vote dependent on spectators (so specs don't have to press F1)
818 if( cvar("g_tourney") && (realplayercount > 0) ) {
819 yescount = realplayeryescount;
820 nocount = realplayernocount;
821 abstaincount = realplayerabstaincount;
822 playercount = realplayercount;
826 if((playercount == 1) && votecalledmaster) {
827 // if only one player is on the server becoming vote
828 // master is not allowed. This could be used for
829 // trolling or worse. 'self' is the user who has
830 // called the vote because this function is called
831 // by SV_ParseClientCommand. Maybe all voting should
832 // be disabled for a single player?
833 sprint(self, "^1You are the only player on this server so you can not become vote master.\n");
834 votecaller.vote_next = 0;
838 votefactor = bound(0.5, cvar("sv_vote_majority_factor"), 0.999);
839 if(yescount > (playercount - abstaincount) * votefactor)
841 VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, -1);
844 else if(nocount >= (playercount - abstaincount) * (1 - votefactor)) // that means, yescount cannot reach minyes any more
846 VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, -1);
849 else if(time > votefinished)
851 if(cvar("sv_vote_simple_majority"))
853 VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, floor((yescount + nocount) * votefactor) + 1);
854 if(yescount > (yescount + nocount) * votefactor)
856 else if(yescount + nocount > 0)
863 VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, floor((playercount - abstaincount) * votefactor) + 1);
871 * Counts how many players are ready. If not enough players are ready, the function
872 * does nothing. If all players are ready, the timelimit will be extended and the
873 * restart_countdown variable is set to allow other functions like PlayerPostThink
874 * to detect that the countdown is now active. If the cvar sv_ready_restart_after_countdown
875 * is not set the map will be resetted.
877 * Function is called after the server receives a 'ready' sign from a player.
884 FOR_EACH_REALPLAYER(e)
891 if(cvar("sv_ready_restart_nag")) {
892 if(!readyNagActive) {
893 readyNagger = spawn();
894 readyNagger.think = readyNagger_Think;
895 readyNagger.cnt = cvar("sv_ready_restart_nag_duration");
896 readyNagger.nextthink = time;
904 bprint("^1Server is restarting...\n");
906 // no arena, assault support yet...
907 if(g_arena | g_assault | gameover | intermission_running)
908 localcmd("restart\n");
910 if(readyNagActive) { //if every player is ready, remove the ready-nagger again
916 tourneyInMatchStage = 1; //once the game is restarted the game is in match stage
917 //reset weapons and ammo, health and armor to default:
918 start_items = IT_LASER | IT_SHOTGUN;
919 start_switchweapon = WEP_SHOTGUN;
920 start_ammo_shells = cvar("g_start_ammo_shells");
921 start_ammo_nails = cvar("g_start_ammo_nails");
922 start_ammo_rockets = cvar("g_start_ammo_rockets");
923 start_ammo_cells = cvar("g_start_ammo_cells");
924 start_health = cvar("g_balance_health_start");
925 start_armorvalue = cvar("g_balance_armor_start");
928 restart_countdown = time + RESTART_COUNTDOWN;
929 restart_mapalreadyrestarted = 0; //reset this var, needed when cvar sv_ready_restart_repeatable is in use
930 //reset the .ready status of all players (also spectators)
935 if(0<cvar("timelimit") || (g_tourney && cvar("g_tourney_warmup_unlimited_time")) )
937 // remember original timelimit on first restart
939 timelimit_orig = cvar("timelimit");
940 //only set the new timelimit if, when loading the map, a timelimit was really set
942 cvar_set("timelimit", ftos(timelimit_orig + ceil(restart_countdown)/60));
944 if(cvar("teamplay_lockonrestart") && teams_matter) {
946 bprint("^1The teams are now locked.\n");
949 //initiate the restart-countdown-announcer entity
950 restartAnnouncer = spawn();
951 restartAnnouncer.think = restartAnnouncer_Think;
952 restartAnnouncer.nextthink = time;
953 restartAnnouncer.cnt = RESTART_COUNTDOWN;
955 //play the prepareforbattle sound to everyone
956 sound(world, CHAN_AUTO, "announcer/robotic/prepareforbattle.wav", 1, ATTN_NONE);
958 //reset map immediately if this cvar is not set
959 if (!cvar("sv_ready_restart_after_countdown"))
962 if(cvar("sv_eventlog"))
963 GameLogEcho(":restart", FALSE);
967 * Centerprints the information to all players who didn't ready up yet to do so.
969 void readyNagger_Think() {
971 if(self.cnt <= 0) { //have a break showing the ready nag
972 //make sure that the old ready-nag-centerprint isn't shown too long:
973 FOR_EACH_REALCLIENT(plr) {
974 if(plr.classname == "player") {
976 centerprint_atprio(plr, CENTERPRIO_SPAM, "");
979 self.cnt = cvar("sv_ready_restart_nag_duration");
980 self.nextthink = time + cvar("sv_ready_restart_nag_interval");
983 //show the ready nagging to all players who aren't ready yet
984 FOR_EACH_REALCLIENT(plr) {
985 if(plr.classname == "player") {
987 centerprint_atprio(plr, CENTERPRIO_SPAM, "^2Please ready up (F4 by default)!");
988 //play reminder sound once the centerprint appears for the first time after the pause:
989 if (self.cnt == cvar("sv_ready_restart_nag_duration"))
990 play2(plr, "misc/talk2.wav");
995 self.nextthink = time + 1;
1001 * Shows the restart countdown for all players.
1002 * Plays the countdown sounds for the seconds 3, 2 1, begin for everyone.
1003 * Restarts the map after the countdown is over (and cvar sv_ready_restart_after_countdown
1006 void restartAnnouncer_Think() {
1009 if(self.cnt <= 0) { //show the "Begin" message and
1010 if (cvar("sv_ready_restart_after_countdown")) {
1011 restart_mapalreadyrestarted = 1;
1015 FOR_EACH_REALCLIENT(plr) {
1016 if(plr.classname == "player") {
1017 s = strcat(NEWLINES, "^1Begin!");
1018 centerprint(plr, s);
1021 sound(world, CHAN_AUTO, "announcer/robotic/begin.wav", 1, ATTN_NONE);
1027 FOR_EACH_REALCLIENT(plr) {
1028 if(plr.classname == "player") {
1029 s = strcat(NEWLINES, "^1Game starts in ", ftos(self.cnt), " seconds");
1030 centerprint(plr, s);
1035 sound(world, CHAN_AUTO, strcat("announcer/robotic/", ftos(self.cnt), ".ogg"), 1, ATTN_NONE);
1037 self.nextthink = time + 1;