AlliedModders

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

Silencer123 05-03-2007 16:30

FM_KeyValue
 
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.

teame06 05-03-2007 16:32

Re: FM_KeyValue
 
I believe you have to register that forward in public plugin_precache().

Silencer123 05-03-2007 16:39

Re: FM_KeyValue
 
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??

teame06 05-03-2007 16:45

Re: FM_KeyValue
 
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.

Silencer123 05-03-2007 17:04

Re: FM_KeyValue
 
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.

VEN 05-04-2007 05:41

Re: FM_KeyValue
 
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.

Silencer123 05-04-2007 07:10

Re: FM_KeyValue
 
What is pfnSetClientKeyValue? Can't find it in any .inc, doc or functions database.

VEN 05-04-2007 09:52

Re: FM_KeyValue
 
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, ...)

Silencer123 05-04-2007 12:32

Re: FM_KeyValue
 
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.

Silencer123 05-04-2007 19:36

Re: FM_KeyValue
 
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?


All times are GMT -4. The time now is 06:42.

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