.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Ded servers with hlds
Old
  (#1)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Ded servers with hlds - 05-01-2004

I just noticed something for ded servers... In botman's code (and I think I saw it in others to) printf is used to show message's at the screen when a dedicated server runs. But this won't work with hlds.
So instead of printf(msghere) use
Code:
(*g_engfuncs.pfnServerPrint) (msghere)
(Or did I just say something every knew except me )
  
Reply With Quote
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
Re: Ded servers with hlds
Old
  (#3)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: Ded servers with hlds - 06-01-2004

looks nice ah well guess you already figured it out printf does not work But it could be handy to know for beginners
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com