1 float SPAWNFLAG_NO_WAYPOINTS_FOR_ITEMS = 1;
2 string redirection_target;
7 float() DoNextMapOverride;
11 if(cvar("g_running_guns"))
13 default_player_alpha = -1;
14 default_weapon_alpha = +1;
16 else if(cvar("g_cloaked"))
18 default_player_alpha = cvar("g_balance_cloaked_alpha");
19 default_weapon_alpha = default_player_alpha;
23 default_player_alpha = cvar("g_player_alpha");
24 if(default_player_alpha <= 0)
25 default_player_alpha = 1;
26 default_weapon_alpha = default_player_alpha;
30 void fteqcc_testbugs()
34 if(!cvar("developer_fteqccbugs"))
37 dprint("*** fteqcc test: checking for bugs...\n");
41 if(sqrt(a) - sqrt(b - a) == 0)
42 dprint("*** fteqcc test: found same-function-twice bug\n");
44 dprint("*** fteqcc test: same-function-twice bug got FINALLY FIXED! HOORAY!\n");
48 world.enemy.frags += 10;
49 if(world.frags > 0.2 || world.frags < -0.2) // don't error out if it's just roundoff errors
50 dprint("*** fteqcc test: found += bug\n");
52 dprint("*** fteqcc test: += bug got FINALLY FIXED! HOORAY!\n");
60 cvar_set("_sv_init", "0");
61 if(cvar("g_maplist_shuffle"))
63 tokenize(cvar_string("g_maplist"));
64 if(argv(0) != GetMapname())
66 cvar_set("nextmap", argv(0));
67 if(!DoNextMapOverride())
73 float world_already_spawned;
74 void worldspawn (void)
76 if(world_already_spawned)
77 error("world already spawned - you may have EXACTLY ONE worldspawn!");
78 world_already_spawned = TRUE;
80 sv_cheats = cvar("sv_cheats");
83 TODO sound pack system
84 // initialize sound pack system
85 soundpack = cvar_string("g_soundpack");
87 soundpack = strcat(soundpack, "/");
88 soundpack = strzone(soundpack);
91 // gamemode related things
92 precache_model ("models/misc/chatbubble.spr");
93 precache_model ("models/misc/teambubble.spr");
94 if (cvar("g_runematch"))
96 precache_model ("models/runematch/curse.mdl");
97 precache_model ("models/runematch/rune.mdl");
100 // Precache all player models if desired
101 if (cvar("sv_precacheplayermodels"))
103 precache_model("models/player/carni.zym");
104 precache_model("models/player/crash.zym");
105 precache_model("models/player/grunt.zym");
106 precache_model("models/player/headhunter.zym");
107 precache_model("models/player/insurrectionist.zym");
108 precache_model("models/player/jeandarc.zym");
109 precache_model("models/player/lurk.zym");
110 precache_model("models/player/lycanthrope.zym");
111 precache_model("models/player/marine.zym");
112 precache_model("models/player/nexus.zym");
113 precache_model("models/player/pyria.zym");
114 precache_model("models/player/shock.zym");
115 precache_model("models/player/skadi.zym");
116 precache_model("models/player/specop.zym");
117 precache_model("models/player/visitant.zym");
120 if (cvar("g_footsteps"))
122 precache_sound ("misc/footstep01.wav");
123 precache_sound ("misc/footstep02.wav");
124 precache_sound ("misc/footstep03.wav");
125 precache_sound ("misc/footstep04.wav");
126 precache_sound ("misc/footstep05.wav");
127 precache_sound ("misc/footstep06.wav");
130 // gore and miscellaneous sounds
131 //precache_sound ("misc/h2ohit.wav");
132 precache_model ("models/gibs/bloodyskull.md3");
133 precache_model ("models/gibs/chunk.mdl");
134 precache_model ("models/gibs/eye.md3");
135 precache_model ("models/gibs/gib1.md3");
136 precache_model ("models/gibs/gib1.mdl");
137 precache_model ("models/gibs/gib2.mdl");
138 precache_model ("models/gibs/gib3.mdl");
139 precache_model ("models/gibs/gib5.md3");
140 precache_sound ("misc/armorimpact.wav");
141 precache_sound ("misc/bodyimpact1.wav");
142 precache_sound ("misc/bodyimpact2.wav");
143 precache_sound ("misc/gib.wav");
144 precache_sound ("misc/gib_splat01.wav");
145 precache_sound ("misc/gib_splat02.wav");
146 precache_sound ("misc/gib_splat03.wav");
147 precache_sound ("misc/gib_splat04.wav");
148 precache_sound ("misc/hit.wav");
149 precache_sound ("misc/hitground1.wav");
150 precache_sound ("misc/hitground2.wav");
151 precache_sound ("misc/hitground3.wav");
152 precache_sound ("misc/hitground4.wav");
153 precache_sound ("misc/null.wav");
154 precache_sound ("misc/talk.wav");
155 precache_sound ("misc/teleport.wav");
156 precache_sound ("player/lava.wav");
157 precache_sound ("player/slime.wav");
159 // announcer sounds - male
160 //precache_sound ("announcer/male/electrobitch.wav");
161 precache_sound ("announcer/male/03kills.wav");
162 precache_sound ("announcer/male/05kills.wav");
163 precache_sound ("announcer/male/10kills.wav");
164 precache_sound ("announcer/male/15kills.wav");
165 precache_sound ("announcer/male/20kills.wav");
166 precache_sound ("announcer/male/25kills.wav");
167 precache_sound ("announcer/male/30kills.wav");
168 precache_sound ("announcer/male/botlike.wav");
169 precache_sound ("announcer/male/yoda.wav");
171 // announcer sounds - robotic
172 precache_sound ("announcer/robotic/1fragleft.wav");
173 precache_sound ("announcer/robotic/1minuteremains.wav");
174 precache_sound ("announcer/robotic/2fragsleft.wav");
175 precache_sound ("announcer/robotic/3fragsleft.wav");
176 if (cvar("g_minstagib"))
178 precache_sound ("announcer/robotic/lastsecond.wav");
179 precache_sound ("announcer/robotic/narrowly.wav");
180 precache_sound ("announcer/robotic/1.wav");
181 precache_sound ("announcer/robotic/2.wav");
182 precache_sound ("announcer/robotic/3.wav");
183 precache_sound ("announcer/robotic/4.wav");
184 precache_sound ("announcer/robotic/5.wav");
185 precache_sound ("announcer/robotic/6.wav");
186 precache_sound ("announcer/robotic/7.wav");
187 precache_sound ("announcer/robotic/8.wav");
188 precache_sound ("announcer/robotic/9.wav");
189 precache_sound ("announcer/robotic/10.wav");
192 // common weapon precaches
193 precache_sound ("weapons/weapon_switch.wav");
194 precache_sound ("weapons/weaponpickup.wav");
195 if (cvar("g_grappling_hook"))
197 precache_sound ("weapons/hook_fire.wav"); // hook
198 precache_sound ("weapons/hook_impact.wav"); // hook
201 if (cvar("sv_precacheweapons"))
203 //precache weapon models/sounds
206 while (wep <= WEP_LAST)
208 weapon_action(wep, WR_PRECACHE);
213 // plays music for the level if there is any
216 precache_sound (self.noise);
217 ambientsound ('0 0 0', self.noise, 1.00, ATTN_NONE);
223 // 1 FLICKER (first variety)
224 lightstyle(1, "mmnmmommommnonmmonqnmmo");
226 // 2 SLOW STRONG PULSE
227 lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
229 // 3 CANDLE (first variety)
230 lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
233 lightstyle(4, "mamamamamama");
236 lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
238 // 6 FLICKER (second variety)
239 lightstyle(6, "nmonqnmomnmomomno");
241 // 7 CANDLE (second variety)
242 lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm");
244 // 8 CANDLE (third variety)
245 lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
247 // 9 SLOW STROBE (fourth variety)
248 lightstyle(9, "aaaaaaaazzzzzzzz");
250 // 10 FLUORESCENT FLICKER
251 lightstyle(10, "mmamammmmammamamaaamammma");
253 // 11 SLOW PULSE NOT FADE TO BLACK
254 lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
256 // styles 32-62 are assigned by the light program for switchable lights
262 lms_lowest_lives = 0;
267 bot_waypoints_for_items = cvar("g_waypoints_for_items");
268 if(bot_waypoints_for_items == 1)
269 if(self.spawnflags & SPAWNFLAG_NO_WAYPOINTS_FOR_ITEMS)
270 bot_waypoints_for_items = 0;
272 if(cvar("g_campaign"))
277 WaypointSprite_Init();
279 //if (cvar("g_domination"))
283 head = nextent(world);
288 head = nextent(head);
291 GameLogInit(); // prepare everything
292 if(cvar("sv_eventlog"))
295 GameLogEcho(":logversion:2", FALSE);
296 s = strcat(cvar_string("sv_eventlog_files_counter"), ".");
297 s = strcat(s, ftos(random()));
298 GameLogEcho(strcat(":gamestart:", GetMapname(), ":", s), FALSE);
299 s = ":gameinfo:mutators:LIST";
300 if(cvar("g_grappling_hook"))
301 s = strcat(s, ":grappling_hook");
302 if(!cvar("g_use_ammunition"))
303 s = strcat(s, ":no_use_ammunition");
304 if(!cvar("g_pickup_items"))
305 s = strcat(s, ":no_pickup_items");
306 if(cvar("g_instagib"))
307 s = strcat(s, ":instagib");
308 if(cvar("g_rocketarena"))
309 s = strcat(s, ":rockerarena");
311 s = strcat(s, ":nixnex");
312 if(cvar("g_vampire"))
313 s = strcat(s, ":vampire");
314 if(cvar("g_laserguided_missile"))
315 s = strcat(s, ":laserguided_missile");
316 if(cvar("g_norecoil"))
317 s = strcat(s, ":norecoil");
319 s = strcat(s, ":midair");
320 if(cvar("g_minstagib"))
321 s = strcat(s, ":minstagib");
322 GameLogEcho(s, FALSE);
323 GameLogEcho(":gameinfo:end", FALSE);
326 cvar_set("nextmap", "");
330 if(cvar("g_campaign"))
340 //makestatic (self); // Who the f___ did that?
344 float( string pFilename ) TryFile =
347 dprint("TryFile(\"", pFilename, "\")\n");
348 lHandle = fopen( pFilename, FILE_READ );
349 if( lHandle != -1 ) {
359 if (game == GAME_DEATHMATCH)
361 else if (game == GAME_TEAM_DEATHMATCH)
363 else if (game == GAME_DOMINATION)
365 else if (game == GAME_CTF)
367 else if (game == GAME_RUNEMATCH)
369 else if (game == GAME_LMS)
371 else if (game == GAME_KEYHUNT)
376 string getmapname_stored;
379 if(getmapname_stored == "")
380 getmapname_stored = strzone(strcat(GetGametype(), "_", mapname));
381 return getmapname_stored;
384 float Map_Count, Map_Current;
385 string Map_Current_Name;
387 // NOTE: this now expects the map list to be already tokenize()d and the count in Map_Count
388 float GetMaplistPosition()
394 idx = cvar("g_maplist_index");
401 for(pos = 0; pos < Map_Count; ++pos)
405 // resume normal maplist rotation if current map is not in g_maplist
409 float MapHasRightSize(string map)
411 // open map size restriction file
413 dprint("opensize "); dprint(map);
414 fh = fopen(strcat("maps/", map, ".sizes"), FILE_READ);
417 float mapmin, mapmax;
419 mapmin = stof(fgets(fh));
420 mapmax = stof(fgets(fh));
422 if(player_count < mapmin)
424 dprint("not enough\n");
427 if(player_count > mapmax)
429 dprint("too many\n");
432 dprint("right size\n");
435 dprint(": not found\n");
439 string Map_Filename(float position)
442 return strcat("maps/", argv(position), ".mapcfg");
445 float(float position, float pass) Map_Check =
449 map_next = argv(position);
451 if(map_next == Map_Current_Name) // same map again in first pass?
453 filename = Map_Filename(position);
454 if(TryFile(filename))
458 if(MapHasRightSize(argv(position)))
463 dprint( "Couldn't find '", filename, "'..\n" );
468 void(string nextmapname) Map_Goto_SetStr =
470 if(getmapname_stored != "")
471 strunzone(getmapname_stored);
472 if(nextmapname == "")
473 getmapname_stored = "";
475 getmapname_stored = strzone(nextmapname);
478 void(float position) Map_Goto_SetFloat =
480 cvar_set("g_maplist_index", ftos(position));
481 Map_Goto_SetStr(argv(position));
484 void() GameResetCfg =
486 // if an exit cfg is defined by exiting map, exec it.
488 exit_cfg = cvar_string("exit_cfg");
490 localcmd(strcat("exec \"", exit_cfg, "\"\n"));
492 localcmd("exec game_reset.cfg\n");
498 localcmd(strcat("exec \"maps/", getmapname_stored ,".mapcfg\"\n"));
501 // return codes of map selectors:
502 // -1 = temporary failure (that is, try some method that is guaranteed to succeed)
503 // -2 = permanent failure
504 float() MaplistMethod_Iterate = // usual method
508 for(pass = 1; pass <= 2; ++pass)
510 for(i = 1; i < Map_Count; ++i)
513 mapindex = math_mod(i + Map_Current, Map_Count);
514 if(Map_Check(mapindex, pass))
521 float() MaplistMethod_Repeat = // fallback method
523 if(Map_Check(Map_Current, 2))
528 float() MaplistMethod_Random = // random map selection
534 for(i = 0; i <= imax; ++i)
537 mapindex = math_mod(Map_Current + ceil(random() * (Map_Count - 1)), Map_Count); // any OTHER map
538 if(Map_Check(mapindex, 1))
544 float(float exponent) MaplistMethod_Shuffle = // more clever shuffling
545 // the exponent sets a bias on the map selection:
546 // the higher the exponent, the less likely "shortly repeated" same maps are
548 float i, j, imax, insertpos;
553 return 0; // only one map, then always play this one
555 for(i = 0; i <= imax; ++i)
559 // now reinsert this at another position
560 insertpos = pow(random(), 1 / exponent); // ]0, 1]
561 insertpos = insertpos * (Map_Count - 1); // ]0, Map_Count - 1]
562 insertpos = ceil(insertpos) + 1; // {2, 3, 4, ..., Map_Count}
563 dprint("SHUFFLE: insert pos = ", ftos(insertpos), "\n");
565 // insert the current map there
567 for(j = 1; j < insertpos; ++j) // i == 1: no loop, will be inserted as first; however, i == 1 has been excluded above
568 newlist = strcat(newlist, "'", argv(j), "'");
569 newlist = strcat(newlist, "'", argv(0), "'"); // now insert the just selected map
570 for(j = insertpos; j < Map_Count; ++j) // i == Map_Count: no loop, has just been inserted as last
571 newlist = strcat(newlist, "'", argv(j), "'");
572 cvar_set("g_maplist", newlist);
573 Map_Count = tokenize(newlist);
575 // NOTE: the selected map has just been inserted at (insertpos-1)th position
576 Map_Current = insertpos - 1; // this is not really valid, but this way the fallback has a chance of working
577 if(Map_Check(Map_Current, 1))
583 void() Maplist_Init =
586 temp = cvar_string("g_maplist");
587 Map_Count = tokenize(temp);
590 bprint( "Maplist is empty! Resetting it to default map list.\n" );
591 cvar_set("g_maplist", temp = cvar_string("g_maplist_defaultlist"));
592 Map_Count = tokenize(temp);
595 error("empty maplist, cannot select a new map");
596 Map_Current = bound(0, GetMaplistPosition(), Map_Count - 1);
598 Map_Current_Name = strzone(argv(Map_Current)); // will be automatically freed on exit thanks to DP
599 // this may or may not be correct, but who cares, in the worst case a map
600 // isn't chosen in the first pass that should have been
603 string() GetNextMap =
611 if(cvar("g_maplist_shuffle") > 0)
612 nextMap = MaplistMethod_Shuffle(cvar("g_maplist_shuffle") + 1);
615 if(cvar("g_maplist_selectrandom"))
616 nextMap = MaplistMethod_Random();
619 nextMap = MaplistMethod_Iterate();
622 nextMap = MaplistMethod_Repeat();
626 Map_Goto_SetFloat(nextMap);
627 return getmapname_stored;
633 float() DoNextMapOverride =
635 if(cvar("g_campaign"))
637 CampaignPostIntermission();
640 if(cvar("quit_when_empty"))
642 if(player_count <= currentbots)
648 if(cvar_string("quit_and_redirect") != "")
650 redirection_target = strzone(cvar_string("quit_and_redirect"));
653 if (cvar("samelevel")) // if samelevel is set, stay on same level
655 // this does not work because it tries to exec maps/nexdm01.mapcfg (which doesn't exist, it should be trying maps/dm_nexdm01.mapcfg for example)
656 //localcmd(strcat("exec \"maps/", mapname, ".mapcfg\"\n"));
657 // so instead just restart the current map using the restart command (DOES NOT WORK PROPERLY WITH exit_cfg STUFF)
658 localcmd("restart\n");
659 //changelevel (mapname);
662 if(cvar_string("nextmap") != "")
663 if(TryFile(strcat("maps/", cvar_string("nextmap"), ".mapcfg")))
665 Map_Goto_SetStr(cvar_string("nextmap"));
669 if(cvar("lastlevel"))
672 localcmd("set lastlevel 0\ntogglemenu\n");
680 //local string nextmap;
681 //local float n, nummaps;
683 if (alreadychangedlevel)
685 alreadychangedlevel = TRUE;
691 for(allowReset = 1; allowReset >= 0; --allowReset)
693 nextMap = GetNextMap();
699 bprint( "Maplist contains no single playable map! Resetting it to default map list.\n" );
700 cvar_set("g_maplist", cvar_string("g_maplist_defaultlist"));
704 error("Everything is broken - not even the default map list works. Please report this to the developers.");
716 When the player presses attack or jump, change to the next level
719 .float autoscreenshot;
720 void() MapVote_Think;
721 float mapvote_initialized;
722 void() IntermissionThink =
724 FixIntermissionClient(self);
726 if(cvar("sv_autoscreenshot"))
727 if(self.autoscreenshot > 0)
728 if(time > self.autoscreenshot)
730 self.autoscreenshot = -1;
731 if(clienttype(self) == CLIENTTYPE_REAL)
732 stuffcmd(self, "\nscreenshot\necho \"^5A screenshot has been taken at request of the server.\"\n");
736 if (time < intermission_exittime)
739 if(!mapvote_initialized)
740 if (time < intermission_exittime + 10 && !self.button0 && !self.button2 && !self.button3 && !self.button6 && !self.buttonuse)
743 if(intermission_exittime >= 0)
751 Returns the entity to view from
755 entity() FindIntermission =
760 // look for info_intermission first
761 spot = find (world, classname, "info_intermission");
763 { // pick a random one
767 spot = find (spot, classname, "info_intermission");
769 spot = find (spot, classname, "info_intermission");
775 // then look for the start position
776 spot = find (world, classname, "info_player_start");
780 // testinfo_player_start is only found in regioned levels
781 spot = find (world, classname, "testplayerstart");
785 // then look for the start position
786 spot = find (world, classname, "info_player_deathmatch");
790 //objerror ("FindIntermission: no spot");
796 ===============================================================================
800 ===============================================================================
803 void(float final) DumpStats =
807 local float to_console;
808 local float to_eventlog;
811 to_console = cvar("sv_logscores_console");
812 to_eventlog = cvar("sv_eventlog");
813 to_file = cvar("sv_logscores_file");
817 to_console = TRUE; // always print printstats replies
818 to_eventlog = FALSE; // but never print them to the event log
822 if(cvar("sv_eventlog_console"))
823 to_console = FALSE; // otherwise we get the output twice
829 s = strcat(s, GetMapname(), ":", ftos(rint(time)));
832 ServerConsoleEcho(s, FALSE);
834 GameLogEcho(s, FALSE);
837 file = fopen(cvar_string("sv_logscores_filename"), FILE_APPEND);
841 fputs(file, strcat(s, "\n"));
844 FOR_EACH_CLIENT(other)
846 if ((clienttype(other) == CLIENTTYPE_REAL) || (clienttype(other) == CLIENTTYPE_BOT && cvar("sv_logscores_bots")))
848 s = strcat(":player:", ftos(other.frags), ":");
849 s = strcat(s, ftos(other.deaths), ":");
850 s = strcat(s, ftos(rint(time - other.jointime)), ":");
851 s = strcat(s, ftos(other.team), ":");
854 ServerConsoleEcho(strcat(s, other.netname), TRUE);
856 GameLogEcho(strcat(s, ftos(other.playerid), ":", other.netname), TRUE);
858 fputs(file, strcat(s, other.netname, "\n"));
863 ServerConsoleEcho(":end", FALSE);
865 GameLogEcho(":end", FALSE);
868 fputs(file, ":end\n");
873 void FixIntermissionClient(entity e)
875 if(!e.autoscreenshot) // initial call
877 e.angles = e.v_angle;
878 e.angles_x = -e.angles_x;
879 e.autoscreenshot = time + 0.8; // used for autoscreenshot
881 // first intermission phase; voting phase has positive health (used to decide whether to send SVC_FINALE or not)
883 e.movetype = MOVETYPE_NONE;
884 e.takedamage = DAMAGE_NO;
886 e.weaponentity.effects = EF_NODRAW;
887 stuffcmd(e, "\nscr_printspeed 1000000\n");
888 if(clienttype(e) == CLIENTTYPE_REAL)
891 WriteByte(MSG_ONE, SVC_INTERMISSION);
895 //e.velocity = '0 0 0';
898 // TODO halt weapon animation
903 go to the next level for deathmatch
904 only called if a time or frag limit has expired
915 intermission_running = 1;
917 // enforce a wait time before allowing changelevel
919 intermission_exittime = time + cvar("sv_mapchange_delay");
921 intermission_exittime = -60;
923 WriteByte (MSG_ALL, SVC_CDTRACK);
924 WriteByte (MSG_ALL, 3);
925 WriteByte (MSG_ALL, 3);
927 //pos = FindIntermission ();
933 if(cvar("sv_eventlog"))
934 GameLogEcho(":gameover", FALSE);
939 FOR_EACH_CLIENT(other)
941 if(maxTotalFrags < other.totalfrags)
942 maxTotalFrags = other.totalfrags;
943 if(minTotalFrags > other.totalfrags)
944 minTotalFrags = other.totalfrags;
947 FOR_EACH_CLIENT(other)
949 FixIntermissionClient(other);
954 bprint(other.netname, " ^7wins.\n");
958 score = (other.frags - minTotalFrags) / max(maxTotalFrags - minTotalFrags, 1);
959 f = bound(0, other.play_time / max(time, 1), 1);
960 // store some statistics?
964 if(cvar("g_campaign"))
965 CampaignPreIntermission();
967 // WriteByte (MSG_ALL, SVC_INTERMISSION);
974 Exit deathmatch games upon conditions
977 void() CheckRules_Player =
979 if (gameover) // someone else quit the game already
982 if(self.deadflag == DEAD_NO)
983 self.play_time += frametime;
985 // fixme: don't check players; instead check dom_team and ctf_team entities
986 // (div0: and that in CheckRules_World please)
989 float checkrules_oneminutewarning;
990 float checkrules_leaderfrags;
991 float tdm_max_score, tdm_old_score;
993 float checkrules_equality;
994 float checkrules_overtimewarning;
995 float checkrules_overtimeend;
997 void() InitiateOvertime =
999 if(!checkrules_overtimeend)
1000 checkrules_overtimeend = time + 60 * cvar("timelimit_maxovertime");
1003 float WINNING_NO = 0; // no winner, but time limits may terminate the game
1004 float WINNING_YES = 1; // winner found
1005 float WINNING_NEVER = 2; // no winner, enter overtime if time limit is reached
1006 float WINNING_STARTOVERTIME = 3; // no winner, enter overtime NOW
1008 float(float fraglimitreached, float equality) GetWinningCode =
1011 if(fraglimitreached)
1012 return WINNING_STARTOVERTIME;
1014 return WINNING_NEVER;
1016 if(fraglimitreached)
1022 // set the .winning flag for exactly those players with a given field value
1023 void(.float field, float value) SetWinners =
1026 FOR_EACH_PLAYER(head)
1027 head.winning = (head.field == value);
1030 // set the .winning flag for those players with a given field value
1031 void(.float field, float value) AddWinners =
1034 FOR_EACH_PLAYER(head)
1035 if(head.field == value)
1039 // clear the .winning flags
1040 void(void) ClearWinners =
1043 FOR_EACH_PLAYER(head)
1047 float() LMS_NewPlayerLives =
1050 fl = cvar("fraglimit");
1054 // first player has left the game for dying too much? Nobody else can get in.
1055 if(lms_lowest_lives < 1)
1058 if(!cvar("g_lms_join_anytime"))
1059 if(lms_lowest_lives < fl - cvar("g_lms_last_join"))
1062 return bound(1, lms_lowest_lives, fl);
1065 // LMS winning condition: game terminates if and only if there's at most one
1066 // one player who's living lives. Top two scores being equal cancels the time
1068 float() WinningCondition_LMS =
1075 have_player = FALSE;
1076 have_players = FALSE;
1077 l = LMS_NewPlayerLives();
1079 head = find(world, classname, "player");
1082 head = find(head, classname, "player");
1084 have_players = TRUE;
1088 // we have at least one player
1091 // two or more active players - continue with the game
1095 // exactly one player?
1098 // but no game has taken place yet
1103 ClearWinners(); SetWinners(winning, 0); // NOTE: exactly one player is still "player", so this works out
1104 dprint("Have a winner, ending game.\n");
1111 // nobody is playing at all...
1114 // wait for players...
1118 // SNAFU (maybe a draw game?)
1120 dprint("No players, ending game.\n");
1125 // When we get here, we have at least two players who are actually LIVING,
1126 // or one player who is still waiting for a victim to join the server. Now
1127 // check if the top two players have equal score.
1129 checkrules_leaderfrags = 0;
1130 checkrules_equality = FALSE;
1131 FOR_EACH_PLAYER(head)
1133 if(head.frags > checkrules_leaderfrags)
1135 checkrules_leaderfrags = head.frags;
1136 checkrules_equality = FALSE;
1138 else if(head.frags > 0 && head.frags == checkrules_leaderfrags)
1139 checkrules_equality = TRUE;
1142 SetWinners(frags, checkrules_leaderfrags);
1144 // The top two players have the same amount of lives? No timelimit then,
1145 // enter overtime...
1147 if(checkrules_equality)
1148 return WINNING_NEVER;
1150 // Top two have different scores? Way to go for our beloved TIMELIMIT!
1154 // DM winning condition: game terminates if a player reached the fraglimit,
1155 // unless the first two players have the same score. The latter case also
1156 // breaks the time limit.
1157 float(float fraglimit) WinningCondition_MaxIndividualScore =
1159 float checkrules_oldleaderfrags;
1162 checkrules_oldleaderfrags = checkrules_leaderfrags;
1163 checkrules_leaderfrags = 0;
1164 checkrules_equality = FALSE;
1165 FOR_EACH_PLAYER(head)
1167 if(head.frags > checkrules_leaderfrags)
1169 checkrules_leaderfrags = head.frags;
1170 checkrules_equality = FALSE;
1172 else if(head.frags > 0 && head.frags == checkrules_leaderfrags)
1173 checkrules_equality = TRUE;
1176 if(checkrules_leaderfrags > 0)
1177 SetWinners(frags, checkrules_leaderfrags);
1181 if (!cvar("g_runematch"))
1182 if (checkrules_leaderfrags != checkrules_oldleaderfrags)
1184 if (checkrules_leaderfrags == fraglimit - 1)
1185 sound(world, CHAN_AUTO, "announcer/robotic/1fragleft.wav", 1, ATTN_NONE);
1186 else if (checkrules_leaderfrags == fraglimit - 2)
1187 sound(world, CHAN_AUTO, "announcer/robotic/2fragsleft.wav", 1, ATTN_NONE);
1188 else if (checkrules_leaderfrags == fraglimit - 3)
1189 sound(world, CHAN_AUTO, "announcer/robotic/3fragsleft.wav", 1, ATTN_NONE);
1192 return GetWinningCode(fraglimit && checkrules_leaderfrags >= fraglimit, checkrules_equality);
1195 float(float fraglimit) WinningConditionBase_Teamplay =
1197 tdm_old_score = tdm_max_score;
1198 tdm_max_score = max4(team1_score, team2_score, team3_score, team4_score);
1200 checkrules_equality =
1205 (team1_score == tdm_max_score)
1206 + (team2_score == tdm_max_score)
1207 + (team3_score == tdm_max_score)
1208 + (team4_score == tdm_max_score)
1212 if(tdm_max_score > 0)
1214 if(team1_score == tdm_max_score)
1215 AddWinners(team, COLOR_TEAM1);
1216 if(team2_score == tdm_max_score)
1217 AddWinners(team, COLOR_TEAM2);
1218 if(team3_score == tdm_max_score)
1219 AddWinners(team, COLOR_TEAM3);
1220 if(team4_score == tdm_max_score)
1221 AddWinners(team, COLOR_TEAM4);
1224 if(!cvar("g_runematch") && !cvar("g_domination"))
1225 if(tdm_max_score != tdm_old_score)
1227 if(tdm_max_score == fraglimit - 1)
1228 sound(world, CHAN_AUTO, "announcer/robotic/1fragleft.wav", 1, ATTN_NONE);
1229 else if(tdm_max_score == fraglimit - 2)
1230 sound(world, CHAN_AUTO, "announcer/robotic/2fragsleft.wav", 1, ATTN_NONE);
1231 else if(tdm_max_score == fraglimit - 3)
1232 sound(world, CHAN_AUTO, "announcer/robotic/3fragsleft.wav", 1, ATTN_NONE);
1235 return GetWinningCode(fraglimit && tdm_max_score >= fraglimit, checkrules_equality);
1238 // TDM winning condition: game terminates if a team's score sum reached the
1239 // fraglimit, unless the first two teams have the same total score. The latter
1240 // case also breaks the time limit.
1241 float(float fraglimit) WinningCondition_MaxTeamSum =
1245 team1_score = team2_score = team3_score = team4_score = 0;
1247 FOR_EACH_PLAYER(head)
1249 if(head.team == COLOR_TEAM1)
1250 team1_score += head.frags;
1251 else if(head.team == COLOR_TEAM2)
1252 team2_score += head.frags;
1253 else if(head.team == COLOR_TEAM3)
1254 team3_score += head.frags;
1255 else if(head.team == COLOR_TEAM4)
1256 team4_score += head.frags;
1259 return WinningConditionBase_Teamplay(fraglimit);
1262 // DOM/CTF winning condition: game terminates if the max of a team's players'
1263 // score reached the fraglimit, unless the first two teams have the same
1264 // maximum score. The latter case also breaks the time limit.
1265 float(float fraglimit) WinningCondition_MaxTeamMax =
1269 team1_score = team2_score = team3_score = team4_score = 0;
1271 FOR_EACH_PLAYER(head)
1273 if(head.team == COLOR_TEAM1)
1275 if(head.frags > team1_score)
1276 team1_score = head.frags;
1278 else if(head.team == COLOR_TEAM2)
1280 if(head.frags > team2_score)
1281 team2_score = head.frags;
1283 else if(head.team == COLOR_TEAM3)
1285 if(head.frags > team3_score)
1286 team3_score = head.frags;
1288 else if(head.team == COLOR_TEAM4)
1290 if(head.frags > team4_score)
1291 team4_score = head.frags;
1295 return WinningConditionBase_Teamplay(fraglimit);
1298 void print_to(entity e, string s)
1301 sprint(e, strcat(s, "\n"));
1303 ServerConsoleEcho(s, TRUE);
1306 void PrintScoreboardFor(entity e, string name, string colorcode, float whichteam)
1316 FOR_EACH_PLAYER(head)
1318 if(!whichteam || head.team == whichteam)
1322 print_to(e, strcat(" ", colorcode, name, ":"));
1324 fragtotal = fragtotal + head.frags;
1325 s = ftos(head.frags);
1326 s = strcat(s, "/", ftos(head.deaths));
1327 s = strcat(s, " @ ", ftos(head.ping));
1328 if(clienttype(head) == CLIENTTYPE_BOT)
1329 s = strcat(s, "botms");
1331 s = strcat(s, "ms");
1332 v = PlayerValue(head);
1334 s = strcat(s, " / ", ftos(v));
1335 print_to(e, strcat(" ", colorcode, head.netname, colorcode, " (", s, ")"));
1338 if(whichteam && found)
1340 s = ftos(fragtotal);
1341 s = strcat(s, " / ", ftos(teamvalue));
1342 print_to(e, strcat(colorcode, " (total: ", s, ")"));
1346 void PrintScoreboard(entity e)
1348 print_to(e, strcat("Time: ", ftos(time / 60)));
1349 print_to(e, strcat("Timelimit: ", ftos(cvar("timelimit"))));
1350 print_to(e, strcat("Fraglimit: ", ftos(cvar("fraglimit"))));
1351 print_to(e, "Scoreboard:");
1354 PrintScoreboardFor(e, "Red", "^1", COLOR_TEAM1);
1355 PrintScoreboardFor(e, "Blue", "^4", COLOR_TEAM2);
1356 PrintScoreboardFor(e, "Yellow", "^3", COLOR_TEAM3);
1357 PrintScoreboardFor(e, "Pink", "^6", COLOR_TEAM4);
1361 PrintScoreboardFor(e, "", "^7", 0);
1366 void ShuffleMaplist()
1374 result = cvar_string("g_maplist");
1375 litems = tokenize(result);
1377 for(start = 0; start < litems - 1; ++start)
1381 // select a random item
1382 selected = ceil(random() * (litems - start) + start) - 1;
1384 // shift this item to the place start
1385 for(i = 0; i < start; ++i)
1386 result = strcat(result, "'", argv(i), "'");
1387 result = strcat(result, "'", argv(selected), "'");
1388 for(i = start; i < litems; ++i)
1390 result = strcat(result, "'", argv(i), "'");
1392 litems = tokenize(result);
1394 //dprint(result, "\n");
1397 cvar_set("g_maplist", result);
1404 Exit deathmatch games upon conditions
1407 void() CheckRules_World =
1410 local float timelimit;
1411 local float fraglimit;
1417 if (intermission_running)
1418 if (time >= intermission_exittime + 60)
1420 if(!DoNextMapOverride())
1425 if (gameover) // someone else quit the game already
1428 timelimit = cvar("timelimit") * 60;
1429 fraglimit = cvar("fraglimit");
1431 if(checkrules_overtimeend)
1433 if(!checkrules_overtimewarning)
1435 checkrules_overtimewarning = TRUE;
1436 //sound(world, CHAN_AUTO, "announcer/robotic/1minuteremains.wav", 1, ATTN_NONE);
1437 bcenterprint("^3Now playing ^1OVERTIME^3!\n\n^3Keep fragging until we have a ^1winner^3!");
1442 if (timelimit && time >= timelimit)
1446 if (checkrules_overtimeend && time >= checkrules_overtimeend)
1452 if (!checkrules_oneminutewarning && timelimit > 0 && time > timelimit - 60)
1454 checkrules_oneminutewarning = TRUE;
1455 sound(world, CHAN_AUTO, "announcer/robotic/1minuteremains.wav", 1, ATTN_NONE);
1458 status = WINNING_NO;
1461 status = WinningCondition_LMS();
1467 if(cvar("g_tdm") || cvar("g_runematch") || cvar("g_ctf") || cvar("g_domination") || cvar("g_keyhunt"))
1468 status = WinningCondition_MaxTeamSum(fraglimit);
1470 // status = WinningCondition_MaxTeamMax(fraglimit);
1473 dprint("div0: How can this happen?\n");
1474 status = WinningCondition_MaxTeamMax(fraglimit);
1478 status = WinningCondition_MaxIndividualScore(fraglimit);
1481 if(status == WINNING_STARTOVERTIME)
1483 status = WINNING_NEVER;
1487 if(status == WINNING_NEVER)
1488 // equality cases! Nobody wins if the overtime ends in a draw.
1491 if(checkrules_overtimeend)
1492 if(status != WINNING_NEVER || time >= checkrules_overtimeend)
1493 status = WINNING_YES;
1495 if(status == WINNING_YES)
1499 float randsel_value;
1500 float randsel_priority;
1501 float randsel_count;
1505 randsel_priority = -1;
1508 void RandSel_Add(float priority, float value)
1510 if(priority > randsel_priority)
1512 randsel_priority = priority;
1513 randsel_value = value;
1516 else if(priority == randsel_priority)
1519 if(ceil(random() * randsel_count) == 1)
1520 randsel_value = value;
1524 float mapvote_nextthink;
1525 float mapvote_initialized;
1526 float mapvote_keeptwotime;
1527 float mapvote_timeout;
1528 string mapvote_message;
1530 #define MAPVOTE_COUNT 10
1531 float mapvote_count;
1532 string mapvote_maps[MAPVOTE_COUNT];
1533 float mapvote_maps_suggested[MAPVOTE_COUNT];
1534 string mapvote_suggestions[MAPVOTE_COUNT];
1535 float mapvote_suggestion_ptr;
1536 string mapvote_fillstr;
1537 float mapvote_maxlen;
1538 float mapvote_voters;
1539 float mapvote_votes[MAPVOTE_COUNT];
1542 void MapVote_ClearAllVotes()
1544 FOR_EACH_CLIENT(other)
1548 string MapVote_Suggest(string m)
1552 return "That's not how to use this command.";
1553 if(!cvar("g_maplist_votable_suggestions"))
1554 return "Suggestions are not accepted on this server.";
1555 if(mapvote_initialized)
1556 return "Can't suggest - voting is already in progress!";
1557 if(!TryFile(strcat("maps/", m, ".mapcfg")))
1558 return "The map you suggested is not available on this server.";
1559 for(i = 0; i < mapvote_suggestion_ptr; ++i)
1560 if(mapvote_suggestions[i] == m)
1561 return "This map was already suggested.";
1562 if(mapvote_suggestion_ptr >= MAPVOTE_COUNT)
1564 i = ceil(random() * mapvote_suggestion_ptr) - 1;
1568 i = mapvote_suggestion_ptr;
1569 mapvote_suggestion_ptr += 1;
1571 if(mapvote_suggestions[i] != "")
1572 strunzone(mapvote_suggestions[i]);
1573 mapvote_suggestions[i] = strzone(m);
1574 GameLogEcho(strcat(":vote:suggested:", m, ":", ftos(self.playerid), ":", self.netname), TRUE);
1575 return "Suggestion accepted.";
1578 void MapVote_AddVotable(string nextMap, float isSuggestion)
1583 for(j = 0; j < mapvote_count; ++j)
1584 if(mapvote_maps[j] == nextMap)
1586 if(strlen(nextMap) > mapvote_maxlen)
1587 mapvote_maxlen = strlen(nextMap);
1588 mapvote_maps[mapvote_count] = strzone(nextMap);
1589 mapvote_maps_suggested[mapvote_count] = isSuggestion;
1598 MapVote_ClearAllVotes();
1600 nmax = min(MAPVOTE_COUNT, cvar("g_maplist_votable"));
1601 smax = min(nmax, cvar("g_maplist_votable_suggestions"));
1604 for(i = 0; i < 100 && mapvote_count < smax; ++i)
1605 MapVote_AddVotable(mapvote_suggestions[ceil(random() * mapvote_suggestion_ptr) - 1], TRUE);
1607 for(i = 0; i < 100 && mapvote_count < nmax; ++i)
1608 MapVote_AddVotable(GetNextMap(), FALSE);
1610 if(mapvote_count == 0)
1612 bprint( "Maplist contains no single playable map! Resetting it to default map list.\n" );
1613 cvar_set("g_maplist", cvar_string("g_maplist_defaultlist"));
1614 for(i = 0; i < 100 && mapvote_count < nmax; ++i)
1615 MapVote_AddVotable(GetNextMap(), FALSE);
1618 //dprint("mapvote count is ", ftos(mapvote_count), "\n");
1620 mapvote_fillstr = " ";
1621 while(strlen(mapvote_fillstr) < mapvote_maxlen + 16)
1622 mapvote_fillstr = strcat(mapvote_fillstr, mapvote_fillstr);
1623 mapvote_fillstr = strzone(mapvote_fillstr);
1625 mapvote_keeptwotime = time + cvar("g_maplist_votable_keeptwotime");
1626 mapvote_timeout = time + cvar("g_maplist_votable_timeout");
1627 if(mapvote_count < 3 || mapvote_keeptwotime <= time)
1628 mapvote_keeptwotime = 0;
1629 mapvote_message = "Choose a map and press its key!";
1631 float MapVote_Finished(float mappos)
1636 result = strcat(":vote:finished:", mapvote_maps[mappos]);
1637 result = strcat(result, ":", ftos(mapvote_votes[mappos]), "::");
1638 for(i = 0; i < mapvote_count; ++i)
1640 if(mapvote_maps[i] != "")
1642 result = strcat(result, ":", mapvote_maps[i]);
1643 result = strcat(result, ":", ftos(mapvote_votes[i]));
1645 GameLogEcho(result, FALSE);
1646 if(mapvote_maps_suggested[mappos])
1647 GameLogEcho(strcat(":vote:suggestion_accepted:", mapvote_maps[mappos]), FALSE);
1649 FOR_EACH_REALCLIENT(other)
1650 FixClientCvars(other);
1652 Map_Goto_SetStr(mapvote_maps[mappos]);
1656 void MapVote_CheckRules_1()
1660 for(i = 0; i < mapvote_count; ++i) if(mapvote_maps[i] != "")
1662 //dprint("Map ", ftos(i), ": "); dprint(mapvote_maps[i], "\n");
1663 mapvote_votes[i] = 0;
1667 FOR_EACH_REALCLIENT(other)
1672 i = other.mapvote - 1;
1673 //dprint("Player ", other.netname, " vote = ", ftos(other.mapvote - 1), "\n");
1674 mapvote_votes[i] = mapvote_votes[i] + 1;
1679 float MapVote_CheckRules_2()
1682 float firstPlace, secondPlace;
1683 float firstPlaceVotes, secondPlaceVotes;
1687 for(i = 0; i < mapvote_count; ++i) if(mapvote_maps[i] != "")
1688 RandSel_Add(mapvote_votes[i], i);
1689 firstPlace = randsel_value;
1690 firstPlaceVotes = randsel_priority;
1691 //dprint("First place: ", ftos(firstPlace), "\n");
1692 //dprint("First place votes: ", ftos(firstPlaceVotes), "\n");
1695 for(i = 0; i < mapvote_count; ++i) if(mapvote_maps[i] != "")
1697 RandSel_Add(mapvote_votes[i], i);
1698 secondPlace = randsel_value;
1699 secondPlaceVotes = randsel_priority;
1700 //dprint("Second place: ", ftos(secondPlace), "\n");
1701 //dprint("Second place votes: ", ftos(secondPlaceVotes), "\n");
1703 if(firstPlace == -1)
1704 error("No first place in map vote... WTF?");
1706 if(secondPlace == -1 || time > mapvote_timeout || (mapvote_voters - firstPlaceVotes) < firstPlaceVotes)
1707 return MapVote_Finished(firstPlace);
1709 if(mapvote_keeptwotime)
1710 if(time > mapvote_keeptwotime || (mapvote_voters - firstPlaceVotes - secondPlaceVotes) < secondPlaceVotes)
1712 mapvote_message = "Now decide between the TOP TWO!";
1713 mapvote_keeptwotime = 0;
1714 result = strcat(":vote:keeptwo:", mapvote_maps[firstPlace]);
1715 result = strcat(result, ":", ftos(firstPlaceVotes));
1716 result = strcat(result, ":", mapvote_maps[secondPlace]);
1717 result = strcat(result, ":", ftos(secondPlaceVotes), "::");
1718 for(i = 0; i < mapvote_count; ++i)
1720 if(i != secondPlace)
1721 if(mapvote_maps[i] != "")
1723 result = strcat(result, ":", mapvote_maps[i]);
1724 result = strcat(result, ":", ftos(mapvote_votes[i]));
1725 strunzone(mapvote_maps[i]);
1726 mapvote_maps[i] = "";
1728 GameLogEcho(result, FALSE);
1740 keeptwo = mapvote_keeptwotime;
1741 MapVote_CheckRules_1(); // count
1742 if(MapVote_CheckRules_2()) // decide
1745 FOR_EACH_REALCLIENT(other)
1747 // hide scoreboard again
1748 if(other.health != 2342)
1750 other.health = 2342;
1752 if(clienttype(other) == CLIENTTYPE_REAL)
1754 stuffcmd(other, "\nin_bind 7 1 \"impulse 1\"; in_bind 7 2 \"impulse 2\"; in_bind 7 3 \"impulse 3\"; in_bind 7 4 \"impulse 4\"; in_bind 7 5 \"impulse 5\"; in_bind 7 6 \"impulse 6\"; in_bind 7 7 \"impulse 7\"; in_bind 7 8 \"impulse 8\"; in_bind 7 9 \"impulse 9\"; in_bind 7 0 \"impulse 10\"; in_bind 7 KP_1 \"impulse 1\"; in_bind 7 KP_2 \"impulse 2\"; in_bind 7 KP_3 \"impulse 3\"; in_bind 7 KP_4 \"impulse 4\"; in_bind 7 KP_5 \"impulse 5\"; in_bind 7 KP_6 \"impulse 6\"; in_bind 7 KP_7 \"impulse 7\"; in_bind 7 KP_8 \"impulse 8\"; in_bind 7 KP_9 \"impulse 9\"; in_bind 7 KP_0 \"impulse 10\"; in_bindmap 7 0\n");
1756 WriteByte(MSG_ONE, SVC_FINALE);
1757 WriteString(MSG_ONE, "");
1761 // notify about keep-two
1762 if(keeptwo != 0 && mapvote_keeptwotime == 0)
1763 play2(other, "misc/invshot.wav");
1765 // clear possibly invalid votes
1766 if(mapvote_maps[other.mapvote - 1] == "")
1768 // use impulses as new vote
1769 if(other.impulse >= 1 && other.impulse <= mapvote_count)
1770 if(mapvote_maps[other.impulse - 1] != "")
1771 other.mapvote = other.impulse;
1775 MapVote_CheckRules_1(); // just count
1777 FOR_EACH_REALCLIENT(other)
1779 // display voting screen
1780 msgstr = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
1781 msgstr = substring(msgstr, 0, strlen(msgstr) - mapvote_count);
1782 msgstr = strcat(msgstr, mapvote_message);
1783 msgstr = strcat(msgstr, "\n\n");
1784 for(i = 0; i < mapvote_count; ++i)
1785 if(mapvote_maps[i] == "")
1786 msgstr = strcat(msgstr, "\n");
1789 tmp = mapvote_maps[i];
1790 tmp = strcat(tmp, substring(mapvote_fillstr, 0, mapvote_maxlen - strlen(tmp)));
1791 tmp = strcat(ftos(math_mod(i + 1, 10)), ": ", tmp);
1792 tmp = strcat(tmp, " ^2(", ftos(mapvote_votes[i]), " vote");
1793 if(mapvote_votes[i] != 1)
1794 tmp = strcat(tmp, "s");
1795 tmp = strcat(tmp, ")");
1796 tmp = strcat(tmp, substring(mapvote_fillstr, 0, mapvote_maxlen + 15 - strlen(tmp)));
1797 if(other.mapvote == i + 1)
1798 msgstr = strcat(msgstr, "^3> ", tmp, "\n");
1800 msgstr = strcat(msgstr, "^7 ", tmp, "\n");
1802 i = ceil(mapvote_timeout - time);
1803 msgstr = strcat(msgstr, "\n\n", ftos(i), " second");
1805 msgstr = strcat(msgstr, "s");
1806 msgstr = strcat(msgstr, " left");
1808 centerprint_atprio(other, CENTERPRIO_MAPVOTE, msgstr);
1811 void MapVote_Think()
1813 if(alreadychangedlevel)
1816 if(time < mapvote_nextthink)
1820 mapvote_nextthink = time + 0.5;
1822 if(!mapvote_initialized)
1824 mapvote_initialized = TRUE;
1825 if(DoNextMapOverride())
1827 alreadychangedlevel = TRUE;
1830 if(!cvar("g_maplist_votable"))
1845 FOR_EACH_REALCLIENT(self)
1847 if(self.classname == "spectator")
1849 if(self.enemy.hitsound)
1850 play2(self, "misc/hit.wav");
1855 play2(self, "misc/hit.wav");
1858 FOR_EACH_CLIENT(self)
1859 self.hitsound = FALSE;
1865 * returns TRUE if redirecting
1867 float redirection_timeout;
1868 float redirection_nextthink;
1869 float RedirectionThink()
1871 float clients_found;
1873 if(redirection_target == "")
1876 if(!redirection_timeout)
1878 cvar_set("sv_public", "-2");
1879 redirection_timeout = time + 0.5; // this will only try twice... should be able to keep more clients
1880 if(redirection_target == "self")
1881 bprint("^3SERVER NOTICE:^7 restarting the server\n");
1883 bprint("^3SERVER NOTICE:^7 redirecting everyone to ", redirection_target, "\n");
1886 if(time < redirection_nextthink)
1889 redirection_nextthink = time + 1;
1892 FOR_EACH_REALCLIENT(self)
1894 ServerConsoleEcho(strcat("Redirecting: sending connect command to ", self.netname), FALSE);
1895 if(redirection_target == "self")
1896 stuffcmd(self, "\ndisconnect; reconnect\n");
1898 stuffcmd(self, strcat("\ndisconnect; connect ", redirection_target, "\n"));
1902 ServerConsoleEcho(strcat("Redirecting: ", ftos(clients_found), " clients left."), FALSE);
1904 if(time > redirection_timeout || clients_found == 0)
1905 localcmd("\nwait; wait; wait; quit\n");