View Single Post
Author Message
Kingnugget
Junior Member
Join Date: Apr 2005
Old 04-21-2005 , 16:52   How do you spawn objects into a map on client commands?
Reply With Quote #1

I am basically trying to create a grenade on a player death or client command and make it explode.
But this raises a basic question of creating objects in a game.

I found some code that looked like it might do the job for a smoke grenade, but I got loads of errors.

Code:
ParticleSmokeGrenade *pSmoke = dynamic_cast<ParticleSmokeGrenade*>( CreateEntityByName(PARTICLESMOKEGRENADE_ENTITYNAME) );
if ( pSmoke )
{
	Vector vForward;
	AngleVectors( GetLocalAngles(), &vForward );
	vForward.z = 0;
	VectorNormalize( vForward );

	pSmoke->SetLocalOrigin( GetLocalOrigin() + vForward * 100 );
	pSmoke->SetFadeTime(25, 30);	// Fade out between 25 seconds and 30 seconds.
	pSmoke->Activate();
	pSmoke->SetLifetime(30);
	pSmoke->FillVolume();
}
This gave me the error message (first of many): error C2065: 'ParticleSmokeGrenade' : undeclared identifier.
I added #include "particle_smokegrenade.h" but then got the error "..\..\dlls\baseentity.h(759) : error C2065: 'CPredictableId' : undeclared identifier".
Adding other include headers from this point spiralled down into loads errors.

I am missing something basis?
Are the any examples about for spawning objects into a game?
Kingnugget is offline