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

register_forward(FM_SetKeyValue, ...) ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bahr
Member
Join Date: Aug 2005
Old 04-13-2006 , 13:08   register_forward(FM_SetKeyValue, ...) ?
Reply With Quote #1

I cant make the register_forward(FM_SetKeyValue,..) to work; it seems to not catch the SetKeyValue() function. Am I missing something?

I have this:

Code:
public plugin_precache() {     register_forward(FM_SetKeyValue, "Hook_SetKeyValue") ... } public Hook_SetKeyValue(infobuffer[], key[], value[]) {     new fmt[256]     formatex(fmt, 255, "infobuffer ='%s', key = '%s', value = '%s'", infobuffer, key, value)     log_amx(fmt)     return FMRES_IGNORED }

I got no logging at all..

Thx
bahr is offline
Send a message via MSN to bahr
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 04-13-2006 , 13:35  
Reply With Quote #2

First off, that formatting thing you do is bad. bad!

log_amx does formatting for you. so do:

Code:
public Hook_SetKeyValue(infobuffer[], key[], value[]) {     log_amx("infobuffer ='%s', key = '%s', value = '%s'", infobuffer, key, value)     return FMRES_IGNORED }

Otherwise, your code is much less efficient (zeroing the fmt buffer on the stack, formatting into that buffer, then letting log_amx go through the entire output again) and fragile (imagine that infobuffer contained "%s", then the output from formatex in fmt would also contain "%s", so log_amx would look for a subsequent string parameter - it wouldn't find it and you'd get a runtime error).

Okay, to your actual issue..
The HLSdk doesn't use this function at all; I don't know what it does; probably the gamedll could tell the engine to set a keyvalue on an entity.. whatever

Most likely you want pfnKeyValue from DLL_FUNCTIONS or maybe pfnInfoKeyValue from enginefuncs_s.
__________________
hello, i am pm
PM is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-13-2006 , 14:22  
Reply With Quote #3

pm is teh smart
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
bahr
Member
Join Date: Aug 2005
Old 04-13-2006 , 18:43  
Reply With Quote #4

Is that mean I cant catch that function at all?
I need to catch it for a way to communicate from one plugin to another.
1st plugin: modify entities; moving, rotating, etc
2nd plugin: create special entities but need to know when 1st plugin modify the keys of entities created by the 2nd.
How can I achieve this?
bahr is offline
Send a message via MSN to bahr
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 04-14-2006 , 08:08  
Reply With Quote #5

DispatchKeyValue doesn't actually alter the keyvalue, it just makes the engine think the value is different. Sooo...maybe the engine forward?
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 04-14-2006 , 08:14  
Reply With Quote #6

Things that plugins do don't go through the hook layer anymore - so you can't intercept them (maybe with some hacks you could); otherwise it would be too easy to get infinite recursion problems and such.

The first plugin would have to notify the second one. We don't have an observer pattern implementation IIRC so callfunc would be most likely your best bet. Of course, assuming that you are able to modify the first plugin.

I hope I haven't misunderstood you

edit: bail said: plugins can do CreateMultiForward()

I imagine that that'd be better than callfunc.
__________________
hello, i am pm
PM is offline
bahr
Member
Join Date: Aug 2005
Old 04-14-2006 , 09:22  
Reply With Quote #7

Thanks

I think I'll try callfunc then ;)
bahr is offline
Send a message via MSN to bahr
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 03:30.


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