View Single Post
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