AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Name change problem (https://forums.alliedmods.net/showthread.php?t=174056)

StickP0le 12-14-2011 19:37

Name change problem
 
Can someone teach me how to change name while dead or being spectator or team_unassgined?

ConnorMcLeod 12-15-2011 00:54

Re: Name change problem
 
PHP Code:

#include <amxmodx>
#include <fakemeta>

#define VERSION "0.0.1"

public plugin_init()
{
    
register_plugin("Dead Name Change"VERSION"ConnorMcLeod")
    
register_forward(FM_ClientUserInfoChanged"ClientUserInfoChanged")
}

public 
ClientUserInfoChanged(id)
{
    new 
szOldName[32]
    
pev(idpev_netnameszOldNamecharsmax(szOldName))
    if( 
szOldName[0] && !is_user_alive(id) )
    {
        new 
szNewName[32]
        
get_user_info(id"name"szNewNamecharsmax(szNewName))
        if( !
equal(szOldNameszNewName) )
        {
            
set_pev(idpev_deadflagDEAD_NO)
            return 
FMRES_HANDLED
        
}
    }
    return 
FMRES_IGNORED



StickP0le 12-15-2011 15:09

Re: Name change problem
 
no, it doesn´t work, look the thing is that i have an account system and when somebody wants to create a new character, he has to change his name and re enter the server, and i want that instantly change his name, being spectating or unassigned team

ConnorMcLeod 12-16-2011 01:57

Re: Name change problem
 
Then you need to express yourself better.

SetUserName(index, "ConnorMcLeod") will change player name even if he is dead, unassigned, spec.

PHP Code:

SetUserName(idszNewName[], bool:bSilent falsebool:bDeadInstantChange true)
{
    new 
szOldName[32]
    
get_user_info(id"name"szOldNamecharsmax(szOldName))
    if( !
equal(szOldNameszNewName) )
    {
        
set_user_info(id"name"szNewName)

        if( 
is_user_connected(id) )
        {
            new 
iDeadFlag pev(idpev_deadflag)
            if( 
iDeadFlag != DEAD_NO )
            {
                if( 
bDeadInstantChange )
                {
                    
set_pev(idpev_netnameszNewName)
                    if( !
bSilent )
                    {
                        
set_pev(idpev_deadflagDEAD_NO)
                        
dllfunc(DLLFunc_ClientUserInfoChangedidengfunc(EngFunc_GetInfoKeyBufferid))
                        
set_pev(idpev_deadflagiDeadFlag)
                    }
                }
            }
            else if( 
bSilent )
            {
                
set_pev(idpev_netnameszNewName)
            }
        }
    }



StickP0le 12-16-2011 16:47

Re: Name change problem
 
thanks man!


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

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