Raised This Month: $51 Target: $400
 12% 

Retriving keyvalues


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zynda
Member
Join Date: Jul 2011
Old 02-09-2016 , 20:27   Retriving keyvalues
Reply With Quote #1

Hello,

First of all, this is what i would like to accomplish:
  • Retrive keyvalue pairs from an entity directly
The way i've been handling keyvalues in the past is by hooking FM_KeyValue and storing keyvalue data as they are being set by the engine.

Now, in a new project for Sven Co-op, there is a loophole where keyvalue data can be changed through certain entities native to Sven Co-op. Such as:During my testing, triggering these entities can successfully change keyvalues of other entities without the FM_KeyValue forward being triggered.
Should such an entity be triggered i become blind to the fact that the keyvalue data of its target is different from when i last retrieved it; as my local cache of the target entity is now different from reality.

Now i am asking for your help. Is there another way of retrieving keyvalues, maybe directly from the engine?
Could it be possible to hook the function these entites use to change keyvalue data?

Even getting just the value when you already know the key would be somewhat useful.

Thank you for your time.

Last edited by Zynda; 02-10-2016 at 00:37.
Zynda is offline
Anggara_nothing
Veteran Member
Join Date: Jan 2009
Location: Indonesia
Old 02-09-2016 , 20:40   Re: Retriving keyvalues
Reply With Quote #2

Does this works?
https://forums.alliedmods.net/showth...11304?p=511304
Anggara_nothing is offline
Zynda
Member
Join Date: Jul 2011
Old 02-09-2016 , 21:00   Re: Retriving keyvalues
Reply With Quote #3

I wrongfully specified i hooked FM_SetKeyValue in my original post, which has been updated.
PHP Code:
From kve.sma

register_forward
(FM_KeyValue"on_key_value"); 
It uses the same forward - FM_KeyValue. I doubt it will be of much help.

Last edited by Zynda; 02-10-2016 at 00:36.
Zynda is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-10-2016 , 00:52   Re: Retriving keyvalues
Reply With Quote #4

Quote:
Originally Posted by Zynda View Post
I wrongfully specified i hooked FM_SetKeyValue in my original post, which has been updated.
PHP Code:
From kve.sma

register_forward
(FM_KeyValue"on_key_value"); 
It uses the same forward - FM_KeyValue. I doubt it will be of much help.
That hook is executed when the game engine calls DispatchKeyValue() in mod DLL. That happens for entities which are read from BSP. These 2 entities probably don't use the same function to change keyvalues, they most likely call ::KeyValue() virtual function on the targeted entity.
So, you would probably have to hook Ham_KeyValue for all entities, or use, say Orpheu, to hook the function which these 2 entities use.
klippy is offline
Zynda
Member
Join Date: Jul 2011
Old 02-14-2016 , 01:58   Re: Retriving keyvalues
Reply With Quote #5

Thank you for your input Klippy, and i do believe you are correct.
I've succesfully hooked ::Keyvalue() on a func_door as a test and when changing, for example, the wait key everything goes smoothly.
However, some other keys such as speed or angles does seemingly not use the func_door's ::Keyvalue() function. Any reason why some keys would get set differently?

Last edited by Zynda; 02-14-2016 at 02:04.
Zynda 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 19:40.


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