2 entity ctf_worldflaglist; // CTF flags in the map
3 .entity ctf_worldflagnext;
7 .float next_take_time; // the next time a player can pick up a flag (time + blah)
8 /// I used this, in part, to fix the looping score bug. - avirox
9 //float FLAGSCORE_PICKUP = 1;
10 //float FLAGSCORE_RETURN = 5; // returned by owner team
11 //float FLAGSCORE_RETURNROGUE = 10; // returned by rogue team
12 //float FLAGSCORE_CAPTURE = 5;
14 #define FLAG_CARRY_POS '-15 0 7'
16 float ctf_score_value(string parameter)
18 if(g_ctf_win_mode != 2)
19 return cvar(strcat("g_ctf_personal", parameter));
21 return cvar(strcat("g_ctf_flag", parameter));
24 void FakeTimeLimit(entity e, float t)
27 WriteByte(MSG_ONE, 3); // svc_updatestat
28 WriteByte(MSG_ONE, 236); // STAT_TIMELIMIT
30 WriteCoord(MSG_ONE, cvar("timelimit"));
32 WriteCoord(MSG_ONE, (t + 1) / 60);
35 float flagcaptimerecord;
36 .float flagpickuptime;
46 self.t_width = 0.1; // frame animation rate
48 self.t_length = 119; // maximum frame
50 setattachment(self, world, "");
51 self.mdl = self.model;
53 self.solid = SOLID_TRIGGER;
54 self.movetype = MOVETYPE_NONE;
55 self.velocity = '0 0 0';
56 self.origin_z = self.origin_z + 6;
57 self.think = FlagThink;
58 self.touch = FlagTouch;
59 self.nextthink = time + 0.1;
61 self.mangle = self.angles;
62 self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
63 //self.effects = self.effects | EF_DIMLIGHT;
66 self.dropped_origin = self.origin;
71 self.movetype = MOVETYPE_TOSS;
75 void LogCTF(string mode, float flagteam, entity actor)
78 if(!cvar("sv_eventlog"))
80 s = strcat(":ctf:", mode);
81 s = strcat(s, ":", ftos(flagteam));
83 s = strcat(s, ":", ftos(actor.playerid));
87 void RegenFlag(entity e)
89 setattachment(e, world, "");
90 e.damageforcescale = 0;
91 e.movetype = MOVETYPE_NONE;
93 e.movetype = MOVETYPE_TOSS;
94 e.solid = SOLID_TRIGGER;
95 // TODO: play a sound here
96 setorigin(e, e.dropped_origin);
100 e.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
103 void ReturnFlag(entity e)
106 if (e.owner.flagcarried == e)
108 WaypointSprite_DetachCarrier(e.owner);
109 e.owner.flagcarried = world;
112 FakeTimeLimit(e.owner, -1);
118 void DropFlag(entity e, entity penalty_receiver, entity attacker)
130 dprint("FLAG: drop - no owner?!?!\n");
134 if (p.flagcarried != e)
136 dprint("FLAG: drop - owner is not carrying this flag??\n");
139 bprint(p.netname, "^7 lost the ", e.netname, "\n");
142 UpdateFrags(penalty_receiver, -ctf_score_value("penalty_suicidedrop"));
144 UpdateFrags(p, -ctf_score_value("penalty_drop"));
145 PlayerScore_Add(p, SP_CTF_DROPS, +1);
146 e.playerid = attacker.playerid;
147 e.ctf_droptime = time;
149 WaypointSprite_Ping(p.waypointsprite_attachedforcarrier);
150 WaypointSprite_DetachCarrier(p);
151 LogCTF("dropped", p.team, p);
153 setattachment(e, world, "");
154 e.damageforcescale = cvar("g_balance_ctf_damageforcescale");
156 if (p.flagcarried == e)
157 p.flagcarried = world;
160 e.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
161 e.solid = SOLID_TRIGGER;
162 e.movetype = MOVETYPE_TOSS;
163 // setsize(e, '-16 -16 0', '16 16 74');
164 setorigin(e, p.origin - '0 0 24' + '0 0 37');
165 e.cnt = FLAG_DROPPED;
166 e.velocity = '0 0 300';
167 e.pain_finished = time + cvar("g_ctf_flag_returntime");//30;
169 trace_startsolid = FALSE;
170 tracebox(e.origin, e.mins, e.maxs, e.origin, TRUE, e);
172 dprint("FLAG FALLTHROUGH will happen SOON\n");
177 if(self.delay > time)
179 self.delay = time + self.t_width;
180 if(self.nextthink > self.delay)
181 self.nextthink = self.delay;
183 self.frame = self.frame + 1;
184 if(self.frame > self.t_length)
192 self.nextthink = time + 0.1;
196 if(self.speedrunning)
197 if(self.cnt == FLAG_CARRY)
200 if(flagcaptimerecord)
201 if(time >= self.flagpickuptime + flagcaptimerecord)
203 bprint("The ", self.netname, " became impatient after ", ftos_decimals(flagcaptimerecord, 2), " seconds and returned itself\n");
205 self.owner.impulse = 77; // returning!
215 if (self.cnt == FLAG_BASE)
218 if (self.cnt == FLAG_DROPPED)
220 // flag fallthrough? FIXME remove this if bug is really fixed now
221 if(self.origin_z < -131072)
223 dprint("FLAG FALLTHROUGH just happened\n");
224 self.pain_finished = 0;
226 setattachment(self, world, "");
227 if (time > self.pain_finished)
229 bprint("The ", self.netname, " has returned to base\n");
230 sound (self, CHAN_TRIGGER, self.noise3, VOL_BASE, ATTN_NONE);
231 LogCTF("returned", self.team, world);
238 if (e.classname != "player" || (e.deadflag) || (e.flagcarried != self))
240 dprint("CANNOT HAPPEN - player dead and STILL had a flag!\n");
241 DropFlag(self, world, world);
245 if(cvar("g_ctf_allow_drop"))
247 DropFlag(self, e, world);
256 local string s, s0, h0, h1;
257 if (other.classname != "player")
259 if (other.health < 1) // ignore dead players
262 if (self.cnt == FLAG_CARRY)
265 if (self.cnt == FLAG_BASE)
266 if (other.team == self.team)
267 if (other.flagcarried) // he's got a flag
268 if (other.flagcarried.team != self.team) // capture
270 if (other.flagcarried == world)
274 t = time - other.flagcarried.flagpickuptime;
275 s = ftos_decimals(t, 2);
276 s0 = ftos_decimals(flagcaptimerecord, 2);
277 h0 = db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"));
282 h0 = strcat(h0, "^7's"); // h0: display text for previous netname
283 if (flagcaptimerecord == 0)
285 bprint(other.netname, "^7 captured the ", other.flagcarried.netname, " in ", s, " seconds\n");
286 flagcaptimerecord = t;
287 db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"), ftos(t));
288 db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"), h1);
289 GameLogEcho(strcat(":recordset:", ftos(other.playerid), ":", ftos(t)));
291 else if (t < flagcaptimerecord)
293 bprint(other.netname, "^7 captured the ", other.flagcarried.netname, " in ", s, ", breaking ", strcat(h0, " previous record of ", s0, " seconds\n"));
294 flagcaptimerecord = t;
295 db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"), ftos(t));
296 db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"), h1);
297 GameLogEcho(strcat(":recordset:", ftos(other.playerid), ":", ftos(t)));
301 bprint(other.netname, "^7 captured the ", other.flagcarried.netname, " in ", s, ", failing to break ", strcat(h0, " record of ", s0, " seconds\n"));
304 PlayerTeamScore_Add(other, SP_CTF_CAPS, ST_CTF_CAPS, 1);
305 LogCTF("capture", other.flagcarried.team, other);
306 // give credit to the individual player
307 UpdateFrags(other, ctf_score_value("score_capture"));
309 sound (other, CHAN_AUTO, self.noise2, VOL_BASE, ATTN_NONE);
310 WaypointSprite_DetachCarrier(other);
311 if(self.speedrunning)
312 FakeTimeLimit(other, -1);
313 RegenFlag (other.flagcarried);
314 other.flagcarried = world;
315 other.next_take_time = time + 1;
317 if (self.cnt == FLAG_BASE)
318 if (other.team == COLOR_TEAM1 || other.team == COLOR_TEAM2) // only red and blue team can steal flags
319 if (other.team != self.team)
320 if (!other.flagcarried)
322 if (other.next_take_time > time)
325 self.flagpickuptime = time; // used for timing runs
326 self.speedrunning = other.speedrunning; // if speedrunning, flag will self-return and teleport the owner back after the record
327 if(other.speedrunning)
328 if(flagcaptimerecord)
329 FakeTimeLimit(other, time + flagcaptimerecord);
330 self.solid = SOLID_NOT;
331 setorigin(self, self.origin); // relink
333 other.flagcarried = self;
334 self.cnt = FLAG_CARRY;
335 self.angles = '0 0 0';
336 bprint(other.netname, "^7 got the ", self.netname, "\n");
337 UpdateFrags(other, ctf_score_value("score_pickup_base"));
338 self.dropperid = other.playerid;
339 PlayerScore_Add(other, SP_CTF_PICKUPS, 1);
340 LogCTF("steal", self.team, other);
341 sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NONE);
343 FOR_EACH_PLAYER(player)
344 if(player.team == self.team)
345 centerprint(player, "The enemy got your flag! Retrieve it!");
347 self.movetype = MOVETYPE_NONE;
348 setorigin(self, FLAG_CARRY_POS);
349 setattachment(self, other, "");
350 WaypointSprite_AttachCarrier("flagcarrier", other);
351 WaypointSprite_UpdateTeamRadar(other.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, '1 1 0');
352 WaypointSprite_Ping(self.sprite);
357 if (self.cnt == FLAG_DROPPED)
359 self.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
360 if (other.team == self.team || (other.team != COLOR_TEAM1 && other.team != COLOR_TEAM2))
363 bprint(other.netname, "^7 returned the ", self.netname, "\n");
365 // punish the player who last had it
366 FOR_EACH_PLAYER(player)
367 if(player.playerid == self.dropperid)
368 PlayerScore_Add(player, SP_SCORE, -ctf_score_value("penalty_returned"));
370 // punish the team who was last carrying it
371 if(self.team == COLOR_TEAM1)
372 TeamScore_AddToTeam(COLOR_TEAM2, ST_SCORE, -ctf_score_value("penalty_returned"));
374 TeamScore_AddToTeam(COLOR_TEAM1, ST_SCORE, -ctf_score_value("penalty_returned"));
376 // reward the player who returned it
377 if(other.playerid == self.playerid) // is this the guy who killed the FC last?
379 if (other.team == COLOR_TEAM1 || other.team == COLOR_TEAM2)
380 UpdateFrags(other, ctf_score_value("score_return_by_killer"));
382 UpdateFrags(other, ctf_score_value("score_return_rogue_by_killer"));
386 if (other.team == COLOR_TEAM1 || other.team == COLOR_TEAM2)
387 UpdateFrags(other, ctf_score_value("score_return"));
389 UpdateFrags(other, ctf_score_value("score_return_rogue"));
391 PlayerScore_Add(other, SP_CTF_RETURNS, 1);
392 LogCTF("return", self.team, other);
393 sound (other, CHAN_AUTO, self.noise1, VOL_BASE, ATTN_NONE);
396 else if (!other.flagcarried && (other.playerid != self.dropperid || time > self.ctf_droptime + cvar("g_balance_ctf_delay_collect")))
399 self.solid = SOLID_NOT;
400 setorigin(self, self.origin); // relink
402 other.flagcarried = self;
403 self.cnt = FLAG_CARRY;
404 bprint(other.netname, "^7 picked up the ", self.netname, "\n");
407 f = bound(0, (self.pain_finished - time) / cvar("g_ctf_flag_returntime"), 1);
408 //print("factor is ", ftos(f), "\n");
409 f = ctf_score_value("score_pickup_dropped_late") * (1-f)
410 + ctf_score_value("score_pickup_dropped_early") * f;
412 self.dropperid = other.playerid;
413 //print("score is ", ftos(f), "\n");
415 UpdateFrags(other, f);
416 PlayerScore_Add(other, SP_CTF_PICKUPS, 1);
417 LogCTF("pickup", self.team, other);
418 sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NONE);
420 FOR_EACH_PLAYER(player)
421 if(player.team == self.team)
422 centerprint(player, "The enemy got your flag! Retrieve it!");
424 self.movetype = MOVETYPE_NONE; // flag must have MOVETYPE_NONE here, otherwise it will drop through the floor...
425 setorigin(self, FLAG_CARRY_POS);
426 setattachment(self, other, "");
427 self.damageforcescale = 0;
428 WaypointSprite_AttachCarrier("flagcarrier", other);
429 WaypointSprite_UpdateTeamRadar(other.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, '1 1 0');
434 /*QUAKED spawnfunc_info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24)
435 CTF Starting point for a player
440 viewing angle when spawning
442 void spawnfunc_info_player_team1()
444 self.team = COLOR_TEAM1; // red
445 spawnfunc_info_player_deathmatch();
447 //self.team = 4;self.classname = "info_player_start";spawnfunc_info_player_start();};
449 /*QUAKED spawnfunc_info_player_team2 (1 0 0) (-16 -16 -24) (16 16 24)
450 CTF Starting point for a player in
455 viewing angle when spawning
457 void spawnfunc_info_player_team2()
459 self.team = COLOR_TEAM2; // blue
460 spawnfunc_info_player_deathmatch();
462 //self.team = 13;self.classname = "info_player_start";spawnfunc_info_player_start();};
464 /*QUAKED spawnfunc_info_player_team3 (1 0 0) (-16 -16 -24) (16 16 24)
465 CTF Starting point for a player in
466 team three (Magenta).
470 viewing angle when spawning
472 void spawnfunc_info_player_team3()
474 self.team = COLOR_TEAM3; // purple
475 spawnfunc_info_player_deathmatch();
479 /*QUAKED spawnfunc_info_player_team4 (1 0 0) (-16 -16 -24) (16 16 24)
480 CTF Starting point for a player in
485 viewing angle when spawning
487 void spawnfunc_info_player_team4()
489 self.team = COLOR_TEAM4; // yellow
490 spawnfunc_info_player_deathmatch();
496 /*QUAKED spawnfunc_item_flag_team1 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
497 CTF flag for team one (Red).
498 Multiple are allowed.
502 Angle the flag will point
505 model to use, note this needs red and blue as skins 0 and 1
506 (default models/ctf/flag.md3)
508 sound played when flag is picked up
509 (default ctf/take.wav)
511 sound played when flag is returned by a teammate
512 (default ctf/return.wav)
514 sound played when flag is captured
515 (default ctf/redcapture.wav)
517 sound played when flag is lost in the field and respawns itself
518 (default ctf/respawn.wav)
521 void spawnfunc_item_flag_team1()
529 //if(!cvar("teamplay"))
530 // cvar_set("teamplay", "3");
532 // link flag into ctf_worldflaglist
533 self.ctf_worldflagnext = ctf_worldflaglist;
534 ctf_worldflaglist = self;
536 self.classname = "item_flag_team";
539 self.team = COLOR_TEAM2; // color 13 team (blue)
540 self.items = IT_KEY1; // silver key (bluish enough)
544 self.team = COLOR_TEAM1; // color 4 team (red)
545 self.items = IT_KEY2; // gold key (redish enough)
547 self.netname = "^1RED^7 flag";
548 self.target = "###item###";
550 if(self.spawnflags & 1)
553 self.model = "models/ctf/flag_red.md3";
555 self.noise = "ctf/take.wav";
557 self.noise1 = "ctf/return.wav";
559 self.noise2 = "ctf/redcapture.wav"; // blue team scores by capturing the red flag
561 self.noise3 = "ctf/respawn.wav";
562 precache_model (self.model);
563 setmodel (self, self.model); // precision set below
564 precache_sound (self.noise);
565 precache_sound (self.noise1);
566 precache_sound (self.noise2);
567 precache_sound (self.noise3);
568 //setsize(self, '-16 -16 -37', '16 16 37');
569 setsize(self, PL_MIN + '0 0 -13', PL_MAX + '0 0 -13');
570 setorigin(self, self.origin + '0 0 37');
571 self.nextthink = time + 0.2; // start after doors etc
572 self.think = place_flag;
576 //if(!self.glow_size)
577 // self.glow_size = 50;
579 self.effects = self.effects | EF_LOWPRECISION;
580 if(cvar("g_ctf_fullbrightflags"))
581 self.effects |= EF_FULLBRIGHT;
583 waypoint_spawnforitem(self);
585 WaypointSprite_SpawnFixed("redbase", self.origin + '0 0 37', self, sprite);
586 WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_FLAG, '1 0 0');
589 /*QUAKED spawnfunc_item_flag_team2 (0 0.5 0.8) (-48 -48 -24) (48 48 64)
590 CTF flag for team two (Blue).
591 Multiple are allowed.
595 Angle the flag will point
598 model to use, note this needs red and blue as skins 0 and 1
599 (default models/ctf/flag.md3)
601 sound played when flag is picked up
602 (default ctf/take.wav)
604 sound played when flag is returned by a teammate
605 (default ctf/return.wav)
607 sound played when flag is captured
608 (default ctf/bluecapture.wav)
610 sound played when flag is lost in the field and respawns itself
611 (default ctf/respawn.wav)
614 void spawnfunc_item_flag_team2()
621 //if(!cvar("teamplay"))
622 // cvar_set("teamplay", "3");
624 // link flag into ctf_worldflaglist
625 self.ctf_worldflagnext = ctf_worldflaglist;
626 ctf_worldflaglist = self;
628 self.classname = "item_flag_team";
631 self.team = COLOR_TEAM1; // color 4 team (red)
632 self.items = IT_KEY2; // gold key (redish enough)
636 self.team = COLOR_TEAM2; // color 13 team (blue)
637 self.items = IT_KEY1; // silver key (bluish enough)
639 self.netname = "^4BLUE^7 flag";
640 self.target = "###item###";
642 if(self.spawnflags & 1)
645 self.model = "models/ctf/flag_blue.md3";
647 self.noise = "ctf/take.wav";
649 self.noise1 = "ctf/return.wav";
651 self.noise2 = "ctf/bluecapture.wav"; // red team scores by capturing the blue flag
653 self.noise3 = "ctf/respawn.wav";
654 precache_model (self.model);
655 setmodel (self, self.model); // precision set below
656 precache_sound (self.noise);
657 precache_sound (self.noise1);
658 precache_sound (self.noise2);
659 precache_sound (self.noise3);
660 //setsize(self, '-16 -16 -37', '16 16 37');
661 setsize(self, PL_MIN + '0 0 -13', PL_MAX + '0 0 -13');
662 setorigin(self, self.origin + '0 0 37');
663 self.nextthink = time + 0.2; // start after doors etc
664 self.think = place_flag;
668 //if(!self.glow_size)
669 // self.glow_size = 50;
671 self.effects = self.effects | EF_LOWPRECISION;
672 if(cvar("g_ctf_fullbrightflags"))
673 self.effects |= EF_FULLBRIGHT;
675 waypoint_spawnforitem(self);
677 WaypointSprite_SpawnFixed("bluebase", self.origin + '0 0 37', self, sprite);
678 WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_FLAG, '0 0 1');
682 /*QUAKED spawnfunc_ctf_team (0 .5 .8) (-16 -16 -24) (16 16 32)
683 Team declaration for CTF gameplay, this allows you to decide what team
684 names and control point models are used in your map.
686 Note: If you use spawnfunc_ctf_team entities you must define at least 2! However, unlike
687 domination, you don't need to make a blank one too.
691 Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)
693 Scoreboard color of the team (for example 4 is red and 13 is blue)
697 void spawnfunc_ctf_team()
704 self.classname = "ctf_team";
705 self.team = self.cnt + 1;
708 // code from here on is just to support maps that don't have control point and team entities
709 void ctf_spawnteam (string teamname, float teamcolor)
711 local entity oldself;
714 self.classname = "ctf_team";
715 self.netname = teamname;
716 self.cnt = teamcolor;
718 spawnfunc_ctf_team();
723 // spawn some default teams if the map is not set up for ctf
724 void ctf_spawnteams()
728 numteams = 2;//cvar("g_ctf_default_teams");
730 ctf_spawnteam("Red", COLOR_TEAM1 - 1);
731 ctf_spawnteam("Blue", COLOR_TEAM2 - 1);
734 void ctf_delayedinit()
736 // if no teams are found, spawn defaults
737 if (find(world, classname, "ctf_team") == world)
745 InitializeEntity(world, ctf_delayedinit, INITPRIO_GAMETYPE);
746 flagcaptimerecord = stof(db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time")));
749 void ctf_setstatus2(entity flag, float shift)
751 if (flag.cnt == FLAG_CARRY)
752 if (flag.owner == self)
753 self.items |= shift * 3;
755 self.items |= shift * 1;
756 else if (flag.cnt == FLAG_DROPPED)
757 self.items |= shift * 2;
766 self.items = self.items - (self.items & IT_RED_FLAG_TAKEN);
767 self.items = self.items - (self.items & IT_RED_FLAG_LOST);
768 self.items = self.items - (self.items & IT_BLUE_FLAG_TAKEN);
769 self.items = self.items - (self.items & IT_BLUE_FLAG_LOST);
773 float redflags, blueflags;
778 for (flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) if(flag.cnt != FLAG_BASE)
780 if(flag.items & IT_KEY2) // blue
782 else if(flag.items & IT_KEY1) // red
786 // blinking magic: if there is more than one flag, show one of these in a clever way
788 redflags = mod(floor(time * redflags * 0.75), redflags);
790 blueflags = mod(floor(time * blueflags * 0.75), blueflags);
792 for (flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) if(flag.cnt != FLAG_BASE)
794 if(flag.items & IT_KEY2) // blue
796 if(--redflags == -1) // happens exactly once (redflags is in 0..count-1, and will --'ed count times)
797 ctf_setstatus2(flag, IT_RED_FLAG_TAKEN);
799 else if(flag.items & IT_KEY1) // red
801 if(--blueflags == -1) // happens exactly once
802 ctf_setstatus2(flag, IT_BLUE_FLAG_TAKEN);
808 entity(float cteam) ctf_team_has_commander =
811 if(cteam != COLOR_TEAM1 || cteam != COLOR_TEAM2)
814 FOR_EACH_REALPLAYER(pl) {
815 if(pl.team == cteam && pl.iscommander) {
822 void(entity e, float st) ctf_setstate =
828 void(float cteam) ctf_new_commander =
833 FOR_EACH_REALPLAYER(pl) {
834 if(pl.team == cteam) {
835 if(pl.iscommander) { // don't reassign if alreay there
838 if(plmax == world || plmax.frags < pl.frags) <<<<<<<<<<<<<<<<< BROKEN in new scoring system
843 bprint(strcat(ColoredTeamName(cteam), " Team has no Commander!\n"));
847 plmax.iscommander = TRUE;
848 ctf_setstate(plmax, 3);
849 sprint(plmax, "^3You're the commander now!\n");
850 centerprint(plmax, "^3You're the commander now!\n");
853 void() ctf_clientconnect =
855 self.iscommander = FALSE;
857 if(!self.team || self.classname != "player") {
858 ctf_setstate(self, -1);
860 ctf_setstate(self, 0);
862 self.team_saved = self.team;
864 if(self.team != 0 && self.classname == "player" && !ctf_team_has_commander(self.team)) {
865 ctf_new_commander(self.team);
869 void() ctf_playerchanged =
871 if(!self.team || self.classname != "player") {
872 ctf_setstate(self, -1);
873 } else if(self.ctf_state < 0 && self.classname == "player") {
874 ctf_setstate(self, 0);
877 if(self.iscommander &&
878 (self.classname != "player" || self.team != self.team_saved)
881 self.iscommander = FALSE;
882 if(self.classname == "player")
883 ctf_setstate(self, 0);
885 ctf_setstate(self, -1);
886 ctf_new_commander(self.team_saved);
889 self.team_saved = self.team;
891 ctf_new_commander(self.team);
894 void() ctf_clientdisconnect =
898 ctf_new_commander(self.team);
902 entity GetPlayer(string);
903 float() ctf_clientcommand =
906 if(argv(0) == "order") {
908 sprint(self, "This command is not supported in this gamemode.\n");
911 if(!self.iscommander) {
912 sprint(self, "^1You are not the commander!\n");
916 sprint(self, "Usage: order #player status - (playernumber as in status)\n");
919 e = GetPlayer(argv(1));
921 sprint(self, "Invalid player.\nUsage: order #player status - (playernumber as in status)\n");
924 if(e.team != self.team) {
925 sprint(self, "^3You can only give orders to your own team!\n");
928 if(argv(2) == "attack") {
929 sprint(self, strcat("Ordering ", e.netname, " to attack!\n"));
930 sprint(e, "^1Attack!\n");
931 centerprint(e, "^7You've been ordered to^9\n^1Attack!\n");
933 } else if(argv(2) == "defend") {
934 sprint(self, strcat("Ordering ", e.netname, " to defend!\n"));
935 sprint(e, "^Defend!\n");
936 centerprint(e, "^7You've been ordered to^9\n^2Defend!\n");
939 sprint(self, "^7Invalid command, use ^3attack^7, or ^3defend^7.\n");