AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Retriving keyvalues (https://forums.alliedmods.net/showthread.php?t=278863)

Zynda 02-09-2016 20:27

Retriving keyvalues
 
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.

Anggara_nothing 02-09-2016 20:40

Re: Retriving keyvalues
 
Does this works?
https://forums.alliedmods.net/showth...11304?p=511304

Zynda 02-09-2016 21:00

Re: Retriving keyvalues
 
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.

klippy 02-10-2016 00:52

Re: Retriving keyvalues
 
Quote:

Originally Posted by Zynda (Post 2391575)
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.

Zynda 02-14-2016 01:58

Re: Retriving keyvalues
 
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?


All times are GMT -4. The time now is 09:29.

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