}
+float setSpectator()
+{
+ if(self.enemy.classname != "player")
+ return FALSE;
+ /*if(self.enemy.vehicle)
+ {
+
+ msg_entity = self;
+ WriteByte(MSG_ONE, SVC_SETVIEW);
+ WriteEntity(MSG_ONE, self.enemy);
+ //stuffcmd(self, "set viewsize $tmpviewsize \n");
+
+ self.movetype = MOVETYPE_NONE;
+ accuracy_resend(self);
+ }
+ else
+ {*/
+ msg_entity = self;
+ WriteByte(MSG_ONE, SVC_SETVIEW);
+ WriteEntity(MSG_ONE, self.enemy);
+ //stuffcmd(self, "set viewsize $tmpviewsize \n");
+ self.movetype = MOVETYPE_NONE;
+ accuracy_resend(self);
+
+ if(!SpectateUpdate())
+ PutObserverInServer();
+ //}
+ return TRUE;
+}
+
+float Spectate(entity pl)
+{
+ if(g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer)
+ if(pl.team != self.team)
+ return 0;
+
+ self.enemy = pl;
+ return setSpectator();
+}
+
// Returns next available player to spectate if g_ca_spectate_enemies == 0
entity CA_SpectateNext(entity start) {
if (start.team == self.team) {
return other;
}
-float SpectateNext(entity _prefer) {
-
- if(_prefer)
- other = _prefer;
- else
- other = find(self.enemy, classname, "player");
-
+float SpectateNext()
+{
+ other = find(self.enemy, classname, "player");
+
if (g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer) {
// CA and ca players when spectating enemies is forbidden
other = CA_SpectateNext(other);
if (!other)
other = find(other, classname, "player");
}
-
+
if (other)
self.enemy = other;
- if(self.enemy.classname == "player") {
- /*if(self.enemy.vehicle)
- {
-
- msg_entity = self;
- WriteByte(MSG_ONE, SVC_SETVIEW);
- WriteEntity(MSG_ONE, self.enemy);
- //stuffcmd(self, "set viewsize $tmpviewsize \n");
-
- self.movetype = MOVETYPE_NONE;
- accuracy_resend(self);
- }
- else
- {*/
- msg_entity = self;
- WriteByte(MSG_ONE, SVC_SETVIEW);
- WriteEntity(MSG_ONE, self.enemy);
- //stuffcmd(self, "set viewsize $tmpviewsize \n");
- self.movetype = MOVETYPE_NONE;
- accuracy_resend(self);
-
- if(!SpectateUpdate())
- PutObserverInServer();
- //}
- return 1;
- } else {
- return 0;
- }
+ return setSpectator();
}
/*
self.flags |= FL_SPAWNING;
} else if(self.BUTTON_ATCK && !self.version_mismatch) {
self.flags &~= FL_JUMPRELEASED;
- if(SpectateNext(world) == 1) {
+ if(SpectateNext()) {
self.classname = "spectator";
}
} else {
self.flags |= FL_SPAWNING;
} else if(self.BUTTON_ATCK) {
self.flags &~= FL_JUMPRELEASED;
- if(SpectateNext(world) == 1) {
+ if(SpectateNext()) {
self.classname = "spectator";
} else {
self.classname = "observer";