View Full Version : g_EntityFuncs.GetKeyValue ?

03-04-2016, 05:53 PM
You can set the keyvalues of entities with g_EntityFuncs.DispatchKeyValue( pEnt.edict(), szKey, szValue );
But is there a way to retrieve them? Like: g_PlayerFuncs.ClientPrint( pPlayer, HUD_PRINTCONSOLE, "Keyvalue " + szKey + " = " + g_EntityFuncs.GetKeyValue( pEnt.edict(), szKey ) + "\n" );

03-04-2016, 06:03 PM
Using KeyValueBuffer I can only get the model name, but not scale or other stuff like that. :[

03-04-2016, 07:15 PM
If they are "default" keyvalues, you can use ent.pev.keyname. For example ent.pev.health

pev are public entity variables iirc and is basically a container for all keyvalues which get networked i.e. sent to clients.

For everything else it may or may not be possible to get/set them. I think DispatchKeyvalue should only be used prior to spawning an entity. "Injecting" stuff later may cause unwanted behaviour.

03-04-2016, 07:54 PM
Oh, so I'll have to put in every key in the script then.
Oh well, thanks! ^^

05-04-2016, 04:36 AM
KeyValueBuffer accesses a player's networked settings.
pev stands for pointer to entvars_t. entvars_t contains all variables that the engine accesses, and that can be networked.
DispatchKeyvalue should be used when setting keyvalues on entities.
There is no way to retrieve individual keyvalues by name.

05-04-2016, 04:50 PM
Aha, thanks :3