This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Get Entity Key Value?


Post New Thread Reply   
 
Thread Tools Display Modes
psychonic

BAFFLED
Join Date: May 2008
Old 11-09-2014 , 13:49   Re: Get Entity Key Value?
Reply With Quote #11

I don't know much about mapping, and maybe they can store custom keys/values for use only in the map's own logic. Those indeed wouldn't show in a datamap dump. Additionally, not all compiled-in keys are mapped directly to variables and thus, would also not show up. The GetKeyValue/[Set]KeyValue baseentity functions special-cases many key names (as derived entities can also do).

You don't need an extension to call GetKeyValue. A BaseEntity SDKCall in an SM plugin would work fine.

This could also easily be added to SM itself as well if someone wants to do a Pull Request. GetKeyValue is exposed on the IServerTools interface, not requiring gamedata.

Last edited by psychonic; 11-09-2014 at 13:55.
psychonic is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 11-10-2014 , 00:54   Re: Get Entity Key Value?
Reply With Quote #12

You can create any keyvalue you like in hammer by disabling the smart editor.
Possibly with addoutput, entities could make them as well, or at least set them? I did not try.
I never bothered to look and see if they are actually accessable in game. I know that entity classnames that are invalid get filtered out, and most datamap values that aren't used by the entity get reset/zeroed out pretty often (every frame?).
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 11-10-2014 at 00:54.
friagram is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-10-2014 , 11:59   Re: Get Entity Key Value?
Reply With Quote #13

Quote:
Originally Posted by psychonic View Post
I don't know much about mapping, and maybe they can store custom keys/values for use only in the map's own logic.
Quote:
Originally Posted by friagram View Post
You can create any keyvalue you like in hammer by disabling the smart editor.
Possibly with addoutput, entities could make them as well, or at least set them? I did not try.
I never bothered to look and see if they are actually accessable in game. I know that entity classnames that are invalid get filtered out, and most datamap values that aren't used by the entity get reset/zeroed out pretty often (every frame?).
I'll be totally honest here and say I haven't tried it.

However, glancing at the Source SDK code, the things that appear in the Hammer editor have backing fields in the class linked to the entity. They (and DataMaps) appear to be created using macros to link them to (already existing) backing fields. (Netprops have something similar, but the backing variables are declared as being a netprop on creation)

The point being that they work because they already have storage in the C++ code.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 11-11-2014 , 03:41   Re: Get Entity Key Value?
Reply With Quote #14

Yes, and when you check for errors it'll cry if the entity doesn't "support" that keyvalue...
Though sometimes it does... Common one is like angles on keyframe_rope, or hammerid on entities from decompiled maps, obviously hammerid and angles are valid. It likely only supports the values that are coded to work there
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Spirrwell
Member
Join Date: Jul 2013
Old 11-12-2014 , 03:50   Re: Get Entity Key Value?
Reply With Quote #15

Ah, the game I'm working with is Pirates, Vikings, and Knights II. I was hoping that I could make the gamemode feel less artificial (yeah, that word kind of makes no sense in this context anyway) by avoiding a reliance on SM menus and the like.

I looked at the code myself as well:

Code:
for ( datamap_t *dmap = GetDataDescMap(); dmap != NULL; dmap = dmap->baseMap )
	{
		if ( ::ExtractKeyvalue( this, dmap->dataDesc, dmap->dataNumFields, szKeyName, szValue, iMaxLen ) )
			return true;
	}
#endif

	return false;

It doesn't seem possible. Oh well. I learned a lot about finding virtual offsets and whatnot thanks to this, so at least I learned something.
Spirrwell is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:54.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode