r1739 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Jul 9 10:25:08 EDT 2006


Author: div0
Date: 2006-07-09 10:25:08 -0400 (Sun, 09 Jul 2006)
New Revision: 1739

Modified:
   trunk/data/qcsrc/server/clientcommands.qc
Log:
make say_team look different from say in team games; say_team shall not reach
observers/spectators/console any more. Please test!


Modified: trunk/data/qcsrc/server/clientcommands.qc
===================================================================
--- trunk/data/qcsrc/server/clientcommands.qc	2006-07-09 10:16:56 UTC (rev 1738)
+++ trunk/data/qcsrc/server/clientcommands.qc	2006-07-09 14:25:08 UTC (rev 1739)
@@ -1,6 +1,72 @@
 void ReadyCount();
 float ValidateMap(string vote);
 
+void Say(entity source, float teamsay, string msgin)
+{
+	string msgstr, colorstr;
+	entity head;
+
+	msgin = formatmessage(msgin);
+
+	if(source.team == COLOR_TEAM1)
+		colorstr = "^1";
+	else if(source.team == COLOR_TEAM2)
+		colorstr = "^4";
+	else if(source.team == COLOR_TEAM3)
+		colorstr = "^6";
+	else if(source.team == COLOR_TEAM4)
+		colorstr = "^3";
+	else
+		colorstr = "^7";
+
+	if(!teams_matter)
+		teamsay = FALSE;
+
+	if(source.classname != "player") // observers can't
+		teamsay = FALSE;
+
+	// how can we prevent the message from appearing in a listen server?
+	// for now, just give "say" back and only handle say_team
+	if(!teamsay)
+	{
+		clientcommand(self, strcat("say ", msgin));
+		return;
+	}
+
+	if(teamsay)
+		msgstr = strcat(colorstr, "(^3", source.netname, colorstr, ") ^7", msgin, "\n");
+	else
+		msgstr = strcat("^3", source.netname, "^7: ", msgin, "\n");
+
+	head = find(world, classname, "player");
+	while(head)
+	{
+		if(clienttype(head) == CLIENTTYPE_REAL)
+			if(!teamsay || (head.team == source.team))
+				sprint(head, msgstr);
+		head = find(head, classname, "player");
+	}
+
+	if(!teamsay)
+	{
+		head = find(world, classname, "observer");
+		while(head)
+		{
+			if(clienttype(head) == CLIENTTYPE_REAL)
+				sprint(head, msgstr);
+			head = find(head, classname, "observer");
+		}
+		head = find(world, classname, "spectator");
+		while(head)
+		{
+			if(clienttype(head) == CLIENTTYPE_REAL)
+				sprint(head, msgstr);
+			head = find(head, classname, "spectator");
+		}
+		ServerConsoleEcho(substring(msgstr, 0, strlen(msgstr) - 1), TRUE);
+	}
+}
+
 void SV_ParseClientCommand(string s) {
 	local float index;
 
@@ -258,9 +324,11 @@
 			ReadyCount();
 		}
 	} else if(argv(0) == "say") {
-		clientcommand(self, formatmessage(s));
+		Say(self, FALSE, substring(s, 4, strlen(s) - 4));
+		//clientcommand(self, formatmessage(s));
 	} else if(argv(0) == "say_team") {
-		clientcommand(self, formatmessage(s));
+		Say(self, TRUE, substring(s, 9, strlen(s) - 9));
+		//clientcommand(self, formatmessage(s));
 	} else {
 		clientcommand(self,s);
 	}




More information about the nexuiz-commits mailing list