Raised This Month: $51 Target: $400
 12% 

Auto Name


Post New Thread Reply   
 
Thread Tools Display Modes
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 03-14-2024 , 16:26   Re: Auto Name
Reply With Quote #11

@Bugsy if the change name message is blocked, will the code still be triggered?
Also, wouldn't it be more effective just having a variable set to true/false for when not to ignore the forward instead of registering and unregistering it constantly?
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
WATCH_D0GS UNITED
Senior Member
Join Date: Jan 2023
Old 03-14-2024 , 18:44   Re: Auto Name
Reply With Quote #12

@DJEarthQuake

public client_infochanged( id )

called 2 times on client connect.
called 5 times when changing team.
// and some more cases.

-> unstoppable



FM_ClientUserInfoChanged

called when changing player name.
called 1 time when changing team.
// and some more cases.

-> can be unregistered



@georgik57

If the "2=#Cstrike_Name_Change" occurs it is always a player changing his name.

But it is global "a", so you will not be able to catch the player id there. You could use a loop although.
So Bugsy proceeds on FM_ClientUserInfoChanged, where the player id can be catched a bit after.

By unregistering the forward you eliminate unnecessary "if" checks when the function is called, in this case when the player changes its team or something else.
__________________
💻Know Our New Blog👄
🔗tube2downs.blogspot.com

Last edited by WATCH_D0GS UNITED; 03-14-2024 at 18:48.
WATCH_D0GS UNITED is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 03-14-2024 , 21:04   Re: Auto Name
Reply With Quote #13

Code:
/*How to legally force name change across servers.*/ #include amxmodx static stock_name[] = "player"; public plugin_init() {     register_plugin("Stock name block", "1.0", ".sρiηX҉.") }     public client_connectex(id, const name[], const ip[], reason[128]) {     reason = "Please change name from 'player' to something more unique. Thank you."     if(equal(name, stock_name))             return PLUGIN_HANDLED_MAIN;     return PLUGIN_CONTINUE; }
__________________
DJEarthQuake is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 03-15-2024 , 06:02   Re: Auto Name
Reply With Quote #14

Quote:
Originally Posted by WATCH_D0GS UNITED View Post
@georgik57

If the "2=#Cstrike_Name_Change" occurs it is always a player changing his name.

But it is global "a", so you will not be able to catch the player id there. You could use a loop although.
So Bugsy proceeds on FM_ClientUserInfoChanged, where the player id can be catched a bit after.

By unregistering the forward you eliminate unnecessary "if" checks when the function is called, in this case when the player changes its team or something else.
I meant like this. 2 less native calls.
PHP Code:
#include <amxmodx>
#include <fakemeta>

new const Version[] = "0.2";

#define MAX_PLAYERS 32

new const DefaultNames[][] = 
{
    
"Player",
    
"Sizzle Chest",
    
"Frank Rizzo",
    
"Sol Rosenberg",
    
"Mike Derucki"
};

new 
g_szNameMAX_PLAYERS ][ 32 ];
new 
g_bCheckName;

public 
plugin_init() 
{
    
register_plugin"Name Change Hook" Version "bugsy" );
    
    
register_event"SayText" "EventSayText" "a" "2=#Cstrike_Name_Change" );
    
    
register_forwardFM_ClientUserInfoChanged "ClientUserInfoChanged" );
}

public 
EventSayText()
{
    
g_bCheckName 1;
}

public 
ClientUserInfoChangedid )
{
    if ( !
g_bCheckName )
        return;
    
    
g_bCheckName 0;
    
    if ( !
is_user_connectedid ) )
        return;
    
    
get_user_nameid g_szNameid ] , charsmaxg_szName[] ) );
    
    for ( new 
sizeof DefaultNames ) ; i++ )
    {
        if ( 
equalig_szNameid ] , DefaultNames] ) )
        {
            
//set name
        
}
    }

__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 03-15-2024 , 07:00   Re: Auto Name
Reply With Quote #15

This has already gone into an oblivion. Who changes their name to 'player' after joining? Client_infochanged catching team changes, big whoop. Running as designed. It runs all the time if we tap into it or not like many other forwards. It's more useful to make script work on all mods especially when less code is required. Name changing is slow-hacking.
__________________
DJEarthQuake is offline
tedaimlocks
Member
Join Date: Jan 2024
Old 03-15-2024 , 12:28   Re: Auto Name
Reply With Quote #16

Dunno what you guys arguing about here, but may i get a final code?
tedaimlocks is offline
WATCH_D0GS UNITED
Senior Member
Join Date: Jan 2023
Old 03-15-2024 , 17:58   Re: Auto Name
Reply With Quote #17

Please download the script, open it, and add the names you want to detect and override.

// Names you want to replace.

PHP Code:
 new const DefaultNames[][] = 
{
    
"Player",
    ...,


// Names you will use to override.

PHP Code:
 new const N_Override[][] = 
{
    
"Captain John Price",
    ...,

Attached Files
File Type: sma Get Plugin or Get Source (generic_name_changer.sma - 31 views - 2.4 KB)
__________________
💻Know Our New Blog👄
🔗tube2downs.blogspot.com
WATCH_D0GS UNITED is offline
tedaimlocks
Member
Join Date: Jan 2024
Old 03-16-2024 , 05:52   Re: Auto Name
Reply With Quote #18

Tried it, it doesnt change my name on connect, only when i change my name while in-game
tedaimlocks is offline
WATCH_D0GS UNITED
Senior Member
Join Date: Jan 2023
Old 03-16-2024 , 08:27   Re: Auto Name
Reply With Quote #19

Tested in AMXX v1.8.2 and 1.10 and it works as intended.

It works well in both CS and CZ.

Please test without using any other plugins.
__________________
💻Know Our New Blog👄
🔗tube2downs.blogspot.com

Last edited by WATCH_D0GS UNITED; 03-16-2024 at 08:41.
WATCH_D0GS UNITED is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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