.:: 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 > SDK Programming discussions > Half-Life 2 SDK
Half-Life 2 SDK For developments focused around the Half-Life 2 engine Half-Life 2

Reply
 
Thread Tools
stuff that helps
Old
  (#1)
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 stuff that helps - 24-01-2005

stick this
Code:
void CPlugin::FireGameEvent (KeyValues *event)
{
   KeyValues *pKey;
   int data_type;
 
   // do we want to display game events on the fly ?
   if (hook_events.GetInt () > 0)
   {
	  ServerConsole_printf ("PMTools: Got event \"%s\"\n", event->GetName ()); // event name
	  ServerConsole_printf ("{\n"); // print the open brace
 
	  // display the whole key/value tree for this event
	  for (pKey = event->GetFirstSubKey (); pKey; pKey = pKey->GetNextKey ())
	  {
		 data_type = pKey->GetDataType (); // get the data type
 
		 // given the data type, print out the data
		 if (data_type == KeyValues.TYPE_NONE)
			ServerConsole_printf ("   \"%s\" = no value (TYPE_NONE)\n", pKey->GetName ());
		 else if (data_type == KeyValues.TYPE_STRING)
			ServerConsole_printf ("   \"%s\" = \"%s\" (TYPE_STRING)\n", pKey->GetName (), pKey->GetString ());
		 else if (data_type == KeyValues.TYPE_INT)
			ServerConsole_printf ("   \"%s\" = %d (TYPE_INT)\n", pKey->GetName (), pKey->GetInt ());
		 else if (data_type == KeyValues.TYPE_FLOAT)
			ServerConsole_printf ("   \"%s\" = %f (TYPE_FLOAT)\n", pKey->GetName (), pKey->GetFloat ());
		 else if (data_type == KeyValues.TYPE_PTR)
		 {
			if (pKey->GetPtr () == NULL) ServerConsole_printf ("   \"%s\" = NULL (TYPE_PTR)\n", pKey->GetName ());
			else ServerConsole_printf ("   \"%s\" = 0x%x (TYPE_PTR)\n", pKey->GetName (), pKey->GetPtr ());
		 }
		 else if (data_type == KeyValues.TYPE_WSTRING)
			ServerConsole_printf ("   \"%s\" = \"%s\" (TYPE_WSTRING)\n", pKey->GetName (), pKey->GetString ());
		 else if (data_type == KeyValues.TYPE_COLOR)
			ServerConsole_printf ("   \"%s\" = #%x%x%x, alpha 0x%x (TYPE_WSTRING)\n", pKey->GetName (), (pKey->GetInt () & 0xFF000000) >> 24, (pKey->GetInt () & 0x00FF0000) >> 16, (pKey->GetInt () & 0x0000FF00) >> 8, (pKey->GetInt () & 0x000000FF) >> 0);
		 else if (data_type == KeyValues.TYPE_NUMTYPES)
			ServerConsole_printf ("   \"%s\" = termination marker (TYPE_NUMTYPES)\n", pKey->GetName ());
	  }
 
	  ServerConsole_printf ("}\n"); // print the closing brace
   }
 
   return; // finished
}
in your Source plugin. Don't forget to declare a CVAR named "hook_events". Fire up a game, and enjoy.

That'll be in PMTools:Source .



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: stuff that helps
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: stuff that helps - 24-01-2005

note: ServerConsole_printf() roughly equals msg().



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: stuff that helps
Old
  (#3)
dub
Member
 
dub's Avatar
 
Status: Offline
Posts: 89
Join Date: Aug 2004
Location: UK
Default Re: stuff that helps - 24-01-2005

Great work Pierre-Marie, I was wondering if you were going to add an option to dump KeyValues .


Dubb`s Coding Cave WiP - YeGods - Free Image hosting
4u-servers.co.uk : YeGods Gin Palace II - Refloated - 195.20.108.30:27025
  
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