AlliedModders

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

SchlumPF* 09-04-2008 10:33

forward for name changes
 
i think i have seen a fm forward which is called whenever a player changes his name but unfortunately i cannot remember the exact forward name :S
does anyone now that forward?

ConnorMcLeod 09-04-2008 10:56

Re: forward for name changes
 
FM_ClientUserInfoChanged, but you can use client_infochanged as well :)
May be you can filter the fm one with infobuffer.

v3x 09-04-2008 11:00

Re: forward for name changes
 
This is the closest you're going to get:
PHP Code:

#include <amxmodx>

public client_infochangedid )
{
    static 
old_name[32]
    static 
new_name[32]

    
get_user_infoid "name" old_name 31 )
    
get_user_nameid new_name 31 )

    if( !
equalold_name new_name ) )
    {
        
// player has changed name
    
}


I forget which one is old and which one is new. Doesn't matter anyway.

Exolent[jNr] 09-04-2008 11:19

Re: forward for name changes
 
@v3x

Code:
new new_name[32], old_name[32]; get_user_info(index, "name", new_name, sizeof(new_name) - 1); get_user_name(index, old_name, sizeof(oldname) - 1);

The forward is called before the player's name is changed, so the player's current name is still the same.
However, the player has entered the name into their info (name "Exolent") but it hasn't changed their name, yet.

Orangutanz 09-04-2008 12:02

Re: forward for name changes
 
Best method:
Code:
public SetClientKeyValue( id, infobuffer[], key[], value[] ) {     if ( equal( key, "name" ) && !equal( value,  "New Name" ) )     {         set_user_info( id, "name", "New Name" )         return FMRES_SUPERCEDE     }     return FMRES_IGNORED }
You can catch the change as it's actually happening, also be very careful of set_user_info it's a nice server crasher when issuing to 20+ players at once, it seems ok in above function mind.

v3x 09-04-2008 12:23

Re: forward for name changes
 
He never said he wanted to block it :P

But that's definitely a better way of doing it.

Orangutanz 09-04-2008 12:25

Re: forward for name changes
 
It's an example, he can surely work out how to catch the name from that :mrgreen:

SchlumPF* 09-04-2008 16:39

Re: forward for name changes
 
Quote:

Originally Posted by Orangutanz (Post 681124)
It's an example, he can surely work out how to catch the name from that :mrgreen:

ofc i can :D thats exactly the forward i saw sometime ago!
thx to everyone, karma++ orangutanz :)


All times are GMT -4. The time now is 03:18.

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