2 entity ctf_worldflaglist; // CTF flags in the map
3 .entity ctf_worldflagnext;
6 .float next_take_time; // the next time a player can pick up a flag (time + blah)
7 /// I used this, in part, to fix the looping score bug. - avirox
8 //float FLAGSCORE_PICKUP = 1;
9 //float FLAGSCORE_RETURN = 5; // returned by owner team
10 //float FLAGSCORE_RETURNROGUE = 10; // returned by rogue team
11 //float FLAGSCORE_CAPTURE = 5;
13 #define FLAG_CARRY_POS '-15 0 7'
15 float ctf_score_value(string parameter)
17 if(g_ctf_win_mode != 2)
18 return cvar(strcat("g_ctf_personal", parameter));
20 return cvar(strcat("g_ctf_flag", parameter));
23 void FakeTimeLimit(entity e, float t)
26 WriteByte(MSG_ONE, 3); // svc_updatestat
27 WriteByte(MSG_ONE, 236); // STAT_TIMELIMIT
29 WriteCoord(MSG_ONE, cvar("timelimit"));
31 WriteCoord(MSG_ONE, (t + 1) / 60);
34 float flagcaptimerecord;
35 .float flagpickuptime;
45 self.t_width = 0.1; // frame animation rate
47 self.t_length = 119; // maximum frame
49 setattachment(self, world, "");
50 self.mdl = self.model;
52 self.solid = SOLID_TRIGGER;
53 self.movetype = MOVETYPE_NONE;
54 self.velocity = '0 0 0';
55 self.origin_z = self.origin_z + 6;
56 self.think = FlagThink;
57 self.touch = FlagTouch;
58 self.nextthink = time + 0.1;
60 self.mangle = self.angles;
61 self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
62 //self.effects = self.effects | EF_DIMLIGHT;
65 self.dropped_origin = self.origin;
70 self.movetype = MOVETYPE_TOSS;
74 void LogCTF(string mode, float flagteam, entity actor)
77 if(!cvar("sv_eventlog"))
79 s = strcat(":ctf:", mode);
80 s = strcat(s, ":", ftos(flagteam));
82 s = strcat(s, ":", ftos(actor.playerid));
86 void RegenFlag(entity e)
88 setattachment(e, world, "");
89 e.damageforcescale = 0;
90 e.movetype = MOVETYPE_NONE;
92 e.movetype = MOVETYPE_TOSS;
93 e.solid = SOLID_TRIGGER;
94 // TODO: play a sound here
95 setorigin(e, e.dropped_origin);
99 e.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
102 void ReturnFlag(entity e)
105 if (e.owner.flagcarried == e)
107 WaypointSprite_DetachCarrier(e.owner);
108 e.owner.flagcarried = world;
111 FakeTimeLimit(e.owner, -1);
117 void DropFlag(entity e, entity penalty_receiver, entity attacker)
129 dprint("FLAG: drop - no owner?!?!\n");
133 if (p.flagcarried != e)
135 dprint("FLAG: drop - owner is not carrying this flag??\n");
138 bprint(p.netname, "^7 lost the ", e.netname, "\n");
141 UpdateFrags(penalty_receiver, -ctf_score_value("penalty_suicidedrop"));
143 UpdateFrags(p, -ctf_score_value("penalty_drop"));
144 PlayerScore_Add(p, SP_CTF_DROPS, +1);
145 e.playerid = attacker.playerid;
147 WaypointSprite_Ping(p.waypointsprite_attachedforcarrier);
148 WaypointSprite_DetachCarrier(p);
149 LogCTF("dropped", p.team, p);
151 setattachment(e, world, "");
152 e.damageforcescale = cvar("g_balance_ctf_damageforcescale");
154 if (p.flagcarried == e)
155 p.flagcarried = world;
158 e.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
159 e.solid = SOLID_TRIGGER;
160 e.movetype = MOVETYPE_TOSS;
161 // setsize(e, '-16 -16 0', '16 16 74');
162 setorigin(e, p.origin - '0 0 24' + '0 0 37');
163 e.cnt = FLAG_DROPPED;
164 e.velocity = '0 0 300';
165 e.pain_finished = time + cvar("g_ctf_flag_returntime");//30;
167 trace_startsolid = FALSE;
168 tracebox(e.origin, e.mins, e.maxs, e.origin, TRUE, e);
170 dprint("FLAG FALLTHROUGH will happen SOON\n");
175 if(self.delay > time)
177 self.delay = time + self.t_width;
178 if(self.nextthink > self.delay)
179 self.nextthink = self.delay;
181 self.frame = self.frame + 1;
182 if(self.frame > self.t_length)
190 self.nextthink = time + 0.1;
194 if(self.speedrunning)
195 if(self.cnt == FLAG_CARRY)
198 if(flagcaptimerecord)
199 if(time >= self.flagpickuptime + flagcaptimerecord)
201 bprint("The ", self.netname, " became impatient after ", ftos_decimals(flagcaptimerecord, 2), " seconds and returned itself\n");
203 self.owner.impulse = 77; // returning!
213 if (self.cnt == FLAG_BASE)
216 if (self.cnt == FLAG_DROPPED)
218 // flag fallthrough? FIXME remove this if bug is really fixed now
219 if(self.origin_z < -131072)
221 dprint("FLAG FALLTHROUGH just happened\n");
222 self.pain_finished = 0;
224 setattachment(self, world, "");
225 if (time > self.pain_finished)
227 bprint("The ", self.netname, " has returned to base\n");
228 sound (self, CHAN_TRIGGER, self.noise3, VOL_BASE, ATTN_NONE);
229 LogCTF("returned", self.team, world);
236 if (e.classname != "player" || (e.deadflag) || (e.flagcarried != self))
238 dprint("CANNOT HAPPEN - player dead and STILL had a flag!\n");
239 DropFlag(self, world, world);
250 local string s, s0, h0, h1;
251 if (other.classname != "player")
253 if (other.health < 1) // ignore dead players
256 if (self.cnt == FLAG_CARRY)
259 if (self.cnt == FLAG_BASE)
260 if (other.team == self.team)
261 if (other.flagcarried) // he's got a flag
262 if (other.flagcarried.team != self.team) // capture
264 if (other.flagcarried == world)
268 t = time - other.flagcarried.flagpickuptime;
269 s = ftos_decimals(t, 2);
270 s0 = ftos_decimals(flagcaptimerecord, 2);
271 h0 = db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"));
276 h0 = strcat(h0, "^7's"); // h0: display text for previous netname
277 if (flagcaptimerecord == 0)
279 bprint(other.netname, "^7 captured the ", other.flagcarried.netname, " in ", s, " seconds\n");
280 flagcaptimerecord = t;
281 db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"), ftos(t));
282 db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"), h1);
283 GameLogEcho(strcat(":recordset:", ftos(other.playerid), ":", ftos(t)));
285 else if (t < flagcaptimerecord)
287 bprint(other.netname, "^7 captured the ", other.flagcarried.netname, " in ", s, ", breaking ", strcat(h0, " previous record of ", s0, " seconds\n"));
288 flagcaptimerecord = t;
289 db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"), ftos(t));
290 db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"), h1);
291 GameLogEcho(strcat(":recordset:", ftos(other.playerid), ":", ftos(t)));
295 bprint(other.netname, "^7 captured the ", other.flagcarried.netname, " in ", s, ", failing to break ", strcat(h0, " record of ", s0, " seconds\n"));
298 PlayerTeamScore_Add(other, SP_CTF_CAPS, ST_CTF_CAPS, 1);
299 LogCTF("capture", other.flagcarried.team, other);
300 // give credit to the individual player
301 UpdateFrags(other, ctf_score_value("score_capture"));
303 sound (other, CHAN_AUTO, self.noise2, VOL_BASE, ATTN_NONE);
304 WaypointSprite_DetachCarrier(other);
305 if(self.speedrunning)
306 FakeTimeLimit(other, -1);
307 RegenFlag (other.flagcarried);
308 other.flagcarried = world;
309 other.next_take_time = time + 1;
311 if (self.cnt == FLAG_BASE)
312 if (other.team == COLOR_TEAM1 || other.team == COLOR_TEAM2) // only red and blue team can steal flags
313 if (other.team != self.team)
314 if (!other.flagcarried)
316 if (other.next_take_time > time)
319 self.flagpickuptime = time; // used for timing runs
320 self.speedrunning = other.speedrunning; // if speedrunning, flag will self-return and teleport the owner back after the record
321 if(other.speedrunning)
322 if(flagcaptimerecord)
323 FakeTimeLimit(other, time + flagcaptimerecord);
324 self.solid = SOLID_NOT;
325 setorigin(self, self.origin); // relink
327 other.flagcarried = self;
328 self.cnt = FLAG_CARRY;
329 self.angles = '0 0 0';
330 bprint(other.netname, "^7 got the ", self.netname, "\n");
331 UpdateFrags(other, ctf_score_value("score_pickup_base"));
332 self.dropperid = other.playerid;
333 PlayerScore_Add(other, SP_CTF_PICKUPS, 1);
334 LogCTF("steal", self.team, other);
335 sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NONE);
337 FOR_EACH_PLAYER(player)
338 if(player.team == self.team)
339 centerprint(player, "The enemy got your flag! Retrieve it!");
341 self.movetype = MOVETYPE_NONE;
342 setorigin(self, FLAG_CARRY_POS);
343 setattachment(self, other, "");
344 WaypointSprite_AttachCarrier("flagcarrier", other);
345 WaypointSprite_UpdateTeamRadar(other.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, '1 1 0');
346 WaypointSprite_Ping(self.sprite);
351 if (self.cnt == FLAG_DROPPED)
353 self.flags = FL_ITEM; // clear FL_ONGROUND and any other junk
354 if (other.team == self.team || (other.team != COLOR_TEAM1 && other.team != COLOR_TEAM2))
357 bprint(other.netname, "^7 returned the ", self.netname, "\n");
359 // punish the player who last had it
360 FOR_EACH_PLAYER(player)
361 if(player.playerid == self.dropperid)
362 PlayerScore_Add(player, SP_SCORE, -ctf_score_value("penalty_returned"));
364 // punish the team who was last carrying it
365 if(self.team == COLOR_TEAM1)
366 TeamScore_AddToTeam(COLOR_TEAM2, ST_SCORE, -ctf_score_value("penalty_returned"));
368 TeamScore_AddToTeam(COLOR_TEAM1, ST_SCORE, -ctf_score_value("penalty_returned"));
370 // reward the player who returned it
371 if(other.playerid == self.playerid) // is this the guy who killed the FC last?
373 if (other.team == COLOR_TEAM1 || other.team == COLOR_TEAM2)
374 UpdateFrags(other, ctf_score_value("score_return_by_killer"));
376 UpdateFrags(other, ctf_score_value("score_return_rogue_by_killer"));
380 if (other.team == COLOR_TEAM1 || other.team == COLOR_TEAM2)
381 UpdateFrags(other, ctf_score_value("score_return"));
383 UpdateFrags(other, ctf_score_value("score_return_rogue"));
385 PlayerScore_Add(other, SP_CTF_RETURNS, 1);
386 LogCTF("return", self.team, other);
387 sound (other, CHAN_AUTO, self.noise1, VOL_BASE, ATTN_NONE);
390 else if (!other.flagcarried)
393 self.solid = SOLID_NOT;
394 setorigin(self, self.origin); // relink
396 other.flagcarried = self;
397 self.cnt = FLAG_CARRY;
398 bprint(other.netname, "^7 picked up the ", self.netname, "\n");
401 f = bound(0, (self.pain_finished - time) / cvar("g_ctf_flag_returntime"), 1);
402 //print("factor is ", ftos(f), "\n");
403 f = ctf_score_value("score_pickup_dropped_late") * (1-f)
404 + ctf_score_value("score_pickup_dropped_early") * f;
406 self.dropperid = other.playerid;
407 //print("score is ", ftos(f), "\n");
409 UpdateFrags(other, f);
410 PlayerScore_Add(other, SP_CTF_PICKUPS, 1);
411 LogCTF("pickup", self.team, other);
412 sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NONE);
414 FOR_EACH_PLAYER(player)
415 if(player.team == self.team)
416 centerprint(player, "The enemy got your flag! Retrieve it!");
418 self.movetype = MOVETYPE_NONE; // flag must have MOVETYPE_NONE here, otherwise it will drop through the floor...
419 setorigin(self, FLAG_CARRY_POS);
420 setattachment(self, other, "");
421 self.damageforcescale = 0;
422 WaypointSprite_AttachCarrier("flagcarrier", other);
423 WaypointSprite_UpdateTeamRadar(other.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, '1 1 0');
428 /*QUAKED spawnfunc_info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24)
429 CTF Starting point for a player
434 viewing angle when spawning
436 void spawnfunc_info_player_team1()
438 self.team = COLOR_TEAM1; // red
439 spawnfunc_info_player_deathmatch();
441 //self.team = 4;self.classname = "info_player_start";spawnfunc_info_player_start();};
443 /*QUAKED spawnfunc_info_player_team2 (1 0 0) (-16 -16 -24) (16 16 24)
444 CTF Starting point for a player in
449 viewing angle when spawning
451 void spawnfunc_info_player_team2()
453 self.team = COLOR_TEAM2; // blue
454 spawnfunc_info_player_deathmatch();
456 //self.team = 13;self.classname = "info_player_start";spawnfunc_info_player_start();};
458 /*QUAKED spawnfunc_info_player_team3 (1 0 0) (-16 -16 -24) (16 16 24)
459 CTF Starting point for a player in
460 team three (Magenta).
464 viewing angle when spawning
466 void spawnfunc_info_player_team3()
468 self.team = COLOR_TEAM3; // purple
469 spawnfunc_info_player_deathmatch();
473 /*QUAKED spawnfunc_info_player_team4 (1 0 0) (-16 -16 -24) (16 16 24)
474 CTF Starting point for a player in
479 viewing angle when spawning
481 void spawnfunc_info_player_team4()
483 self.team = COLOR_TEAM4; // yellow
484 spawnfunc_info_player_deathmatch();
490 /*QUAKED spawnfunc_item_flag_team1 (0 0.5 0.8) (-48 -48 -37) (48 48 37)
491 CTF flag for team one (Red).
492 Multiple are allowed.
496 Angle the flag will point
499 model to use, note this needs red and blue as skins 0 and 1
500 (default models/ctf/flag.md3)
502 sound played when flag is picked up
503 (default ctf/take.wav)
505 sound played when flag is returned by a teammate
506 (default ctf/return.wav)
508 sound played when flag is captured
509 (default ctf/redcapture.wav)
511 sound played when flag is lost in the field and respawns itself
512 (default ctf/respawn.wav)
515 void spawnfunc_item_flag_team1()
523 //if(!cvar("teamplay"))
524 // cvar_set("teamplay", "3");
526 // link flag into ctf_worldflaglist
527 self.ctf_worldflagnext = ctf_worldflaglist;
528 ctf_worldflaglist = self;
530 self.classname = "item_flag_team";
531 self.team = COLOR_TEAM1; // color 4 team (red)
532 self.items = IT_KEY2; // gold key (redish enough)
533 self.netname = "^1RED^7 flag";
534 self.target = "###item###";
536 if(self.spawnflags & 1)
539 self.model = "models/ctf/flag_red.md3";
541 self.noise = "ctf/take.wav";
543 self.noise1 = "ctf/return.wav";
545 self.noise2 = "ctf/redcapture.wav"; // blue team scores by capturing the red flag
547 self.noise3 = "ctf/respawn.wav";
548 precache_model (self.model);
549 setmodel (self, self.model); // precision set below
550 precache_sound (self.noise);
551 precache_sound (self.noise1);
552 precache_sound (self.noise2);
553 precache_sound (self.noise3);
554 //setsize(self, '-16 -16 -37', '16 16 37');
555 setsize(self, PL_MIN + '0 0 -13', PL_MAX + '0 0 -13');
556 setorigin(self, self.origin + '0 0 37');
557 self.nextthink = time + 0.2; // start after doors etc
558 self.think = place_flag;
562 //if(!self.glow_size)
563 // self.glow_size = 50;
565 self.effects = self.effects | EF_LOWPRECISION;
566 if(cvar("g_ctf_fullbrightflags"))
567 self.effects |= EF_FULLBRIGHT;
569 waypoint_spawnforitem(self);
571 WaypointSprite_SpawnFixed("redbase", self.origin + '0 0 37', self, sprite);
572 WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_FLAG, '1 0 0');
575 /*QUAKED spawnfunc_item_flag_team2 (0 0.5 0.8) (-48 -48 -24) (48 48 64)
576 CTF flag for team two (Blue).
577 Multiple are allowed.
581 Angle the flag will point
584 model to use, note this needs red and blue as skins 0 and 1
585 (default models/ctf/flag.md3)
587 sound played when flag is picked up
588 (default ctf/take.wav)
590 sound played when flag is returned by a teammate
591 (default ctf/return.wav)
593 sound played when flag is captured
594 (default ctf/bluecapture.wav)
596 sound played when flag is lost in the field and respawns itself
597 (default ctf/respawn.wav)
600 void spawnfunc_item_flag_team2()
607 //if(!cvar("teamplay"))
608 // cvar_set("teamplay", "3");
610 // link flag into ctf_worldflaglist
611 self.ctf_worldflagnext = ctf_worldflaglist;
612 ctf_worldflaglist = self;
614 self.classname = "item_flag_team";
615 self.team = COLOR_TEAM2; // color 13 team (blue)
616 self.items = IT_KEY1; // silver key (bluish enough)
617 self.netname = "^4BLUE^7 flag";
618 self.target = "###item###";
620 if(self.spawnflags & 1)
623 self.model = "models/ctf/flag_blue.md3";
625 self.noise = "ctf/take.wav";
627 self.noise1 = "ctf/return.wav";
629 self.noise2 = "ctf/bluecapture.wav"; // red team scores by capturing the blue flag
631 self.noise3 = "ctf/respawn.wav";
632 precache_model (self.model);
633 setmodel (self, self.model); // precision set below
634 precache_sound (self.noise);
635 precache_sound (self.noise1);
636 precache_sound (self.noise2);
637 precache_sound (self.noise3);
638 //setsize(self, '-16 -16 -37', '16 16 37');
639 setsize(self, PL_MIN + '0 0 -13', PL_MAX + '0 0 -13');
640 setorigin(self, self.origin + '0 0 37');
641 self.nextthink = time + 0.2; // start after doors etc
642 self.think = place_flag;
646 //if(!self.glow_size)
647 // self.glow_size = 50;
649 self.effects = self.effects | EF_LOWPRECISION;
650 if(cvar("g_ctf_fullbrightflags"))
651 self.effects |= EF_FULLBRIGHT;
653 waypoint_spawnforitem(self);
655 WaypointSprite_SpawnFixed("bluebase", self.origin + '0 0 37', self, sprite);
656 WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_FLAG, '0 0 1');
660 /*QUAKED spawnfunc_ctf_team (0 .5 .8) (-16 -16 -24) (16 16 32)
661 Team declaration for CTF gameplay, this allows you to decide what team
662 names and control point models are used in your map.
664 Note: If you use spawnfunc_ctf_team entities you must define at least 2! However, unlike
665 domination, you don't need to make a blank one too.
669 Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)
671 Scoreboard color of the team (for example 4 is red and 13 is blue)
675 void spawnfunc_ctf_team()
682 self.classname = "ctf_team";
683 self.team = self.cnt + 1;
686 // code from here on is just to support maps that don't have control point and team entities
687 void ctf_spawnteam (string teamname, float teamcolor)
689 local entity oldself;
692 self.classname = "ctf_team";
693 self.netname = teamname;
694 self.cnt = teamcolor;
696 spawnfunc_ctf_team();
701 // spawn some default teams if the map is not set up for ctf
702 void ctf_spawnteams()
706 numteams = 2;//cvar("g_ctf_default_teams");
708 ctf_spawnteam("Red", COLOR_TEAM1 - 1);
709 ctf_spawnteam("Blue", COLOR_TEAM2 - 1);
712 void ctf_delayedinit()
714 // if no teams are found, spawn defaults
715 if (find(world, classname, "ctf_team") == world)
723 InitializeEntity(world, ctf_delayedinit, INITPRIO_GAMETYPE);
724 flagcaptimerecord = stof(db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time")));
727 void ctf_setstatus2(entity flag, float shift)
729 if (flag.cnt == FLAG_CARRY)
730 if (flag.owner == self)
731 self.items |= shift * 3;
733 self.items |= shift * 1;
734 else if (flag.cnt == FLAG_DROPPED)
735 self.items |= shift * 2;
744 self.items = self.items - (self.items & IT_RED_FLAG_TAKEN);
745 self.items = self.items - (self.items & IT_RED_FLAG_LOST);
746 self.items = self.items - (self.items & IT_BLUE_FLAG_TAKEN);
747 self.items = self.items - (self.items & IT_BLUE_FLAG_LOST);
751 float redflags, blueflags;
756 for (flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) if(flag.cnt != FLAG_BASE)
758 if(flag.team == COLOR_TEAM1)
760 else if(flag.team == COLOR_TEAM2)
764 // blinking magic: if there is more than one flag, show one of these in a clever way
766 redflags = mod(floor(time * redflags * 0.75), redflags);
768 blueflags = mod(floor(time * blueflags * 0.75), blueflags);
770 for (flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext) if(flag.cnt != FLAG_BASE)
772 if(flag.team == COLOR_TEAM1)
774 if(--redflags == -1) // happens exactly once (redflags is in 0..count-1, and will --'ed count times)
775 ctf_setstatus2(flag, IT_RED_FLAG_TAKEN);
777 else if(flag.team == COLOR_TEAM2)
779 if(--blueflags == -1) // happens exactly once
780 ctf_setstatus2(flag, IT_BLUE_FLAG_TAKEN);
786 entity(float cteam) ctf_team_has_commander =
789 if(cteam != COLOR_TEAM1 || cteam != COLOR_TEAM2)
792 FOR_EACH_REALPLAYER(pl) {
793 if(pl.team == cteam && pl.iscommander) {
800 void(entity e, float st) ctf_setstate =
806 void(float cteam) ctf_new_commander =
811 FOR_EACH_REALPLAYER(pl) {
812 if(pl.team == cteam) {
813 if(pl.iscommander) { // don't reassign if alreay there
816 if(plmax == world || plmax.frags < pl.frags) <<<<<<<<<<<<<<<<< BROKEN in new scoring system
821 bprint(strcat(ColoredTeamName(cteam), " Team has no Commander!\n"));
825 plmax.iscommander = TRUE;
826 ctf_setstate(plmax, 3);
827 sprint(plmax, "^3You're the commander now!\n");
828 centerprint(plmax, "^3You're the commander now!\n");
831 void() ctf_clientconnect =
833 self.iscommander = FALSE;
835 if(!self.team || self.classname != "player") {
836 ctf_setstate(self, -1);
838 ctf_setstate(self, 0);
840 self.team_saved = self.team;
842 if(self.team != 0 && self.classname == "player" && !ctf_team_has_commander(self.team)) {
843 ctf_new_commander(self.team);
847 void() ctf_playerchanged =
849 if(!self.team || self.classname != "player") {
850 ctf_setstate(self, -1);
851 } else if(self.ctf_state < 0 && self.classname == "player") {
852 ctf_setstate(self, 0);
855 if(self.iscommander &&
856 (self.classname != "player" || self.team != self.team_saved)
859 self.iscommander = FALSE;
860 if(self.classname == "player")
861 ctf_setstate(self, 0);
863 ctf_setstate(self, -1);
864 ctf_new_commander(self.team_saved);
867 self.team_saved = self.team;
869 ctf_new_commander(self.team);
872 void() ctf_clientdisconnect =
876 ctf_new_commander(self.team);
880 entity GetPlayer(string);
881 float() ctf_clientcommand =
884 if(argv(0) == "order") {
886 sprint(self, "This command is not supported in this gamemode.\n");
889 if(!self.iscommander) {
890 sprint(self, "^1You are not the commander!\n");
894 sprint(self, "Usage: order #player status - (playernumber as in status)\n");
897 e = GetPlayer(argv(1));
899 sprint(self, "Invalid player.\nUsage: order #player status - (playernumber as in status)\n");
902 if(e.team != self.team) {
903 sprint(self, "^3You can only give orders to your own team!\n");
906 if(argv(2) == "attack") {
907 sprint(self, strcat("Ordering ", e.netname, " to attack!\n"));
908 sprint(e, "^1Attack!\n");
909 centerprint(e, "^7You've been ordered to^9\n^1Attack!\n");
911 } else if(argv(2) == "defend") {
912 sprint(self, strcat("Ordering ", e.netname, " to defend!\n"));
913 sprint(e, "^Defend!\n");
914 centerprint(e, "^7You've been ordered to^9\n^2Defend!\n");
917 sprint(self, "^7Invalid command, use ^3attack^7, or ^3defend^7.\n");