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

Solved client_infochanged Efficiency


Post New Thread Reply   
 
Thread Tools Display Modes
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 11-02-2019 , 17:06   Re: client_infochanged Efficiency
Reply With Quote #11

Quote:
Originally Posted by Natsheh View Post
3rd argument in unregister_forward should be removed it doesnt make any sense.
0 = pre, 1 = post it makes sense, just doesn't work properly.
__________________
edon1337 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-02-2019 , 17:06   Re: client_infochanged Efficiency
Reply With Quote #12

OciXCrom's suggestion worked for me, adding the 1 to the unregister_forward() makes it only fire once. I also made an efficiency fix.
  • Using register_event() on only 2=#Cstrike_Name_Change, instead of hooking all SayText messages and then checking the 2nd arg within the callback.
  • unregister_message() post fix
Code:
*TEST* Name changed to [bugsy]
* bugsy3 changed name to bugsy
*TEST* Name changed to [bugsy2]
* bugsy changed name to bugsy2
PHP Code:
#include <amxmodx>
#include <fakemeta>

new const Version[] = "0.2";

#define MAX_PLAYERS 32

new g_szNameMAX_PLAYERS ][ 32 ];
new 
g_iInfoChangedFwd;

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

public 
EventSayText()
{
    
g_iInfoChangedFwd register_forwardFM_ClientUserInfoChanged "ClientUserInfoChanged" );
}

public 
ClientUserInfoChangedid )
{
    if ( 
is_user_connectedid ) )
    {
        
get_user_nameid g_szNameid ] , charsmaxg_szName[] ) );
        
unregister_forwardFM_ClientUserInfoChanged g_iInfoChangedFwd );
        
client_printid print_chat "*TEST* Name changed to [%s]" g_szNameid ] );
    }

__________________

Last edited by Bugsy; 11-02-2019 at 17:07.
Bugsy is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 11-02-2019 , 17:18   Re: client_infochanged Efficiency
Reply With Quote #13

Quote:
Originally Posted by Bugsy View Post
OciXCrom's suggestion worked for me, adding the 1 to the unregister_forward() makes it only fire once. I also made an efficiency fix.
  • Using register_event() on only 2=#Cstrike_Name_Change, instead of hooking all SayText messages and then checking the 2nd arg within the callback.
  • unregister_message() post fix
Code:
*TEST* Name changed to [bugsy]
* bugsy3 changed name to bugsy
*TEST* Name changed to [bugsy2]
* bugsy changed name to bugsy2
PHP Code:
#include <amxmodx>
#include <fakemeta>

new const Version[] = "0.2";

#define MAX_PLAYERS 32

new g_szNameMAX_PLAYERS ][ 32 ];
new 
g_iInfoChangedFwd;

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

public 
EventSayText()
{
    
g_iInfoChangedFwd register_forwardFM_ClientUserInfoChanged "ClientUserInfoChanged" );
}

public 
ClientUserInfoChangedid )
{
    if ( 
is_user_connectedid ) )
    {
        
get_user_nameid g_szNameid ] , charsmaxg_szName[] ) );
        
unregister_forwardFM_ClientUserInfoChanged g_iInfoChangedFwd );
        
client_printid print_chat "*TEST* Name changed to [%s]" g_szNameid ] );
    }

When I set 1 on unregister_forward it doesn't work tested in local and public server.
__________________

Last edited by edon1337; 11-02-2019 at 17:18.
edon1337 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-02-2019 , 18:38   Re: client_infochanged Efficiency
Reply With Quote #14

You probably did something wrong. Can you post your code?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 11-03-2019 , 06:43   Re: client_infochanged Efficiency
Reply With Quote #15

Quote:
Originally Posted by OciXCrom View Post
You probably did something wrong. Can you post your code?
Sure, it's already public. https://forums.alliedmods.net/showthread.php?t=317151

Search for FM_ClientUserInfoChanged in EliteAdminSystem.sma and EliteAdminSystem_Commands.sma
__________________

Last edited by edon1337; 11-03-2019 at 06:44.
edon1337 is offline
Reply


Thread Tools
Display Modes

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 19:25.


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