Raised This Month: $ Target: $400
 0% 

FM_KeyValue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Silencer123
Veteran Member
Join Date: Jul 2006
Old 05-03-2007 , 16:30   FM_KeyValue
Reply With Quote #1

I registered the forward FM_KeyValue but it actually never got called.
I want the following function to be called when some KeyValue on an
entity, to be more precisely, a client, has changed.
Code:
public scxpm_set_displayname(id,kv) {     client_print(0,print_chat,"DISPLAYNAME STEP 1/4")     if(get_pcvar_num(cvar_dpname))     {         client_print(0,print_chat,"DISPLAYNAME STEP 2/4")         if(pev_valid(id))         {             client_print(0,print_chat,"DISPLAYNAME STEP 3/4")             new var[128]             get_kvd(kv,KV_KeyName,var,31)             if(equali(var,"displayname"))             {                 client_print(0,print_chat,"DISPLAYNAME STEP 4/4")                 get_kvd(kv,KV_Value,var,31)                 format(var,127,"%s^nLevel: %i^nRank: %s",var,playerlevel[id],rank[id])                 forward_return(FMV_STRING,var)                 return FMRES_SUPERCEDE             }         }     }     return FMRES_IGNORED }
As "DISPLAYNAME STEP 1/4" is never being printed to console I guess this is
never being called. Note that I registered the forward in plugin_init, because
thats where to register cvars too which this function shall know about.
__________________
EAT YOUR VEGGIES
Silencer123 is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 05-03-2007 , 16:32   Re: FM_KeyValue
Reply With Quote #2

I believe you have to register that forward in public plugin_precache().
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Silencer123
Veteran Member
Join Date: Jul 2006
Old 05-03-2007 , 16:39   Re: FM_KeyValue
Reply With Quote #3

Why that? This function is called frequently. Everytime an entities keyvalue changes!
Monsters hp. Players health, armor, angles, velocity, and that displayname.
Why should this requires to be registered that second earlier??
__________________
EAT YOUR VEGGIES
Silencer123 is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 05-03-2007 , 16:45   Re: FM_KeyValue
Reply With Quote #4

I don't know FM_KeyValue that well but all I remember when I saw other people used it. It was registered in precache and they were trying to modify the keyvalue of those entity to there liking.

I only saw FM_KeyValue forward used that way although I can be totally wrong on this though. Since I do not deal with entity stuff that much.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Silencer123
Veteran Member
Join Date: Jul 2006
Old 05-03-2007 , 17:04   Re: FM_KeyValue
Reply With Quote #5

I have tried that but it still is not being called.
now i tried something completely different.
The following function is being called when the player spawns:
Code:
public scxpm_set_displayname(id) {     client_print(0,print_chat,"DISPLAYNAME STEP 1/3")     if(get_pcvar_num(cvar_dpname))     {         client_print(0,print_chat,"DISPLAYNAME STEP 2/3")         if(pev_valid(id))         {             client_print(0,print_chat,"DISPLAYNAME STEP 3/3")             new var[128]             format(var,127,"%s^nLevel: %i^nRank: %s",var,playerlevel[id],rank[id])             engfunc(EngFunc_SetClientKeyValue,engfunc(EngFunc_GetInfoKeyBuffer,id),"displayname",var)         }     } }
But there is a native error in the engfunc somewhere. [FAKEMETA] Invalid Entity.
__________________
EAT YOUR VEGGIES
Silencer123 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-04-2007 , 05:41   Re: FM_KeyValue
Reply With Quote #6

AFAIK, pfnKeyValue is for non-player entities only.

Furthermore you shouldn't return string function result in this case bause this function returns nothing:
Quote:
DLLFunc_KeyValue, // void ) (edict_t *pentKeyvalue, KeyValueData *pkvd);
Quote:
Why that? This function is called frequently. Everytime an entities keyvalue changes!
Monsters hp. Players health, armor, angles, velocity, and that displayname.
Why should this requires to be registered that second earlier??
You totally misinterpreting that function. http://forums.alliedmods.net/showpos...66&postcount=3

I think you are looking for pfnSetClientKeyValue.
VEN is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 05-04-2007 , 07:10   Re: FM_KeyValue
Reply With Quote #7

What is pfnSetClientKeyValue? Can't find it in any .inc, doc or functions database.
__________________
EAT YOUR VEGGIES
Silencer123 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-04-2007 , 09:52   Re: FM_KeyValue
Reply With Quote #8

pfnSetClientKeyValue is HL engine function.

To hook it you have to use register_froward(FM_SetClientKeyValue, ...)
And to call it you have to use engfunc(EngFunc_SetClientKeyValue, ...)
VEN is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 05-04-2007 , 12:32   Re: FM_KeyValue
Reply With Quote #9

Funny, I tried exactly that one before and it also never was called after plugin_init.
I needed something that is called everytime a keyvalue of a player changes.
In instance every time a player takes damage such event should be called, because
his health keyvalue has changed. But whatsoever I just discovered that svencoop
never touches displayname. it gets the playersname and puts that in the hudmessage.
Only if displayname is added it is looking for it. so now I do the job when the player
spawns and I want to do it when he changes name i use client_infochanged but
with a set_task on 0.2 seconds as it is a forward. Anyways I'd still like to have a Forward
I asked for.
__________________
EAT YOUR VEGGIES
Silencer123 is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 05-04-2007 , 19:36   Re: FM_KeyValue
Reply With Quote #10

Well there still is nothing happening. the displayname is being changed, but is not being showed really.
it is like in entmod - when u change an entities keyvalues u have to respawn it. Any idea on
how to get around that when handling with a player?
__________________
EAT YOUR VEGGIES
Silencer123 is offline
Reply


Thread Tools
Display Modes

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 06:42.


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