View Single Post
Re: Ded servers with hlds
Old
  (#2)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Ded servers with hlds - 05-01-2004

I wrote my own facilities
Code:
int printf (const char *fmt, ...)
{
   // this function prints a message on the screen. If we are running a dedicated server, the
   // text will be printed on the server console, else if we are running a listen server, it
   // will be printed in game on the listen server client's HUD chat area. Since it's basically
   // a redefinition of the standard C libraries printf() function, it has to be the same type,
   // hence the integer return value.
   va_list argptr;
   static char string[1024];
   // concatenate all the arguments in one string
   va_start (argptr, fmt);
   vsprintf (string, fmt, argptr);
   va_end (argptr);
   // are we running a listen server ?
   if (!server.is_dedicated && IsValidPlayer (pListenserverEntity))
   {
	  MESSAGE_BEGIN (MSG_ONE, GetUserMsgId ("SayText"), NULL, pListenserverEntity); // then print to HUD
	  WRITE_BYTE (ENTINDEX (pListenserverEntity));
	  WRITE_STRING (string);
	  MESSAGE_END ();
   }
   else
	  pfnServerPrint (string); // else print to console
   // if developer mode is on...
   if (server.developer_level > 0)
	  LogToFile ("(server HUD): %s", string); // also log this message to the logfile
   return (0); // printf() HAS to return a value
}

int ServerConsole_printf (const char *fmt, ...)
{
   // this function asks the engine to print a message on the server console
   va_list argptr;
   static char string[1024];
   // concatenate all the arguments in one string
   va_start (argptr, fmt);
   vsprintf (string, fmt, argptr);
   va_end (argptr);
   (*g_engfuncs.pfnServerPrint) (string); // print to console
   // if developer mode is on...
   if (server.developer_level > 0)
	  if (string[0] == '.')
		 LogToFile (string); // also log this message to the logfile (not prefixing dots)
	  else
		 LogToFile ("(server console): %s", string); // also log this message to the logfile
   return (0); // printf() HAS to return a value
}



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote