3 float Nagger_SendEntity(entity to, float sendflags)
7 WriteByte(MSG_ENTITY, ENT_CLIENT_NAGGER);
28 WriteByte(MSG_ENTITY, nags);
33 WriteString(MSG_ENTITY, votecalledvote_display);
35 WriteString(MSG_ENTITY, "");
40 for(i = 1; i <= maxclients; i += 8)
42 for(f = 0, e = edict_num(i), b = 1; b < 256; b *= 2, e = nextent(e))
43 if(clienttype(e) != CLIENTTYPE_REAL || e.ready)
45 WriteByte(MSG_ENTITY, f);
53 Net_LinkEntity(nagger = spawn(), FALSE, 0, Nagger_SendEntity);
55 void Nagger_VoteChanged()
58 nagger.SendFlags |= 128;
60 void Nagger_VoteCountChanged()
63 nagger.SendFlags |= 1;
65 void Nagger_ReadyCounted()
68 nagger.SendFlags |= 1;
72 string MapVote_Suggest(string m);
74 entity GetPlayer(string name)
80 if(substring(name, 0, 1) == "#") {
81 num = stof(substring(name, 1, 999));
82 if(num >= 1 && num <= maxclients) {
83 for((e = world); num > 0; --num, (e = nextent(e)))
85 //if(clienttype(e) == CLIENTTYPE_REAL)
86 if(e.classname == "player")
90 ns = strdecolorize(name);
91 FOR_EACH_REALPLAYER(e) {
92 if(!strcasecmp(strdecolorize(e.netname), ns)) {
103 if(self.aiment && self.enemy)
105 self.origin_x = (self.aiment.origin_x + self.enemy.origin_x) * 0.5;
106 self.origin_y = (self.aiment.origin_y + self.enemy.origin_y) * 0.5;
107 self.origin_z = (self.aiment.origin_z + self.enemy.origin_z) * 0.5;
108 self.maxs_x = fabs(self.aiment.origin_x - self.enemy.origin_x) * 0.5;
109 self.maxs_y = fabs(self.aiment.origin_y - self.enemy.origin_y) * 0.5;
110 self.maxs_z = fabs(self.aiment.origin_z - self.enemy.origin_z) * 0.5;
111 self.mins = -1 * self.maxs;
112 setorigin(self, self.origin); setsize(self, self.mins, self.maxs); // link edict
115 if(self.cnt == -1) // actually race_place -1
117 // show "10 10" for qualifying spawns
118 setmodel(self.killindicator, "models/sprites/10.spr32");
119 setmodel(self.killindicator.killindicator, "models/sprites/10.spr32");
121 else if(self.cnt == -2) // actually race_place 0
123 // show "10 0" for loser spawns
124 setmodel(self.killindicator, "models/sprites/10.spr32");
125 setmodel(self.killindicator.killindicator, "models/sprites/0.spr32");
129 setmodel(self.killindicator, strcat("models/sprites/", ftos(mod(self.cnt, 10)), ".spr32"));
130 setmodel(self.killindicator.killindicator, strcat("models/sprites/", ftos(floor(self.cnt / 10)), ".spr32"));
133 self.nextthink = time;
136 //float ctf_clientcommand();
137 float readyrestart_happened;
138 .float lms_spectate_warning;
139 void spawnfunc_func_breakable();
140 void SV_ParseClientCommand(string s) {
142 float tokens, f, effectnum;
146 tokens = tokenize_console(s);
148 if(GameCommand_Vote(s, self)) {
150 } else if(GameCommand_MapVote(argv(0))) {
152 } else if(argv(0) == "autoswitch") {
153 // be backwards compatible with older clients (enabled)
154 self.autoswitch = ("0" != argv(1));
155 local string autoswitchmsg;
156 if (self.autoswitch) {
157 autoswitchmsg = "on";
159 autoswitchmsg = "off";
161 sprint(self, strcat("^1autoswitch turned ", autoswitchmsg, "\n"));
162 } else if(argv(0) == "clientversion") {
163 if not(self.flags & FL_CLIENT)
165 if (argv(1) == "$gameversion") {
166 //versionmsg = "^1client is too old to get versioninfo.\nUPDATE!!! (http://www.nexuiz.com)^8";
167 // either that or someone wants to be funny
170 self.version = stof(argv(1));
172 if(self.version != cvar("gameversion"))
174 self.classname = "observer";
175 self.version_mismatch = 1;
177 } else if(cvar("g_campaign") || cvar("g_balance_teams") || cvar("g_balance_teams_force")) {
178 //JoinBestTeam(self, FALSE, TRUE);
179 } else if(teams_matter && !cvar("sv_spectate")) {
180 self.classname = "observer";
181 stuffcmd(self,"menu_showteamselect\n");
183 } else if(argv(0) == "reportcvar") { // old system
184 if(substring(argv(2), 0, 1) == "$") // undefined cvar: use the default value on the server then
186 s = strcat(substring(s, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\"");
187 tokens = tokenize_console(s);
190 } else if(argv(0) == "sentcvar") { // new system
191 if(tokens == 2) // undefined cvar: use the default value on the server then
193 s = strcat(substring(s, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\"");
194 tokens = tokenize_console(s);
197 } else if(argv(0) == "spectate") {
198 if not(self.flags & FL_CLIENT)
204 if(self.lms_spectate_warning)
206 // mark player as spectator
207 PlayerScore_Add(self, SP_LMS_RANK, 666 - PlayerScore_Add(self, SP_LMS_RANK, 0));
211 self.lms_spectate_warning = 1;
212 sprint(self, "WARNING: you won't be able to enter the game again after spectating in LMS. Use the same command again to spectate anyway.\n");
216 if(self.classname == "player" && cvar("sv_spectate") == 1) {
218 DropFlag(self.flagcarried, world, world);
220 DropBall(self.ballcarried, self.origin, self.velocity);
221 kh_Key_DropAll(self, TRUE);
222 WaypointSprite_PlayerDead();
223 self.classname = "observer";
225 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"));
228 } else if(argv(0) == "join") {
229 if not(self.flags & FL_CLIENT)
232 if (self.classname != "player" && !lockteams)
234 if(isJoinAllowed()) {
235 self.classname = "player";
236 PlayerScore_Clear(self);
237 bprint ("^4", self.netname, "^4 is playing now\n");
239 if(cvar("g_campaign"))
240 campaign_bots_may_start = 1;
243 //player may not join because of g_maxplayers is set
244 centerprint_atprio(self, CENTERPRIO_MAPVOTE, PREVENT_JOIN_TEXT);
247 } else if( argv(0) == "selectteam" ) {
248 if not(self.flags & FL_CLIENT)
250 if( !teams_matter ) {
251 sprint( self, "selecteam can only be used in teamgames\n");
252 } else if(cvar("g_campaign")) {
253 //JoinBestTeam(self, 0);
254 } else if(lockteams) {
255 sprint( self, "^7The game has already begun, you must wait until the next map to be able to join a team.\n");
256 } else if( argv(1) == "red" ) {
257 DoTeamChange(COLOR_TEAM1);
258 } else if( argv(1) == "blue" ) {
259 DoTeamChange(COLOR_TEAM2);
260 } else if( argv(1) == "yellow" ) {
261 DoTeamChange(COLOR_TEAM3);
262 } else if( argv(1) == "pink" ) {
263 DoTeamChange(COLOR_TEAM4);
264 } else if( argv(1) == "auto" ) {
267 sprint( self, strcat( "selectteam none/red/blue/yellow/pink/auto - \"", argv(1), "\" not recognised\n" ) );
269 } else if(argv(0) == "ready") {
270 if not(self.flags & FL_CLIENT)
273 if((inWarmupStage && 0 >= g_warmup_limit) // with unlimited warmup players have to be able to restart
274 || cvar("sv_ready_restart") || g_race_qualifying == 2)
276 if(!readyrestart_happened || cvar("sv_ready_restart_repeatable"))
278 if (self.ready) // toggle
281 bprint(self.netname, "^2 is ^1NOT^2 ready\n");
286 bprint(self.netname, "^2 is ready\n");
289 // cannot reset the game while a timeout is active!
293 sprint(self, "^1Game has already been restarted\n");
296 } else if(argv(0) == "maplist") {
297 sprint(self, maplist_reply);
298 } else if(argv(0) == "lsmaps") {
299 sprint(self, lsmaps_reply);
300 } else if(argv(0) == "records") {
301 sprint(self, records_reply);
302 } else if(argv(0) == "voice") {
304 VoiceMessage(argv(1), substring(s, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
306 VoiceMessage(argv(1), "");
307 } else if(argv(0) == "say") {
309 Say(self, FALSE, world, substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1);
310 //clientcommand(self, formatmessage(s));
311 } else if(argv(0) == "say_team") {
313 Say(self, TRUE, world, substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1);
314 //clientcommand(self, formatmessage(s));
315 } else if(argv(0) == "tell") {
316 e = GetCommandPlayerSlotTargetFromTokenizedCommand(tokens, 1);
317 if(e && tokens > ParseCommandPlayerSlotTarget_firsttoken)
318 Say(self, FALSE, e, substring(s, argv_start_index(ParseCommandPlayerSlotTarget_firsttoken), argv_end_index(-1) - argv_start_index(ParseCommandPlayerSlotTarget_firsttoken)), 1);
320 sprint(self, "ERROR: usage: tell # playerid text...\n");
321 //clientcommand(self, formatmessage(s));
322 } else if(argv(0) == "info") {
323 cmd = cvar_string(strcat("sv_info_", argv(1)));
325 sprint(self, "ERROR: unsupported info command\n");
327 wordwrap_sprint(cmd, 1111);
328 } else if(argv(0) == "suggestmap") {
329 sprint(self, strcat(MapVote_Suggest(argv(1)), "\n"));
330 } else if(argv(0) == "timeout") {
331 if not(self.flags & FL_CLIENT)
333 if(cvar("sv_timeout")) {
334 if(self.classname == "player") {
336 sprint(self, "^7Error: you can not call a timeout while a vote is active!\n");
341 sprint(self, "^7Error: only players can call a timeout!\n");
343 } else if(argv(0) == "timein") {
344 if not(self.flags & FL_CLIENT)
346 if(cvar("sv_timeout")) {
349 } else if(argv(0) == "teamstatus") {
350 Score_NicePrint(self);
351 } else if(argv(0) == "cvar_changes") {
352 sprint(self, cvar_changes);
353 } else if(argv(0) == "pointparticles") {
354 if((sv_cheats || self.maycheat) && tokens == 5)
358 // origin (0..1, on crosshair line)
361 effectnum = particleeffectnum(argv(1));
363 start = (1-f) * self.origin + f * self.cursor_trace_endpos;
366 pointparticles(effectnum, start, end, f);
369 sprint(self, "Usage: sv_cheats 1; restart; cmd pointparticles effectname position(0..1) velocityvector multiplier\n");
370 } else if(argv(0) == "trailparticles") {
371 if((sv_cheats || self.maycheat) && tokens == 2)
375 effectnum = particleeffectnum(argv(1));
376 W_SetupShot(self, FALSE, FALSE, "",0);
377 traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
378 trailparticles(self, effectnum, w_shotorg, trace_endpos);
381 sprint(self, "Usage: sv_cheats 1; restart; cmd trailparticles effectname\n");
382 } else if(argv(0) == "make") {
383 if((sv_cheats || self.maycheat) && tokens == 3)
388 W_SetupShot(self, FALSE, FALSE, "", 0);
389 traceline(w_shotorg, w_shotorg + w_shotdir * 2048, MOVE_NORMAL, self);
390 if((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) || trace_fraction == 1)
392 sprint(self, "cannot make stuff there (bad surface)\n");
398 self.model = strzone(argv(1));
399 self.mdl = "rocket_explode";
401 self.origin = trace_endpos;
402 self.effects = EF_NOMODELFLAGS;
405 self.angles = fixedvectoangles2(trace_plane_normal, v_forward);
406 self.angles = AnglesTransform_Multiply(self.angles, '-90 0 0'); // so unrotated models work
408 spawnfunc_func_breakable();
412 tracebox(self.origin, self.mins, self.maxs, self.origin, MOVE_NORMAL, self);
415 sprint(oldself, "cannot make stuff there (no space)\n");
423 sprint(self, "Usage: sv_cheats 1; restart; cmd make models/... 0/1/2\n");
424 } else if(argv(0) == "penalty") {
425 if((sv_cheats || self.maycheat) && tokens == 3)
426 race_ImposePenaltyTime(self, stof(argv(1)), argv(2));
428 sprint(self, "Usage: sv_cheats 1; restart; cmd penalty 5.0 AHAHAHAHAHAHAH))\n");
429 } else if(argv(0) == "dragbox_spawn") {
430 if(sv_cheats || self.maycheat)
433 e.classname = "dragbox_box";
434 e.think = DragBox_Think;
436 e.solid = -1; // black
437 setmodel(e, "null"); // network it
439 e.cnt = stof(argv(1));
441 e.cnt = max(0, drag_lastcnt);
444 e.aiment.classname = "dragbox_corner_1";
446 setmodel(e.aiment, "models/marker.md3");
448 setsize(e.aiment, '0 0 0', '0 0 0');
450 setorigin(e.aiment, stov(argv(2)));
452 setorigin(e.aiment, self.cursor_trace_endpos);
455 e.enemy.classname = "dragbox_corner_2";
457 setmodel(e.enemy, "models/marker.md3");
459 setsize(e.enemy, '0 0 0', '0 0 0');
460 end = normalize(self.cursor_trace_start - e.aiment.origin);
461 end_x = (end_x > 0) * 2 - 1;
462 end_y = (end_y > 0) * 2 - 1;
463 end_z = (end_z > 0) * 2 - 1;
465 setorigin(e.enemy, stov(argv(3)));
467 setorigin(e.enemy, e.aiment.origin + 32 * end);
469 e.killindicator = spawn();
470 e.killindicator.classname = "drag_digit";
471 e.killindicator.owner = e;
472 setattachment(e.killindicator, e, "");
473 setorigin(e.killindicator, '0 0 -8');
474 e.killindicator.killindicator = spawn();
475 e.killindicator.killindicator.classname = "drag_digit";
476 e.killindicator.killindicator.owner = e;
477 setattachment(e.killindicator.killindicator, e, "");
478 setorigin(e.killindicator.killindicator, '0 0 8');
481 sprint(self, "Usage: sv_cheats 1; r_showbboxes 1.5; restart; cmd dragbox_spawn\n");
482 } else if(argv(0) == "dragpoint_spawn") {
483 if(sv_cheats || self.maycheat)
486 e.classname = "dragpoint";
487 e.think = DragBox_Think;
489 e.solid = 0; // nothing special
490 setmodel(e, "models/marker.md3");
491 setsize(e, PL_MIN, PL_MAX);
494 e.cnt = stof(argv(1));
496 e.cnt = drag_lastcnt;
498 setorigin(e, stov(argv(2)));
501 setorigin(e, self.cursor_trace_endpos + normalize(self.cursor_trace_start - self.cursor_trace_endpos));
502 move_out_of_solid(e);
505 e.killindicator = spawn();
506 e.killindicator.classname = "drag_digit";
507 e.killindicator.owner = e;
508 setattachment(e.killindicator, e, "");
509 setorigin(e.killindicator, '0 0 40');
510 e.killindicator.killindicator = spawn();
511 e.killindicator.killindicator.classname = "drag_digit";
512 e.killindicator.killindicator.owner = e;
513 setattachment(e.killindicator.killindicator, e, "");
514 setorigin(e.killindicator.killindicator, '0 0 56');
517 sprint(self, "Usage: sv_cheats 1; r_showbboxes 1.5; restart; cmd dragbox_spawn\n");
518 } else if(argv(0) == "drag_remove") {
519 if(sv_cheats || self.maycheat)
521 RandomSelection_Init();
522 for(e = world; (e = find(e, classname, "dragbox_box")); )
523 RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
524 for(e = world; (e = find(e, classname, "dragpoint")); )
525 RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
526 if(RandomSelection_chosen_ent)
528 remove(RandomSelection_chosen_ent.killindicator.killindicator);
529 remove(RandomSelection_chosen_ent.killindicator);
530 if(RandomSelection_chosen_ent.aiment)
531 remove(RandomSelection_chosen_ent.aiment);
532 if(RandomSelection_chosen_ent.enemy)
533 remove(RandomSelection_chosen_ent.enemy);
534 remove(RandomSelection_chosen_ent);
538 sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_remove\n");
539 } else if(argv(0) == "drag_setcnt") {
540 if((sv_cheats || self.maycheat) && tokens >= 2)
542 RandomSelection_Init();
543 for(e = world; (e = find(e, classname, "dragbox_box")); )
544 RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
545 for(e = world; (e = find(e, classname, "dragpoint")); )
546 RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
547 if(RandomSelection_chosen_ent)
549 if(substring(argv(1), 0, 1) == "*")
550 RandomSelection_chosen_ent.cnt = drag_lastcnt = RandomSelection_chosen_ent.cnt + stof(substring(argv(1), 1, -1));
552 RandomSelection_chosen_ent.cnt = drag_lastcnt = stof(argv(1));
556 sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_setcnt cnt\n");
557 } else if(argv(0) == "drag_save") {
558 if((sv_cheats || self.maycheat) && tokens >= 2)
560 f = fopen(argv(1), FILE_WRITE);
561 fputs(f, "cmd drag_clear\n");
562 for(e = world; (e = find(e, classname, "dragbox_box")); )
564 fputs(f, strcat("cmd dragbox_spawn ", ftos(e.cnt), " \"", vtos(e.aiment.origin), "\" \"", vtos(e.enemy.origin), "\"\n"));
566 for(e = world; (e = find(e, classname, "dragpoint")); )
568 fputs(f, strcat("cmd dragpoint_spawn ", ftos(e.cnt), " \"", vtos(e.origin), "\"\n"));
573 sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
574 } else if(argv(0) == "drag_saveraceent") {
575 if((sv_cheats || self.maycheat) && tokens >= 2)
577 f = fopen(argv(1), FILE_WRITE);
578 for(e = world; (e = find(e, classname, "dragbox_box")); )
581 fputs(f, "\"classname\" \"trigger_race_checkpoint\"\n");
582 fputs(f, strcat("\"origin\" \"", ftos(e.absmin_x), " ", ftos(e.absmin_y), " ", ftos(e.absmin_z), "\"\n"));
583 fputs(f, strcat("\"maxs\" \"", ftos(e.absmax_x - e.absmin_x), " ", ftos(e.absmax_y - e.absmin_y), " ", ftos(e.absmax_z - e.absmin_z), "\"\n"));
584 fputs(f, strcat("\"cnt\" \"", ftos(e.cnt), "\"\n"));
585 fputs(f, strcat("\"targetname\" \"checkpoint", ftos(e.cnt), "\"\n"));
588 for(e = world; (e = find(e, classname, "dragpoint")); )
592 for(oldself = world; (oldself = find(oldself, classname, "dragbox_box")); )
594 if(e.cnt <= 0 && oldself.cnt == 0 || e.cnt == oldself.cnt)
596 start = start + oldself.origin;
600 start *= 1 / effectnum;
602 fputs(f, "\"classname\" \"info_player_race\"\n");
603 fputs(f, strcat("\"angle\" \"", ftos(vectoyaw(start - e.origin)), "\"\n"));
604 fputs(f, strcat("\"origin\" \"", ftos(e.origin_x), " ", ftos(e.origin_y), " ", ftos(e.origin_z), "\"\n"));
607 fputs(f, "\"target\" \"checkpoint0\"\n");
608 fputs(f, "\"race_place\" \"0\"\n");
612 fputs(f, "\"target\" \"checkpoint0\"\n");
613 fputs(f, "\"race_place\" \"-1\"\n");
617 fputs(f, strcat("\"target\" \"checkpoint", ftos(e.cnt), "\"\n"));
620 // these need race_place
623 for(oldself = world; (oldself = find(oldself, classname, "dragpoint")); )
626 if(vlen(oldself.origin - start) < vlen(e.origin - start))
628 else if(vlen(oldself.origin - start) == vlen(e.origin - start) && num_for_edict(oldself) < num_for_edict(e))
631 fputs(f, strcat("\"race_place\" \"", ftos(effectnum), "\"\n"));
639 sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_save filename\n");
640 } else if(argv(0) == "drag_clear") {
641 if(sv_cheats || self.maycheat)
643 for(e = world; (e = find(e, classname, "dragbox_box")); )
645 for(e = world; (e = find(e, classname, "dragbox_corner_1")); )
647 for(e = world; (e = find(e, classname, "dragbox_corner_2")); )
649 for(e = world; (e = find(e, classname, "dragpoint")); )
651 for(e = world; (e = find(e, classname, "drag_digit")); )
655 sprint(self, "Usage: sv_cheats 1; restart; cmd dragbox_clear\n");
657 //if(ctf_clientcommand())
660 // grep for Cmd_AddCommand_WithClientCommand to find them all
668 if(cmd != "notarget")
672 //if(cmd != "say") // handled above
673 //if(cmd != "say_team") // handled above
682 if(cmd != "playermodel")
683 if(cmd != "playerskin")
684 if(cmd != "prespawn")
688 if(cmd != "sv_startdownload")
689 if(cmd != "download")
691 print("WARNING: Invalid clientcommand by ", self.netname, ": ", s, "\n");
695 if(self.jointime > 0 && time > self.jointime + 10 && time > self.nickspamtime) // allow any changes in the first 10 seconds since joining
696 if(cmd == "name" || cmd == "playermodel") // TODO also playerskin and color?
698 if(self.nickspamtime == 0 || time > self.nickspamtime + cvar("g_nick_flood_timeout"))
699 // good, no serious flood
700 self.nickspamcount = 1;
702 self.nickspamcount += 1;
703 self.nickspamtime = time + cvar("g_nick_flood_penalty");
705 if (timeoutStatus == 2) //when game is paused, no flood protection
706 self.nickspamcount = self.nickspamtime = 0;
709 clientcommand(self,s);
713 void ReadyRestartForce()
717 bprint("^1Server is restarting...\n");
722 if (checkrules_overtimesadded > 0 && g_race_qualifying != 2) {
723 //we have to decrease timelimit to its original value again!!
725 newTL = cvar("timelimit");
726 newTL -= checkrules_overtimesadded * cvar("timelimit_overtime");
727 cvar_set("timelimit", ftos(newTL));
730 checkrules_suddendeathend = checkrules_overtimesadded = checkrules_suddendeathwarning = 0;
733 readyrestart_happened = 1;
734 game_starttime = time + RESTART_COUNTDOWN;
735 restart_mapalreadyrestarted = 0; //reset this var, needed when cvar sv_ready_restart_repeatable is in use
737 inWarmupStage = 0; //once the game is restarted the game is in match stage
739 //reset the .ready status of all players (also spectators)
740 FOR_EACH_CLIENTSLOT(e)
743 Nagger_ReadyCounted(); // NOTE: this causes a resend of that entity, and will also turn off warmup state on the client
745 if(cvar("teamplay_lockonrestart") && teams_matter) {
747 bprint("^1The teams are now locked.\n");
750 //initiate the restart-countdown-announcer entity
751 if(cvar("sv_ready_restart_after_countdown"))
753 restartTimer = spawn();
754 restartTimer.think = restartTimer_Think;
755 restartTimer.nextthink = game_starttime;
758 //after a restart every players number of allowed timeouts gets reset, too
759 if(cvar("sv_timeout"))
761 FOR_EACH_REALPLAYER(e)
762 e.allowedTimeouts = cvar("sv_timeout_number");
765 //reset map immediately if this cvar is not set
766 if (!cvar("sv_ready_restart_after_countdown"))
769 if(cvar("sv_eventlog"))
770 GameLogEcho(":restart");
775 // no arena, assault support yet...
776 if(g_arena | g_assault | gameover | intermission_running | race_completing)
777 localcmd("restart\n");
781 // reset ALL scores, but only do that at the beginning
782 //of the countdown if sv_ready_restart_after_countdown is off!
783 //Otherwise scores could be manipulated during the countdown!
784 if (!cvar("sv_ready_restart_after_countdown"))
789 * Counts how many players are ready. If not enough players are ready, the function
790 * does nothing. If all players are ready, the timelimit will be extended and the
791 * restart_countdown variable is set to allow other functions like PlayerPostThink
792 * to detect that the countdown is now active. If the cvar sv_ready_restart_after_countdown
793 * is not set the map will be resetted.
795 * Function is called after the server receives a 'ready' sign from a player.
804 FOR_EACH_REALPLAYER(e)
813 Nagger_ReadyCounted();
815 if(r) // at least one is ready
816 if(r == p) // and, everyone is ready
821 * Restarts the map after the countdown is over (and cvar sv_ready_restart_after_countdown
824 void restartTimer_Think() {
825 restart_mapalreadyrestarted = 1;
833 * Checks whether the player who calls the timeout is allowed to do so.
834 * If so, it initializes the timeout countdown. It also checks whether another
835 * timeout was already running at this time and reacts correspondingly.
837 * affected globals/fields: .allowedTimeouts, remainingTimeoutTime, remainingLeadTime,
838 * timeoutInitiator, timeoutStatus, timeoutHandler
840 * This function is called when a player issues the calltimeout command.
842 void evaluateTimeout() {
843 if (inWarmupStage && !g_warmup_allow_timeout)
844 return sprint(self, "^7Error: You can not call a timeout in warmup-stage!\n");
845 if (time < game_starttime )
846 return sprint(self, "^7Error: You can not call a timeout while the map is being restarted!\n");
847 if (timeoutStatus != 2) {
848 //if the map uses a timelimit make sure that timeout cannot be called right before the map ends
849 if (cvar("timelimit")) {
850 //a timelimit was used
852 myTl = cvar("timelimit");
854 local float lastPossibleTimeout;
855 lastPossibleTimeout = (myTl*60) - cvar("sv_timeout_leadtime") - 1;
857 if (lastPossibleTimeout < time - game_starttime)
858 return sprint(self, "^7Error: It is too late to call a timeout now!\n");
861 //player may not call a timeout if he has no calls left
862 if (self.allowedTimeouts < 1)
863 return sprint(self, "^7Error: You already used all your timeout calls for this map!\n");
864 //now all required checks are passed
865 self.allowedTimeouts -= 1;
866 bprint(self.netname, " ^7called a timeout (", ftos(self.allowedTimeouts), " timeouts left)!\n"); //write a bprint who started the timeout (and how many he has left)
867 remainingTimeoutTime = cvar("sv_timeout_length");
868 remainingLeadTime = cvar("sv_timeout_leadtime");
869 timeoutInitiator = self;
870 if (timeoutStatus == 0) { //if another timeout was already active, don't change its status (which was 1 or 2) to 1, only change it to 1 if no timeout was active yet
872 //create the timeout indicator which centerprints the information to all players and takes care of pausing/unpausing
873 timeoutHandler = spawn();
874 timeoutHandler.think = timeoutHandler_Think;
876 timeoutHandler.nextthink = time; //always let the entity think asap
878 //inform all connected clients about the timeout call
879 play2all("announcer/robotic/timeoutcalled.wav");
883 * Checks whether a player is allowed to resume the game. If he is allowed to do it,
884 * and the lead time for the timeout is still active, this countdown just will be aborted (the
885 * game will never be paused). Otherwise the remainingTimeoutTime will be set to the corresponding
886 * value of the cvar sv_timeout_resumetime.
888 * This function is called when a player issues the resumegame command.
890 void evaluateTimein() {
892 return sprint(self, "^7Error: There is no active timeout which could be aborted!\n");
893 if (self != timeoutInitiator)
894 return sprint(self, "^7Error: You may not abort the active timeout. Only the player who called it can do that!\n");
895 if (timeoutStatus == 1) {
896 remainingTimeoutTime = timeoutStatus = 0;
897 timeoutHandler.nextthink = time; //timeoutHandler has to take care of it immediately
898 bprint(strcat("^7The timeout was aborted by ", self.netname, " !\n"));
900 else if (timeoutStatus == 2) {
901 //only shorten the remainingTimeoutTime if it makes sense
902 if( remainingTimeoutTime > (cvar("sv_timeout_resumetime") + 1) ) {
903 bprint(strcat("^1Attention: ^7", self.netname, " resumed the game! Prepare for battle!\n"));
904 remainingTimeoutTime = cvar("sv_timeout_resumetime");
905 timeoutHandler.nextthink = time; //timeoutHandler has to take care of it immediately
908 sprint(self, "^7Error: Your resumegame call was discarded!\n");