AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Catch name changes (https://forums.alliedmods.net/showthread.php?t=2767)

SomeonE 06-16-2004 08:49

Catch name changes
 
How can i catch name changes? I tried with: public client_infochanged(id)
but then the name is already changed. And i also tried with: register_clcmd("name"... and then nothing happen.

The thing i want to do is if some one tries to change name to something i dont want him to change to, then will i just change it to something else. How can i do it?

Johnny got his gun 06-16-2004 08:51

I'm not entirely clear either how this works, but for WWW REg I hooked client_infochanged:

Code:
public client_infochanged(id) {     //if (regged(id))         //addregisteredaccess(id)     if (is_user_bot(id) || is_user_connecting(id))         return PLUGIN_CONTINUE     /*     new buffer[128]     get_info_keybuffer(id, buffer, 127)     client_print(0, print_chat, "ic %d:%s", id, buffer)     server_print("ic %d:%s", id, buffer)     */     new newname[32] // oldname[32],     //get_user_name(id, oldname, 31)     get_user_info(id, "name", newname, 31)     new prepend[32]     get_cvar_string(CVAR_PREPEND, prepend, 31)     new const PREPENDLENGTH = strlen(prepend)     if (PREPENDLENGTH > 0 && !regged(id)) { // if prepend cvar is empty, don't bother doing this!         // Force prefix on unregistered players         if (!equal(prepend, newname, PREPENDLENGTH)) {             server_print("[%s] Forcing Pub: name on %s", PLUGINNAME, newname)             new regurl[64]             get_cvar_string(CVAR_REGURL, regurl, 63)             client_print(id, print_console, "Because you aren't registered at %s you must use the prefix ^"%s^".", regurl, prepend)             format(newname, 31, "%s%s", prepend, newname)             //entity_set_string(idd[0], EV_SZ_netname, name)             set_user_info(id, "name", newname)             return PLUGIN_HANDLED         }     }     else if (regged(id)) {         // Regged here         if (!equal(newname, g_forumnames[id])) {             server_print("[%s] Forcing forum name (%s) on %s", PLUGINNAME, g_forumnames[id], newname)             client_print(id, print_console, "Sorry, you must use your name (%s) from forums!", g_forumnames[id], newname)             set_user_info(id, "name", g_forumnames[id]) // Force forum name             return PLUGIN_HANDLED         }     }     //new idd[1]     //idd[0] = id     //set_task(0.1, "checkname", 0, idd, 1)     return PLUGIN_CONTINUE }

SomeonE 06-16-2004 09:25

ok, ill test it. thx.

PM 06-16-2004 14:08

how it works: client cvars like name and model have the CVAR_USERINFO flag.

Code:

#define        FCVAR_USERINFO                (1<<1)        // changes the client's info string
(HLSDK: common/cvardef.h)

When such a cvar changes, the clients info string is changed, and the client_infochanged function in plugins is called :)


All times are GMT -4. The time now is 14:53.

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