AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Blocking name change... (https://forums.alliedmods.net/showthread.php?t=187417)

Neeeeeeeeeel.- 06-12-2012 21:21

Blocking name change...
 
Which is the best way to do it?

I need to block name change if a var it is true. I know how, but is not the best way.

Liverwiz 06-12-2012 21:24

Re: Blocking name change...
 
PHP Code:

// plugin_init
register_clcmd("name""cmdName")

public 
cmdName(id)
    return 
PLUGIN_HANDLED 

give that a test.

Neeeeeeeeeel.- 06-12-2012 21:33

Re: Blocking name change...
 
Do not work.
I meant with fakemeta.

YamiKaitou 06-12-2012 21:42

Re: Blocking name change...
 
Use client_infochanged

Search, I barely recall this being addressed in the past

Neeeeeeeeeel.- 06-12-2012 21:52

Re: Blocking name change...
 
Quote:

Originally Posted by YamiKaitou (Post 1727637)
Use client_infochanged

Search, I barely recall this being addressed in the past

Yes i know that native but I what I'm looking for is how to block it, in client_infochanged or in fakemeta forward...

YamiKaitou 06-12-2012 22:03

Re: Blocking name change...
 
Please Search....

Also, why are you restricting yourself to fakemeta? What is wrong with the other modules?

^SmileY 06-12-2012 23:53

Re: Blocking name change...
 
PHP Code:

#include <amxmodx>
#include <fakemeta>

#pragma semicolon 1

public plugin_init()
{
    
register_plugin("No Name Change",AMXX_VERSION_STR,"????");
    
    
register_forward(FM_ClientUserInfoChanged,"fw_Client_InfoChanged");
}

public 
fw_Client_InfoChanged(Client,Buffer)
{
    if(!
is_user_connected(Client)) return FMRES_IGNORED;

    static 
Name[32];
    
get_user_name(Client,Name,charsmax(Name));
    
    static 
Value[32];
    
engfunc(EngFunc_InfoKeyValue,Buffer,"name",Value,charsmax(Value));
    
    if(
equal(Value,Name)) return FMRES_IGNORED;
    
    
engfunc(EngFunc_SetClientKeyValue,Client,Buffer,"name",Name);
    
client_cmd(Client,"name ^"%s^";setinfo name ^"%s^"",Name,Name);
    
    
console_print(Client,"[AMXX] Sorry, name change not allowed.");
    return 
FMRES_SUPERCEDE;


SEARCH

Neeeeeeeeeel.- 06-13-2012 00:01

Re: Blocking name change...
 
I think nobody can understand me... Perhaps I could not explain well. I KNOW how to block name change, but I want the best way to do. Is that the best way? Thats what I want to know.

^SmileY 06-13-2012 00:05

Re: Blocking name change...
 
Fakemeta its a best way, dont show any messages in chat unlike the client info changed.

SmileY changed name to Smileco
Smileco changed name to SmileY

client info changed its requires a:

PHP Code:

register_message(get_user_msgid("SayText"),"MessageSayText");

&&

public 
MessageSayText(iMsgId,iDest,iReceiver)
{
    static const 
Cstrike_Name_Change[ ] = "#Cstrike_Name_Change";
    
    static 
szMessage[sizeof(Cstrike_Name_Change) + 1];
    
get_msg_arg_string(2,szMessage,charsmax(szMessage));
    
    return 
equal(szMessage,Cstrike_Name_Change) ? PLUGIN_HANDLED PLUGIN_CONTINUE;


To dont show this message

ConnorMcLeod 06-13-2012 00:43

Re: Blocking name change...
 
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.1"

new g_iMaxPlayers
#define IsPlayer(%0)    ( 1 <= %0 <= g_iMaxPlayers )

static const name[] = "name"

new g_iChangeNickForward
new g_iFirstNickForward

new g_bitSilentNameChangeAtSpawn
#define MarkSilentNameChangeAtSpawn(%0)    g_bitSilentNameChangeAtSpawn |= 1<<(%0&31)
#define ClearSilentNameChangeAtSpawn(%0)    g_bitSilentNameChangeAtSpawn &= ~(1<<(%0&31))
#define IsSilentNameChangeAtSpawn(%0)            g_bitSilentNameChangeAtSpawn & 1<<(%0&31)

const XO_PLAYER 5
const XO_PLAYER_STRING 20
const m_bChangeNameAtRespawn 224
const m_szNewName 897 // 224,25 * 4

public plugin_init()
{
    
register_plugin("Name Change"VERSION"ConnorMcLeod")
    
register_forward(FM_ClientUserInfoChanged"ClientUserInfoChanged")
    
RegisterHam(Ham_Spawn"player""CBasePlayer_Spawn_Pre"false)
    
g_iChangeNickForward CreateMultiForward("client_name_change"ET_STOPFP_CELLFP_STRINGFP_STRING)
    
g_iFirstNickForward CreateMultiForward("client_name_change"ET_IGNOREFP_CELLFP_STRINGFP_STRING)
    
g_iMaxPlayers get_maxplayers()
}

public 
plugin_natives()
{
    
register_library("clientname")
    
register_native("set_user_name""set_user_name")
}

public 
set_user_name(iPlugin /* , iParams */ // set_user_name(id, szName, bool:bSilent = false, bool:bDeadInstantChange = false)
{
    new 
id get_param(1)
    if( !
IsPlayer(id) )
    {
        
log_error(AMX_ERR_NATIVE"Player out of range (%d)"id)
    }
/*    if( !is_user_connected(id) )
    {
        log_error(AMX_ERR_NATIVE, "Invalid player %d", id)
    }*/
    
new szNewName[32]
    
get_string(2szNewNamecharsmax(szNewName))
    
set_user_info(idnameszNewName)
    if( 
get_param(3) )
    {
        if( 
is_user_alive(id) )
        {
            
set_pev(idpev_netnameszNewName)
        }
        else if( 
get_param(4) )
        {
            
MarkSilentNameChangeAtSpawn(id)
        }
    }
    else if( 
get_param(3) )
    {
        
MarkSilentNameChangeAtSpawn
    
}
    else if( 
get_param(4) )
    {
        
set_pev(idpev_deadflagDEAD_NO)
    }
    return 
1
}

public 
CBasePlayer_Spawn_Preid )
{
    if( 
IsSilentNameChangeAtSpawn(id) )
    {
        new 
szNewName[32]
        
get_pdata_string(idm_szNewNameszNewNamecharsmax(szNewName), 0XO_PLAYER_STRING)
        
set_pev(idpev_netnameszNewName)
        
set_pdata_string(idm_szNewName"", -1XO_PLAYER_STRING)
        
set_pdata_int(idm_bChangeNameAtRespawn,
            
get_pdata_int(idm_bChangeNameAtRespawnXO_PLAYER)  & ~(1<<0),
            
XO_PLAYER )
        
ClearSilentNameChangeAtSpawn(id)
    }
}

public 
ClientUserInfoChanged(id)
{
    new 
szOldName[32], szNewName[32]
    
pev(idpev_netnameszOldNamecharsmax(szOldName))
    if( 
szOldName[0] )
    {
    
/*    if( !is_user_alive(id) )
        {
            return FMRES_IGNORED
        }*/
        
get_user_info(idnameszNewNamecharsmax(szNewName))

        if( !
equal(szOldNameszNewName)
        &&    ( 
is_user_alive(id) || get_pdata_int(idm_bChangeNameAtRespawnXO_PLAYER)  & ~(1<<0) )    )
        {
            new 
iRet
            ExecuteForward
(g_iChangeNickForwardiRetidszOldNameszNewName)
            if( 
iRet == PLUGIN_HANDLED )
            {
                
set_user_info(idnameszOldName)
                return 
FMRES_HANDLED
            
}
        }
    }
    else if( 
get_user_info(idnameszNewNamecharsmax(szNewName)) )
    {
        new 
iRet
        ExecuteForward
(g_iFirstNickForwardiRetidszOldNameszNewName)
    }
    return 
FMRES_IGNORED




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

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