View Full Version : get all keyvalues and create a copy

24-11-2016, 11:17 PM

I'm trying to write a little script where you can store an entity and later create an instance of it.
But I can't figure out how to get all keyvalues from an ent.
I hope someone can help me.

Here's my code:

//BTW. this is part of a weapon script
CBaseEntity@ pEntity = g_Utility.FindEntityForward( self.m_pPlayer, 4096 );
//Spawn it directly for test reasons
CBaseEntity@ pNewEnt = g_EntityFuncs.Create( pEntity.pev.classname, self.m_pPlayer.GetGunPosition() + g_Engine.v_forward * 64, Vector(0,0,0), false);
//Now: How do I get all entvars of pEntity and how do I write them into pNewEnt?

09-01-2017, 07:37 PM
Not all keyvalues can be saved from an entity. Some settings are only accessible to that entity's private code.

Copy pEntity.pev to pNewEnt.pev and hope for the best.

Edit: If you cast the ent down to something more specific than CBaseEntity (like CBaseMonster) you'll be able to copy more stuff.