Difference between revisions of "User talk:^Ben"

From Valve Developer Community
Jump to: navigation, search
Line 2: Line 2:
  
 
[[Valve Developer TidBits]]
 
[[Valve Developer TidBits]]
 +
 +
Game Event System
 +
 +
Creating Events
 +
IGameEvent *event = gameeventmanager->CreateEvent( "player_death" );
 +
if( event )
 +
{
 +
event->SetInt("userid", pVictim->GetUserID() );
 +
event->SetInt("attacker", killer_ID );
 +
event->SetString("weapon", killer_weapon_name );
 +
gameeventmanager->FireEvent( event );
 +
}
 +
 +
Listening for Events
 +
gameeventmanager->AddListener( this, "player_death", false );
 +
 +
Capturing Events
 +
void CMapOverview::FireGameEvent( IGameEvent *event )
 +
{
 +
const char * type = event->GetName();
 +
if ( Q_strcmp(type, "player_death") == 0 )
 +
{
 +
}
 +
}

Revision as of 12:09, 2 May 2006

http://www.student.kun.nl/rvanhoorn/Optimization.htm

Valve Developer TidBits

Game Event System

Creating Events

IGameEvent *event = gameeventmanager->CreateEvent( "player_death" );
if( event )
{
	event->SetInt("userid", pVictim->GetUserID() );
	event->SetInt("attacker", killer_ID );
	event->SetString("weapon", killer_weapon_name );
	gameeventmanager->FireEvent( event );
}

Listening for Events

gameeventmanager->AddListener( this, "player_death", false );

Capturing Events

void CMapOverview::FireGameEvent( IGameEvent *event )
{
	const char * type = event->GetName();
	if ( Q_strcmp(type, "player_death") == 0 )
	{
	}
}