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);
127 //ServerConsoleEcho(substring(msgstr, 1, strlen(msgstr) - 2), TRUE);
133 float VoteCheckNasty(string cmd)
135 if(strstrofs(cmd, ";", 0) >= 0)
137 if(strstrofs(cmd, "\n", 0) >= 0)
139 if(strstrofs(cmd, "\r", 0) >= 0)
141 if(strstrofs(cmd, "$", 0) >= 0)
146 string GetKickVoteVictim_newcommand;
147 string GetKickVoteVictim_reason;
148 entity GetKickVoteVictim(string vote, string cmd)
155 tokens = tokenize(vote);
159 if(substring(argv(1), 0, 1) == "#")
161 ns = substring(argv(1), 1, 999);
174 GetKickVoteVictim_reason = "";
175 for(i = t; i < tokens; ++i)
176 GetKickVoteVictim_reason = strcat(GetKickVoteVictim_reason, argv(i), " ");
177 GetKickVoteVictim_reason = substring(GetKickVoteVictim_reason, 0, strlen(GetKickVoteVictim_reason) - 1);
180 if(ns == ftos(n)) if(n >= 1) if(n <= maxclients)
183 if(clienttype(e) == CLIENTTYPE_REAL)
185 GetKickVoteVictim_newcommand = strcat(argv(0), " # ", ns);
191 sprint(self, strcat("Usage: ", cmd, " ", argv(0), " #playernumber (as in \"status\")\n"));
195 void SV_ParseClientCommand(string s) {
202 if(argv(0) == "vote") {
203 if(argv(1) == "help") {
204 local string vmasterdis;
205 if(!cvar("sv_vote_master")) {
206 vmasterdis = " ^1(disabled)";
208 local string vcalldis;
209 if(!cvar("sv_vote_call")) {
210 vcalldis = " ^1(disabled)";
212 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");
213 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");
214 sprint(self, "^7\"^2help^7\" shows this info.\n");
215 sprint(self, "^7\"^2status^7\" shows if there is a vote called and who called it.\n");
216 sprint(self, strcat("^7\"^2call^7\" is used to call a vote. See the list of allowed commands.", vcalldis, "^7\n"));
217 sprint(self, "^7\"^2stop^7\" can be used by the vote caller or an admin to stop a vote and maybe correct it.\n");
218 sprint(self, strcat("^7\"^2master^7\" is used to call a vote to become a master.", vmasterdis, "^7\n"));
219 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");
220 sprint(self, "^7\"^2yes^7\", \"^2no^7\" and \"^2dontcare^7\" to make your vote.\n");
221 sprint(self, "^7If enough of the players vote yes the vote is accepted.\n");
222 sprint(self, "^7If enough of the players vote no the vote is rejected.\n");
223 sprint(self, strcat("^7The vote will end after ", cvar_string("sv_vote_timeout"), "^7 seconds.\n"));
224 sprint(self, "^7You can call a vote for or execute these commands:\n");
225 sprint(self, strcat("^3", cvar_string("sv_vote_commands"), "^7 and maybe further ^3arguments^7\n"));
226 } else if(argv(1) == "status") {
228 sprint(self, strcat("^7Vote for ", votecalledvote_display, "^7 called by ^7", votecaller.netname, "^7.\n"));
230 sprint(self, "^1No vote called.\n");
232 } else if(argv(1) == "call") {
233 if(cvar("sv_vote_call")) {
235 sprint(self, "^1There is already a vote called.\n");
240 sprint(self, "^1Your vote is empty. See help for more info.\n");
241 } else if(time < self.vote_next) {
242 sprint(self, strcat("^1You have to wait ^2", ftos(self.vote_next - time), "^1 seconds before you can again call a vote.\n"));
243 } else if(VoteCheckNasty(vote)) {
244 sprint(self, "Syntax error in command.\n");
245 } else if(VoteAllowed(strcat1(argv(2)))) { // strcat seems to be necessary
246 // remap chmap to gotomap (forces intermission)
247 if(vote == "chmap" || vote == "gotomap") // won't work without arguments
249 if(substring(vote, 0, 6) == "chmap ")
250 vote = strcat("gotomap ", substring(vote, 6, strlen(vote) - 6));
251 if(substring(vote, 0, 8) == "gotomap ")
253 if(!(vote = ValidateMap(substring(vote, 8, strlen(vote) - 8))))
255 vote = strcat("gotomap ", vote);
258 // make kick and kickban votes a bit nicer (and reject them if formatted badly)
259 if(substring(vote, 0, 5) == "kick " || substring(vote, 0, 8) == "kickban ")
261 if(!(e = GetKickVoteVictim(vote, "vcall")))
263 vote = GetKickVoteVictim_newcommand;
264 votecalledvote_display = strzone(strcat("^1", vote, " (^7", e.netname, "^1): ", GetKickVoteVictim_reason));
268 votecalledvote_display = strzone(strcat("^1", vote));
270 votecalledvote = strzone(vote);
272 votecalledmaster = FALSE;
273 votecaller = self; // remember who called the vote
274 votefinished = time + cvar("sv_vote_timeout");
275 votecaller.vote_vote = 1; // of course you vote yes
276 votecaller.vote_next = time + cvar("sv_vote_wait");
277 bprint("\{1}^2* ^3", votecaller.netname, "^2 calls a vote for ", votecalledvote_display, "\n");
278 VoteCount(); // needed if you are the only one
280 sprint(self, "^1This vote is not ok. See help for more info.\n");
284 sprint(self, "^1Vote calling is NOT allowed.\n");
286 } else if(argv(1) == "stop") {
288 sprint(self, "^1No vote called.\n");
289 } else if(self == votecaller) { // the votecaller can stop a vote
291 } else if(self.vote_master) { // masters can, too
294 sprint(self, "^1You are not allowed to stop that Vote.\n");
296 } else if(argv(1) == "master") {
297 if(cvar("sv_vote_master")) {
299 sprint(self, "^1There is already a vote called.\n");
302 votecalledmaster = TRUE;
303 votecalledvote = strzone("XXX");
304 votecalledvote_display = strzone("^3master");
305 votecaller = self; // remember who called the vote
306 votefinished = time + cvar("sv_vote_timeout");
307 votecaller.vote_vote = 1; // of course you vote yes
308 votecaller.vote_next = time + cvar("sv_vote_wait");
309 bprint("\{1}^2* ^3", votecaller.netname, "^2 calls a vote to become ^3master^2.\n");
310 VoteCount(); // needed if you are the only one
313 sprint(self, "^1Vote to become master is NOT allowed.\n");
315 } else if(argv(1) == "do") {
316 if(argv(2) == "login") {
317 local string masterpwd;
318 masterpwd = cvar_string("sv_vote_master_password");
319 if(masterpwd != "") {
320 self.vote_master = (masterpwd == argv(3));
321 if(self.vote_master) {
322 ServerConsoleEcho(strcat("Accepted master login from ", self.netname), TRUE);
323 bprint("\{1}^2* ^3", self.netname, "^2 logged in as ^3master^2\n");
326 ServerConsoleEcho(strcat("REJECTED master login from ", self.netname), TRUE);
329 sprint(self, "^1You are NOT a master.\n");
330 } else if(self.vote_master) {
331 local string dovote, dovote_display;
332 dovote = VoteParse();
334 sprint(self, "^1Your command was empty. See help for more info.\n");
335 } else if(VoteCheckNasty(dovote)) {
336 sprint(self, "Syntax error in command.\n");
337 } else if(VoteAllowed(strcat1(argv(2)))) { // strcat seems to be necessary
338 if(dovote == "chmap" || dovote == "gotomap") // won't work without arguments
340 if(substring(dovote, 0, 6) == "chmap ")
341 dovote = strcat("gotomap ", substring(dovote, 6, strlen(dovote) - 6));
342 if(substring(dovote, 0, 8) == "gotomap ")
344 if(!(dovote = ValidateMap(substring(dovote, 8, strlen(dovote) - 8))))
346 dovote = strcat("gotomap ", dovote);
349 dovote_display = dovote;
350 if(substring(dovote, 0, 5) == "kick " || substring(dovote, 0, 8) == "kickban ")
352 if(!(e = GetKickVoteVictim(dovote, "vdo")))
354 dovote = GetKickVoteVictim_newcommand;
355 dovote_display = strcat("^1", dovote, " (^7", e.netname, "^1): ", GetKickVoteVictim_reason);
357 bprint("\{1}^2* ^3", self.netname, "^2 used his ^3master^2 status to do \"^2", dovote_display, "^2\".\n");
358 localcmd(strcat(dovote, "\n"));
360 sprint(self, "^1This command is not ok. See help for more info.\n");
363 sprint(self, "^1You are NOT a master.\n");
365 } else if(argv(1) == "yes") {
367 sprint(self, "^1No vote called.\n");
368 } else if(self.vote_vote == 0
369 || cvar("sv_vote_change")) {
370 sprint(self, "^1You accepted the vote.\n");
372 centerprint_expire(self, CENTERPRIO_VOTE);
373 if(!cvar("sv_vote_singlecount")) {
377 sprint(self, "^1You have already voted.\n");
379 } else if(argv(1) == "no") {
381 sprint(self, "^1No vote called.\n");
382 } else if(self.vote_vote == 0
383 || cvar("sv_vote_change")) {
384 sprint(self, "^1You rejected the vote.\n");
386 centerprint_expire(self, CENTERPRIO_VOTE);
387 if(!cvar("sv_vote_singlecount")) {
391 sprint(self, "^1You have already voted.\n");
393 } else if(argv(1) == "abstain" || argv(1) == "dontcare") {
395 sprint(self, "^1No vote called.\n");
396 } else if(self.vote_vote == 0
397 || cvar("sv_vote_change")) {
398 sprint(self, "^1You abstained from your vote.\n");
400 centerprint_expire(self, CENTERPRIO_VOTE);
401 if(!cvar("sv_vote_singlecount")) {
405 sprint(self, "^1You have already voted.\n");
409 sprint(self, "^1Unknown vote command.\n");
411 } else if(argv(0) == "autoswitch") {
412 // be backwards compatible with older clients (enabled)
413 self.autoswitch = ("0" != argv(1));
414 local string autoswitchmsg;
415 if (self.autoswitch) {
416 autoswitchmsg = "on";
418 autoswitchmsg = "off";
420 sprint(self, strcat("^1autoswitch turned ", autoswitchmsg, "\n"));
421 } else if(argv(0) == "clientversion") {
422 if (argv(1) == "$gameversion") {
423 //versionmsg = "^1client is too old to get versioninfo.\nUPDATE!!! (http://www.nexuiz.com)^8";
424 // either that or someone wants to be funny
427 self.version = stof(argv(1));
429 if(self.version != cvar("gameversion"))
431 self.classname = "observer";
434 } else if(cvar("g_campaign") || cvar("g_balance_teams") || cvar("g_balance_teams_force")) {
435 //JoinBestTeam(self, FALSE, TRUE);
436 } else if(cvar("teamplay") && !cvar("sv_spectate")) {
437 self.classname = "observer";
438 stuffcmd(self,"menu_showteamselect\n");
440 } else if(argv(0) == "reportcvar") { // old system
442 } else if(argv(0) == "sentcvar") { // new system
444 } else if(argv(0) == "spectate") {
446 return; // don't allow spectating in lms, unless player runs out of lives
447 if(self.classname == "player" && cvar("sv_spectate") == 1) {
449 DropFlag(self.flagcarried);
450 kh_Key_DropAll(self, TRUE);
451 WaypointSprite_PlayerDead();
452 DistributeFragsAmongTeam(self, self.team, 1.0);
453 self.classname = "observer";
455 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"));
458 } else if(argv(0) == "join") {
460 if (self.classname != "player" && !lockteams)
462 if(isJoinAllowed()) {
463 self.classname = "player";
465 bprint ("^4", self.netname, "^4 is playing now\n");
469 //player may not join because of g_maxplayers is set
470 centerprint_atprio(self, CENTERPRIO_MAPVOTE, PREVENT_JOIN_TEXT);
473 } else if( argv(0) == "selectteam" ) {
474 if( !cvar("teamplay") ) {
475 sprint( self, "selecteam can only be used in teamgames\n");
476 } else if(cvar("g_campaign")) {
477 //JoinBestTeam(self, 0);
478 } else if(lockteams) {
479 sprint( self, "^7The game has already begun, you must wait until the next map to be able to join a team.\n");
480 } else if( argv(1) == "red" ) {
481 DoTeamChange(COLOR_TEAM1);
482 } else if( argv(1) == "blue" ) {
483 DoTeamChange(COLOR_TEAM2);
484 } else if( argv(1) == "yellow" ) {
485 DoTeamChange(COLOR_TEAM3);
486 } else if( argv(1) == "pink" ) {
487 DoTeamChange(COLOR_TEAM4);
488 } else if( argv(1) == "auto" ) {
491 sprint( self, strcat( "selectteam none/red/blue/yellow/pink/auto - \"", argv(1), "\" not recognised\n" ) );
493 } else if(argv(0) == "ready") {
494 if(cvar("sv_ready_restart"))
496 if(!restart_countdown || cvar("sv_ready_restart_repeatable"))
499 bprint(self.netname, "^2 is ready\n");
502 sprint(self, "^1game has already been restarted\n");
505 } else if(argv(0) == "maplist") {
508 n = tokenize(cvar_string("g_maplist"));
509 sprint(self, "^7Maps in list: ");
510 for(i = 0; i < n; ++i)
516 sprint(self, strcat(col, argv(i), " "));
520 } else if(argv(0) == "lsmaps") {
521 sprint(self, "^7Maps available: ");
522 for(i = 0; i < MapInfo_count; ++i)
528 sprint(self, strcat(col, MapInfo_BSPName_ByID(i), " "));
532 } else if(argv(0) == "teamstatus") {
533 PrintScoreboard(self);
534 } else if(argv(0) == "voice") {
535 VoiceMessage(argv(1));
536 } else if(argv(0) == "say") {
537 Say(self, FALSE, substring(s, 4, strlen(s) - 4));
538 //clientcommand(self, formatmessage(s));
539 } else if(argv(0) == "say_team") {
540 Say(self, TRUE, substring(s, 9, strlen(s) - 9));
541 //clientcommand(self, formatmessage(s));
542 } else if(argv(0) == "info") {
543 cmd = cvar_string(strcat("sv_info_", argv(1)));
545 sprint(self, "ERROR: unsupported info command\n");
547 wordwrap_sprint(cmd, 1111);
548 } else if(argv(0) == "suggestmap") {
549 sprint(self, strcat(MapVote_Suggest(argv(1)), "\n"));
552 /* checks not needed any more since DP has separated clientcommands and regular commands
555 //if(cmd != "say") // handled above
556 //if(cmd != "say_team") // handled above
567 if(cmd != "playermodel")
568 if(cmd != "playerskin")
569 if(cmd != "god") if(cmd != "notarget") if(cmd != "fly") if(cmd != "give") if(cmd != "noclip")
571 ServerConsoleEcho(strcat("WARNING: Invalid clientcommand by ", self.netname, ": ", s), TRUE);
575 clientcommand(self,s);
579 string ValidateMap(string m)
582 m = MapInfo_FixName(m);
585 sprint(self, "This map is not available on this server.\n");
589 if(!cvar("sv_vote_change_gametype"))
590 if(!IsSameGametype(m))
592 sprint(self, "This server does not allow changing the game type by map votes.\n");
596 if(!cvar("sv_vote_override_mostrecent"))
599 sprint(self, "This server does not allow for recent maps to be played again. Please be patient for some rounds.\n");
603 if(!MapInfo_CheckMap(m))
605 sprint(self, strcat("^1Invalid mapname, \"^3", m, "^1\" does not support the current game mode.\n"));
609 if(!TryFile(strcat("maps/", m, ".mapcfg")))
611 sprint(self, strcat("^1Invalid mapname, \"^3", m, "^1\" does not exist on this server.\n"));
621 if(votefinished > 0 // a vote was called
622 && time > votefinished) // time is up
633 while(argv(index) != "") {
634 vote = strcat(vote, " ", argv(index));
638 // necessary for some of the string operations
639 vote = strzone(vote);
641 // now we remove some things that could be misused
645 local float votelength;
646 votelength = strlen(vote);
647 while(!found && index < votelength)
649 local string badchar;
650 badchar = substring(vote, index, 1);
660 return substring(vote, 0, index);
663 float VoteAllowed(string votecommand) {
664 tokenize(cvar_string("sv_vote_commands"));
667 while(argv(index) != "") {
668 local string allowed;
669 allowed = argv(index);
670 if(votecommand == allowed) {
681 FOR_EACH_CLIENT(player)
683 player.vote_vote = 0;
684 centerprint_expire(player, CENTERPRIO_VOTE);
689 strunzone(votecalledvote);
690 strunzone(votecalledvote_display);
694 votecalledmaster = FALSE;
699 bprint("\{1}^2* ^3", votecaller.netname, "^2's vote for ^1", votecalledvote_display, "^2 was accepted\n");
702 votecaller.vote_master = 1;
704 localcmd(strcat(votecalledvote, "\n"));
706 votecaller.vote_next = 0; // people like your votes, no wait for next vote
711 bprint("\{1}^2* ^3", votecaller.netname, "^2's vote for ", votecalledvote_display, "^2 was rejected\n");
716 bprint("\{1}^2* ^3", votecaller.netname, "^2's vote for ", votecalledvote_display, "^2 timed out\n");
720 void VoteStop(entity stopper) {
721 bprint("\{1}^2* ^3", stopper.netname, "^2 stopped ^3", votecaller.netname, "^2's vote\n");
722 if(stopper == votecaller) {
723 // no wait for next vote so you can correct your vote
724 votecaller.vote_next = 0;
731 if(self.vote_vote == 0)
732 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."));
735 void VoteSpam(float yescount, float nocount, float abstaincount, float notvoters, float mincount)
740 s = strcat("\{1}^2* vote results: ^1", ftos(yescount), "^2:^1");
741 s = strcat(s, ftos(nocount), "^2 (^1");
742 s = strcat(s, ftos(mincount), "^2 needed), ^1");
743 s = strcat(s, ftos(abstaincount), "^2 didn't care, ^1");
744 s = strcat(s, ftos(notvoters), "^2 didn't vote\n");
748 s = strcat("\{1}^2* vote results: ^1", ftos(yescount), "^2:^1");
749 s = strcat(s, ftos(nocount), "^2 (^1");
750 s = strcat(s, ftos(abstaincount), "^2 didn't care, ^1");
751 s = strcat(s, ftos(notvoters), "^2 didn't have to vote\n");
757 local float playercount;
759 local float yescount;
763 local float abstaincount;
767 FOR_EACH_REALCLIENT(player)
769 if(player.vote_vote == -1) {
771 } else if(player.vote_vote == 1) {
773 } else if(player.vote_vote == -2) {
779 if((playercount == 1) && votecalledmaster) {
780 // if only one player is on the server becoming vote
781 // master is not allowed. This could be used for
782 // trolling or worse. 'self' is the user who has
783 // called the vote because this function is called
784 // by SV_ParseClientCommand. Maybe all voting should
785 // be disabled for a single player?
786 sprint(self, "^1You are the only player on this server so you can not become vote master.\n");
787 votecaller.vote_next = 0;
791 votefactor = bound(0.5, cvar("sv_vote_majority_factor"), 0.999);
792 if(yescount > (playercount - abstaincount) * votefactor)
794 VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, -1);
797 else if(nocount >= (playercount - abstaincount) * (1 - votefactor)) // that means, yescount cannot reach minyes any more
799 VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, -1);
802 else if(time > votefinished)
804 if(cvar("sv_vote_simple_majority"))
806 VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, floor((yescount + nocount) * votefactor) + 1);
807 if(yescount > (yescount + nocount) * votefactor)
809 else if(yescount + nocount > 0)
816 VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, floor((playercount - abstaincount) * votefactor) + 1);
823 float timelimit_orig;
826 * Counts how many players are ready. If not enough players are ready, the function
827 * does nothing. If all players are ready, the timelimit will be extended and the
828 * restart_countdown variable is set to allow other functions like PlayerPostThink
829 * to detect that the countdown is now active. If the cvar sv_ready_restart_after_countdown
830 * is not set the map will be resetted.
832 * Function is called after the server receives a 'ready' sign from a player.
839 FOR_EACH_REALPLAYER(e)
846 if(cvar("sv_ready_restart_nag")) {
847 if(!readyNagActive) {
848 readyNagger = spawn();
849 readyNagger.think = readyNagger_Think;
850 readyNagger.cnt = cvar("sv_ready_restart_nag_duration");
851 readyNagger.nextthink = time;
859 bprint("^1Server is restarting...\n");
861 // no arena, assault support yet...
862 if(g_arena | g_assault | gameover | intermission_running)
863 localcmd("restart\n");
865 if(readyNagActive) { //if every player is ready, remove the ready-nagger again
870 restart_countdown = time + RESTART_COUNTDOWN;
871 restart_mapalreadyrestarted = 0; //reset this var, needed when cvar sv_ready_restart_repeatable is in use
872 //reset the .ready status of all players (also spectators)
877 if(0<cvar("timelimit"))
879 // remember original timelimit on first restart
881 timelimit_orig = cvar("timelimit");
882 cvar_set("timelimit", ftos(timelimit_orig + ceil(restart_countdown)/60));
884 if(cvar("teamplay_lockonrestart") && teams_matter) {
886 bprint("^1The teams are now locked.\n");
889 //initiate the restart-countdown-announcer entity
890 restartAnnouncer = spawn();
891 restartAnnouncer.think = restartAnnouncer_Think;
892 restartAnnouncer.nextthink = time;
893 restartAnnouncer.cnt = RESTART_COUNTDOWN;
895 //play the prepareforbattle sound to everyone
896 sound(world, CHAN_AUTO, "announcer/robotic/prepareforbattle.wav", 1, ATTN_NONE);
898 //reset map immediately if this cvar is not set
899 if (!cvar("sv_ready_restart_after_countdown"))
902 if(cvar("sv_eventlog"))
903 GameLogEcho(":restart", FALSE);
907 * Centerprints the information to all players who didn't ready up yet to do so.
909 void readyNagger_Think() {
911 if(self.cnt <= 0) { //have a break showing the ready nag
912 //make sure that the old ready-nag-centerprint isn't shown too long:
913 FOR_EACH_REALCLIENT(plr) {
914 if(plr.classname == "player") {
916 centerprint_atprio(plr, CENTERPRIO_SPAM, "");
919 self.cnt = cvar("sv_ready_restart_nag_duration");
920 self.nextthink = time + cvar("sv_ready_restart_nag_interval");
923 //show the ready nagging to all players who aren't ready yet
924 FOR_EACH_REALCLIENT(plr) {
925 if(plr.classname == "player") {
927 centerprint_atprio(plr, CENTERPRIO_SPAM, "^2Please ready up (F4 by default)!");
928 //play reminder sound once the centerprint appears for the first time after the pause:
929 if (self.cnt == cvar("sv_ready_restart_nag_duration"))
930 play2(plr, "misc/talk2.wav");
935 self.nextthink = time + 1;
941 * Shows the restart countdown for all players.
942 * Plays the countdown sounds for the seconds 3, 2 1, begin for everyone.
943 * Restarts the map after the countdown is over (and cvar sv_ready_restart_after_countdown
946 void restartAnnouncer_Think() {
949 if(self.cnt <= 0) { //show the "Begin" message and
950 if (cvar("sv_ready_restart_after_countdown")) {
951 restart_mapalreadyrestarted = 1;
955 FOR_EACH_REALCLIENT(plr) {
956 if(plr.classname == "player") {
957 s = strcat(NEWLINES, "^1Begin!");
961 sound(world, CHAN_AUTO, "announcer/robotic/begin.wav", 1, ATTN_NONE);
967 FOR_EACH_REALCLIENT(plr) {
968 if(plr.classname == "player") {
969 s = strcat(NEWLINES, "^1Game starts in ", ftos(self.cnt), " seconds");
975 sound(world, CHAN_AUTO, strcat("announcer/robotic/", ftos(self.cnt), ".ogg"), 1, ATTN_NONE);
977 self.nextthink = time + 1;