2 entity ctf_worldflaglist; // CTF flags in the map
3 .entity ctf_worldflagnext;
5 .float next_take_time; // the next time a player can pick up a flag (time + blah)
6 /// I used this, in part, to fix the looping score bug. - avirox
7 //float FLAGSCORE_PICKUP = 1;
8 //float FLAGSCORE_RETURN = 5; // returned by owner team
9 //float FLAGSCORE_RETURNROGUE = 10; // returned by rogue team
10 //float FLAGSCORE_CAPTURE = 5;
12 #define FLAG_CARRY_POS '-15 0 7'
14 float ctf_score_value(string parameter)
16 if(g_ctf_win_mode != 2)
17 return cvar(strcat("g_ctf_personal", parameter));
19 return cvar(strcat("g_ctf_flag", parameter));
22 void FakeTimeLimit(entity e, float t)
25 WriteByte(MSG_ONE, 3); // svc_updatestat
26 WriteByte(MSG_ONE, 236); // STAT_TIMELIMIT
28 WriteCoord(MSG_ONE, cvar("timelimit"));
30 WriteCoord(MSG_ONE, (t + 1) / 60);
33 float flagcaptimerecord;
34 .float flagpickuptime;
44 self.t_width = 0.1; // frame animation rate
46 self.t_length = 119; // maximum frame
48 setattachment(self, world, "");
49 self.mdl = self.model;
51 self.solid = SOLID_TRIGGER;
52 self.movetype = MOVETYPE_NONE;
53 self.velocity = '0 0 0';
54 self.origin_z = self.origin_z + 6;
55 self.think = FlagThink;
56 self.touch = FlagTouch;
57 self.nextthink = time + 0.1;
59 self.mangle = self.angles;
60 self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
61 //self.effects = self.effects | EF_DIMLIGHT;
64 self.dropped_origin = self.origin;
69 self.movetype = MOVETYPE_TOSS;
73 void LogCTF(string mode, float flagteam, entity actor)
76 if(!cvar("sv_eventlog"))
78 s = strcat(":ctf:", mode);
79 s = strcat(s, ":", ftos(flagteam));
81 s = strcat(s, ":", ftos(actor.playerid));
85 void RegenFlag(entity e)
87 setattachment(e, world, "");
88 e.damageforcescale = 0;
89 e.movetype = MOVETYPE_NONE;
91 e.movetype = MOVETYPE_TOSS;
92 e.solid = SOLID_TRIGGER;
93 // TODO: play a sound here
94 setorigin(e, e.dropped_origin);
98 e.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
101 void ReturnFlag(entity e)
104 if (e.owner.flagcarried == e)
106 WaypointSprite_DetachCarrier(e.owner);
107 e.owner.flagcarried = world;
110 FakeTimeLimit(e.owner, -1);
116 void DropFlag(entity e, entity penalty_receiver, entity attacker)
128 dprint("FLAG: drop - no owner?!?!\n");
132 if (p.flagcarried != e)
134 dprint("FLAG: drop - owner is not carrying this flag??\n");
137 bprint(p.netname, "^7 lost the ", e.netname, "\n");
140 UpdateFrags(penalty_receiver, -ctf_score_value("penalty_suicidedrop"));
142 UpdateFrags(p, -ctf_score_value("penalty_drop"));
143 PlayerScore_Add(p, SP_CTF_DROPS, +1);
144 e.playerid = attacker.playerid;
146 WaypointSprite_Ping(p.waypointsprite_attachedforcarrier);
147 WaypointSprite_DetachCarrier(p);
148 LogCTF("dropped", p.team, p);
150 setattachment(e, world, "");
151 e.damageforcescale = cvar("g_balance_ctf_damageforcescale");
153 if (p.flagcarried == e)
154 p.flagcarried = world;
157 e.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
158 e.solid = SOLID_TRIGGER;
159 e.movetype = MOVETYPE_TOSS;
160 // setsize(e, '-16 -16 0', '16 16 74');
161 setorigin(e, p.origin - '0 0 24' + '0 0 37');
162 e.cnt = FLAG_DROPPED;
163 e.velocity = '0 0 300';
164 e.pain_finished = time + cvar("g_ctf_flag_returntime");//30;
166 trace_startsolid = FALSE;
167 tracebox(e.origin, e.mins, e.maxs, e.origin, TRUE, e);
169 dprint("FLAG FALLTHROUGH will happen SOON\n");
174 if(self.delay > time)
176 self.delay = time + self.t_width;
177 if(self.nextthink > self.delay)
178 self.nextthink = self.delay;
180 self.frame = self.frame + 1;
181 if(self.frame > self.t_length)
189 self.nextthink = time + 0.1;
193 if(self.speedrunning)
194 if(self.cnt == FLAG_CARRY)
197 if(flagcaptimerecord)
198 if(time >= self.flagpickuptime + flagcaptimerecord)
200 bprint("The ", self.netname, " became impatient after ", ftos_decimals(flagcaptimerecord, 2), " seconds and returned itself\n");
202 self.owner.impulse = 77; // returning!
212 if (self.cnt == FLAG_BASE)
215 if (self.cnt == FLAG_DROPPED)
217 // flag fallthrough? FIXME remove this if bug is really fixed now
218 if(self.origin_z < -131072)
220 dprint("FLAG FALLTHROUGH just happened\n");
221 self.pain_finished = 0;
223 setattachment(self, world, "");
224 if (time > self.pain_finished)
226 bprint("The ", self.netname, " has returned to base\n");
227 sound (self, CHAN_TRIGGER, self.noise3, VOL_BASE, ATTN_NONE);
228 LogCTF("returned", self.team, world);
235 if (e.classname != "player" || (e.deadflag) || (e.flagcarried != self))
237 dprint("CANNOT HAPPEN - player dead and STILL had a flag!\n");
238 DropFlag(self, world, world);
249 local string s, s0, h0, h1;
250 if (other.classname != "player")
252 if (other.health < 1) // ignore dead players
255 if (self.cnt == FLAG_CARRY)
258 if (self.cnt == FLAG_BASE)
259 if (other.team == self.team)
260 if (other.flagcarried) // he's got a flag
261 if (other.flagcarried.team != self.team) // capture
263 if (other.flagcarried == world)
267 t = time - other.flagcarried.flagpickuptime;
268 s = ftos_decimals(t, 2);
269 s0 = ftos_decimals(flagcaptimerecord, 2);
270 h0 = db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"));
275 h0 = strcat(h0, "^7's"); // h0: display text for previous netname
276 if (flagcaptimerecord == 0)
278 bprint(other.netname, "^7 captured the ", other.flagcarried.netname, " in ", s, " seconds\n");
279 flagcaptimerecord = t;
280 db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"), ftos(t));
281 db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"), h1);
282 GameLogEcho(strcat(":recordset:", ftos(other.playerid), ":", ftos(t)));
284 else if (t < flagcaptimerecord)
286 bprint(other.netname, "^7 captured the ", other.flagcarried.netname, " in ", s, ", breaking ", strcat(h0, " previous record of ", s0, " seconds\n"));
287 flagcaptimerecord = t;
288 db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"), ftos(t));
289 db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"), h1);
290 GameLogEcho(strcat(":recordset:", ftos(other.playerid), ":", ftos(t)));
294 bprint(other.netname, "^7 captured the ", other.flagcarried.netname, " in ", s, ", failing to break ", strcat(h0, " record of ", s0, " seconds\n"));
297 PlayerTeamScore_Add(other, SP_CTF_CAPS, ST_CTF_CAPS, 1);
298 LogCTF("capture", other.flagcarried.team, other);
299 // give credit to the individual player
300 UpdateFrags(other, ctf_score_value("score_capture"));
302 sound (other, CHAN_AUTO, self.noise2, VOL_BASE, ATTN_NONE);
303 WaypointSprite_DetachCarrier(other);
304 if(self.speedrunning)
305 FakeTimeLimit(other, -1);
306 RegenFlag (other.flagcarried);
307 other.flagcarried = world;
308 other.next_take_time = time + 1;
310 if (self.cnt == FLAG_BASE)
311 if (other.team == COLOR_TEAM1 || other.team == COLOR_TEAM2) // only red and blue team can steal flags
312 if (other.team != self.team)
313 if (!other.flagcarried)
315 if (other.next_take_time > time)
318 self.flagpickuptime = time; // used for timing runs
319 self.speedrunning = other.speedrunning; // if speedrunning, flag will self-return and teleport the owner back after the record
320 if(other.speedrunning)
321 if(flagcaptimerecord)
322 FakeTimeLimit(other, time + flagcaptimerecord);
323 self.solid = SOLID_NOT;
324 setorigin(self, self.origin); // relink
326 other.flagcarried = self;
327 self.cnt = FLAG_CARRY;
328 self.angles = '0 0 0';
329 bprint(other.netname, "^7 got the ", self.netname, "\n");
330 UpdateFrags(other, ctf_score_value("score_pickup_base"));
331 PlayerScore_Add(other, SP_CTF_PICKUPS, 1);
332 LogCTF("steal", self.team, other);
333 sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NONE);
335 FOR_EACH_PLAYER(player)
336 if(player.team == self.team)
337 centerprint(player, "The enemy got your flag! Retrieve it!");
339 self.movetype = MOVETYPE_NONE;
340 setorigin(self, FLAG_CARRY_POS);
341 setattachment(self, other, "");
342 WaypointSprite_AttachCarrier("flagcarrier", other);
343 WaypointSprite_UpdateTeamRadar(other.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, '1 1 0');
344 WaypointSprite_Ping(self.sprite);
349 if (self.cnt == FLAG_DROPPED)
351 self.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
352 if (other.team == self.team || (other.team != COLOR_TEAM1 && other.team != COLOR_TEAM2))
355 bprint(other.netname, "^7 returned the ", self.netname, "\n");
357 // punish the player who last had it
358 FOR_EACH_PLAYER(player)
359 if(player.playerid == self.playerid)
360 PlayerScore_Add(player, SP_SCORE, -ctf_score_value("penalty_returned"));
362 // punish the team who was last carrying it
363 if(self.team == COLOR_TEAM1)
364 TeamScore_AddToTeam(COLOR_TEAM2, ST_SCORE, -ctf_score_value("penalty_returned"));
366 TeamScore_AddToTeam(COLOR_TEAM1, ST_SCORE, -ctf_score_value("penalty_returned"));
368 // reward the player who returned it
369 if(other.playerid == self.playerid) // is this the guy who killed the FC last?
371 if (other.team == COLOR_TEAM1 || other.team == COLOR_TEAM2)
372 UpdateFrags(other, ctf_score_value("score_return_by_killer"));
374 UpdateFrags(other, ctf_score_value("score_return_rogue_by_killer"));
378 if (other.team == COLOR_TEAM1 || other.team == COLOR_TEAM2)
379 UpdateFrags(other, ctf_score_value("score_return"));
381 UpdateFrags(other, ctf_score_value("score_return_rogue"));
383 PlayerScore_Add(other, SP_CTF_RETURNS, 1);
384 LogCTF("return", self.team, other);
385 sound (other, CHAN_AUTO, self.noise1, VOL_BASE, ATTN_NONE);
388 else if (!other.flagcarried)
391 self.solid = SOLID_NOT;
392 setorigin(self, self.origin); // relink
394 other.flagcarried = self;
395 self.cnt = FLAG_CARRY;
396 bprint(other.netname, "^7 picked up the ", self.netname, "\n");
399 f = bound(0, (self.pain_finished - time) / cvar("g_ctf_flag_returntime"), 1);
400 //print("factor is ", ftos(f), "\n");
401 f = ctf_score_value("score_pickup_dropped_late") * (1-f)
402 + ctf_score_value("score_pickup_dropped_early") * f;
404 //print("score is ", ftos(f), "\n");
406 UpdateFrags(other, f);
407 PlayerScore_Add(other, SP_CTF_PICKUPS, 1);
408 LogCTF("pickup", self.team, other);
409 sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NONE);
411 FOR_EACH_PLAYER(player)
412 if(player.team == self.team)
413 centerprint(player, "The enemy got your flag! Retrieve it!");
415 self.movetype = MOVETYPE_NONE; // flag must have MOVETYPE_NONE here, otherwise it will drop through the floor...
416 setorigin(self, FLAG_CARRY_POS);
417 setattachment(self, other, "");
418 self.damageforcescale = 0;
419 WaypointSprite_AttachCarrier("flagcarrier", other);
420 WaypointSprite_UpdateTeamRadar(other.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, '1 1 0');
425 /*QUAKED spawnfunc_info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24)
426 CTF Starting point for a player
431 viewing angle when spawning
433 void spawnfunc_info_player_team1()
435 self.team = COLOR_TEAM1; // red
436 spawnfunc_info_player_deathmatch();
438 //self.team = 4;self.classname = "info_player_start";spawnfunc_info_player_start();};
440 /*QUAKED spawnfunc_info_player_team2 (1 0 0) (-16 -16 -24) (16 16 24)
441 CTF Starting point for a player in
446 viewing angle when spawning
448 void spawnfunc_info_player_team2()
450 self.team = COLOR_TEAM2; // blue
451 spawnfunc_info_player_deathmatch();
453 //self.team = 13;self.classname = "info_player_start";spawnfunc_info_player_start();};
455 /*QUAKED spawnfunc_info_player_team3 (1 0 0) (-16 -16 -24) (16 16 24)
456 CTF Starting point for a player in
457 team three (Magenta).
461 viewing angle when spawning
463 void spawnfunc_info_player_team3()
465 self.team = COLOR_TEAM3; // purple
466 spawnfunc_info_player_deathmatch();
470 /*QUAKED spawnfunc_info_player_team4 (1 0 0) (-16 -16 -24) (16 16 24)
471 CTF Starting point for a player in
476 viewing angle when spawning
478 void spawnfunc_info_player_team4()
480 self.team = COLOR_TEAM4; // yellow
481 spawnfunc_info_player_deathmatch();
487 /*QUAKED spawnfunc_item_flag_team1 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
488 CTF flag for team one (Red).
489 Multiple are allowed.
493 Angle the flag will point
496 model to use, note this needs red and blue as skins 0 and 1
497 (default models/ctf/flag.md3)
499 sound played when flag is picked up
500 (default ctf/take.wav)
502 sound played when flag is returned by a teammate
503 (default ctf/return.wav)
505 sound played when flag is captured
506 (default ctf/redcapture.wav)
508 sound played when flag is lost in the field and respawns itself
509 (default ctf/respawn.wav)
512 void spawnfunc_item_flag_team1()
520 //if(!cvar("teamplay"))
521 // cvar_set("teamplay", "3");
523 // link flag into ctf_worldflaglist
524 self.ctf_worldflagnext = ctf_worldflaglist;
525 ctf_worldflaglist = self;
527 self.classname = "item_flag_team";
528 self.team = COLOR_TEAM1; // color 4 team (red)
529 self.items = IT_KEY2; // gold key (redish enough)
530 self.netname = "^1RED^7 flag";
531 self.target = "###item###";
533 if(self.spawnflags & 1)
536 self.model = "models/ctf/flag_red.md3";
538 self.noise = "ctf/take.wav";
540 self.noise1 = "ctf/return.wav";
542 self.noise2 = "ctf/redcapture.wav"; // blue team scores by capturing the red flag
544 self.noise3 = "ctf/respawn.wav";
545 precache_model (self.model);
546 setmodel (self, self.model); // precision set below
547 precache_sound (self.noise);
548 precache_sound (self.noise1);
549 precache_sound (self.noise2);
550 precache_sound (self.noise3);
551 //setsize(self, '-16 -16 -37', '16 16 37');
552 setsize(self, PL_MIN + '0 0 -13', PL_MAX + '0 0 -13');
553 setorigin(self, self.origin + '0 0 37');
554 self.nextthink = time + 0.2; // start after doors etc
555 self.think = place_flag;
559 //if(!self.glow_size)
560 // self.glow_size = 50;
562 self.effects = self.effects | EF_LOWPRECISION;
563 if(cvar("g_ctf_fullbrightflags"))
564 self.effects |= EF_FULLBRIGHT;
566 waypoint_spawnforitem(self);
568 WaypointSprite_SpawnFixed("redbase", self.origin + '0 0 37', self, sprite);
569 WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_FLAG, '1 0 0');
572 /*QUAKED spawnfunc_item_flag_team2 (0 0.5 0.8) (-48 -48 -24) (48 48 64)
573 CTF flag for team two (Blue).
574 Multiple are allowed.
578 Angle the flag will point
581 model to use, note this needs red and blue as skins 0 and 1
582 (default models/ctf/flag.md3)
584 sound played when flag is picked up
585 (default ctf/take.wav)
587 sound played when flag is returned by a teammate
588 (default ctf/return.wav)
590 sound played when flag is captured
591 (default ctf/bluecapture.wav)
593 sound played when flag is lost in the field and respawns itself
594 (default ctf/respawn.wav)
597 void spawnfunc_item_flag_team2()
604 //if(!cvar("teamplay"))
605 // cvar_set("teamplay", "3");
607 // link flag into ctf_worldflaglist
608 self.ctf_worldflagnext = ctf_worldflaglist;
609 ctf_worldflaglist = self;
611 self.classname = "item_flag_team";
612 self.team = COLOR_TEAM2; // color 13 team (blue)
613 self.items = IT_KEY1; // silver key (bluish enough)
614 self.netname = "^4BLUE^7 flag";
615 self.target = "###item###";
617 if(self.spawnflags & 1)
620 self.model = "models/ctf/flag_blue.md3";
622 self.noise = "ctf/take.wav";
624 self.noise1 = "ctf/return.wav";
626 self.noise2 = "ctf/bluecapture.wav"; // red team scores by capturing the blue flag
628 self.noise3 = "ctf/respawn.wav";
629 precache_model (self.model);
630 setmodel (self, self.model); // precision set below
631 precache_sound (self.noise);
632 precache_sound (self.noise1);
633 precache_sound (self.noise2);
634 precache_sound (self.noise3);
635 //setsize(self, '-16 -16 -37', '16 16 37');
636 setsize(self, PL_MIN + '0 0 -13', PL_MAX + '0 0 -13');
637 setorigin(self, self.origin + '0 0 37');
638 self.nextthink = time + 0.2; // start after doors etc
639 self.think = place_flag;
643 //if(!self.glow_size)
644 // self.glow_size = 50;
646 self.effects = self.effects | EF_LOWPRECISION;
647 if(cvar("g_ctf_fullbrightflags"))
648 self.effects |= EF_FULLBRIGHT;
650 waypoint_spawnforitem(self);
652 WaypointSprite_SpawnFixed("bluebase", self.origin + '0 0 37', self, sprite);
653 WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_FLAG, '0 0 1');
657 /*QUAKED spawnfunc_ctf_team (0 .5 .8) (-16 -16 -24) (16 16 32)
658 Team declaration for CTF gameplay, this allows you to decide what team
659 names and control point models are used in your map.
661 Note: If you use spawnfunc_ctf_team entities you must define at least 2! However, unlike
662 domination, you don't need to make a blank one too.
666 Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)
668 Scoreboard color of the team (for example 4 is red and 13 is blue)
672 void spawnfunc_ctf_team()
679 self.classname = "ctf_team";
680 self.team = self.cnt + 1;
683 // code from here on is just to support maps that don't have control point and team entities
684 void ctf_spawnteam (string teamname, float teamcolor)
686 local entity oldself;
689 self.classname = "ctf_team";
690 self.netname = teamname;
691 self.cnt = teamcolor;
693 spawnfunc_ctf_team();
698 // spawn some default teams if the map is not set up for ctf
699 void ctf_spawnteams()
703 numteams = 2;//cvar("g_ctf_default_teams");
705 ctf_spawnteam("Red", COLOR_TEAM1 - 1);
706 ctf_spawnteam("Blue", COLOR_TEAM2 - 1);
709 void ctf_delayedinit()
711 // if no teams are found, spawn defaults
712 if (find(world, classname, "ctf_team") == world)
720 InitializeEntity(world, ctf_delayedinit, INITPRIO_GAMETYPE);
721 flagcaptimerecord = stof(db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time")));
724 void ctf_setstatus2(entity flag, float shift)
726 if (flag.cnt == FLAG_CARRY)
727 if (flag.owner == self)
728 self.items |= shift * 3;
730 self.items |= shift * 1;
731 else if (flag.cnt == FLAG_DROPPED)
732 self.items |= shift * 2;
741 self.items = self.items - (self.items & IT_RED_FLAG_TAKEN);
742 self.items = self.items - (self.items & IT_RED_FLAG_LOST);
743 self.items = self.items - (self.items & IT_BLUE_FLAG_TAKEN);
744 self.items = self.items - (self.items & IT_BLUE_FLAG_LOST);
748 float redflags, blueflags;
753 for (flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) if(flag.cnt != FLAG_BASE)
755 if(flag.team == COLOR_TEAM1)
757 else if(flag.team == COLOR_TEAM2)
761 // blinking magic: if there is more than one flag, show one of these in a clever way
763 redflags = mod(floor(time * redflags * 0.75), redflags);
765 blueflags = mod(floor(time * blueflags * 0.75), blueflags);
767 for (flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) if(flag.cnt != FLAG_BASE)
769 if(flag.team == COLOR_TEAM1)
771 if(--redflags == -1) // happens exactly once (redflags is in 0..count-1, and will --'ed count times)
772 ctf_setstatus2(flag, IT_RED_FLAG_TAKEN);
774 else if(flag.team == COLOR_TEAM2)
776 if(--blueflags == -1) // happens exactly once
777 ctf_setstatus2(flag, IT_BLUE_FLAG_TAKEN);
783 entity(float cteam) ctf_team_has_commander =
786 if(cteam != COLOR_TEAM1 || cteam != COLOR_TEAM2)
789 FOR_EACH_REALPLAYER(pl) {
790 if(pl.team == cteam && pl.iscommander) {
797 void(entity e, float st) ctf_setstate =
803 void(float cteam) ctf_new_commander =
808 FOR_EACH_REALPLAYER(pl) {
809 if(pl.team == cteam) {
810 if(pl.iscommander) { // don't reassign if alreay there
813 if(plmax == world || plmax.frags < pl.frags) <<<<<<<<<<<<<<<<< BROKEN in new scoring system
818 bprint(strcat(ColoredTeamName(cteam), " Team has no Commander!\n"));
822 plmax.iscommander = TRUE;
823 ctf_setstate(plmax, 3);
824 sprint(plmax, "^3You're the commander now!\n");
825 centerprint(plmax, "^3You're the commander now!\n");
828 void() ctf_clientconnect =
830 self.iscommander = FALSE;
832 if(!self.team || self.classname != "player") {
833 ctf_setstate(self, -1);
835 ctf_setstate(self, 0);
837 self.team_saved = self.team;
839 if(self.team != 0 && self.classname == "player" && !ctf_team_has_commander(self.team)) {
840 ctf_new_commander(self.team);
844 void() ctf_playerchanged =
846 if(!self.team || self.classname != "player") {
847 ctf_setstate(self, -1);
848 } else if(self.ctf_state < 0 && self.classname == "player") {
849 ctf_setstate(self, 0);
852 if(self.iscommander &&
853 (self.classname != "player" || self.team != self.team_saved)
856 self.iscommander = FALSE;
857 if(self.classname == "player")
858 ctf_setstate(self, 0);
860 ctf_setstate(self, -1);
861 ctf_new_commander(self.team_saved);
864 self.team_saved = self.team;
866 ctf_new_commander(self.team);
869 void() ctf_clientdisconnect =
873 ctf_new_commander(self.team);
877 entity GetPlayer(string);
878 float() ctf_clientcommand =
881 if(argv(0) == "order") {
883 sprint(self, "This command is not supported in this gamemode.\n");
886 if(!self.iscommander) {
887 sprint(self, "^1You are not the commander!\n");
891 sprint(self, "Usage: order #player status - (playernumber as in status)\n");
894 e = GetPlayer(argv(1));
896 sprint(self, "Invalid player.\nUsage: order #player status - (playernumber as in status)\n");
899 if(e.team != self.team) {
900 sprint(self, "^3You can only give orders to your own team!\n");
903 if(argv(2) == "attack") {
904 sprint(self, strcat("Ordering ", e.netname, " to attack!\n"));
905 sprint(e, "^1Attack!\n");
906 centerprint(e, "^7You've been ordered to^9\n^1Attack!\n");
908 } else if(argv(2) == "defend") {
909 sprint(self, strcat("Ordering ", e.netname, " to defend!\n"));
910 sprint(e, "^Defend!\n");
911 centerprint(e, "^7You've been ordered to^9\n^2Defend!\n");
914 sprint(self, "^7Invalid command, use ^3attack^7, or ^3defend^7.\n");