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

The proper event to print information to client


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-17-2019 , 14:13   Re: The proper event to print information to client
Reply With Quote #11

Quote:
Originally Posted by edon1337 View Post
There, full code can be found here. Player gets kicked but the prints do go off.
PHP Code:
public client_authorizedid )
{
    
set_task0.3"client_authorized_delayed"id TASK_AUTHORIZED );
}

public 
client_authorized_delayedid )
{
    
id -= TASK_AUTHORIZED;

    
CheckBannedid );
}

public 
CheckBannedid )
{
    if( 
get_user_flagsid ) & g_iConfigIMMUNITY_FLAG ] )
    {
        return 
PLUGIN_HANDLED;
    }

    else
    {
        new 
eDataPlayerBan ], szSteamIdMAX_AUTHID_LENGTH ], szNameMAX_NAME_LENGTH ], szIPMAX_IP_LENGTH ];
        
get_user_authididszSteamIdcharsmaxszSteamId ) );
        
get_user_nameidszNamecharsmaxszName ) );
        
get_user_ipidszIPcharsmaxszIP ), );

        for( new 
iArraySizeg_aBans ); i++ )
        {
            
ArrayGetArrayg_aBansieData );
            
            if( 
equaliszSteamIdeDataPlayer_SteamId ] ) || equaliszNameeDataPlayer_Name ] ) || equaliszIPeDataPlayer_IP ] ) )
            {
                if( ! 
HasDatePassedeDataPlayer_BanExpire ] ) || equalieDataPlayer_BanExpire ], "never" ) )
                {
                    if( 
equalieDataPlayer_BanExpire ], "never" ) )
                    {                
                        
                        
send_messageidCONSOLEfalse"************************************************" );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_BANNED" );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_EXPIRE_NEVER" );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_REASON"eDataPlayer_BanReason ] );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_BY"eDataPlayer_BannedBy ] );
                        
send_messageidCONSOLEfalse"************************************************" );
                    }
                    
                    else
                    {
                        
send_messageidCONSOLEfalse"************************************************" );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_BANNED" );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_EXPIRE"eDataPlayer_BanExpire ] );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_REASON"eDataPlayer_BanReason ] );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_BY"eDataPlayer_BannedBy ] );
                        
send_messageidCONSOLEfalse"************************************************" );
                    }
                    
server_cmd"kick #%d %L"get_user_useridid ), id"CHECK_CONSOLE_INFO" );
                    break;
                }
            }
        }
    }
    return 
PLUGIN_CONTINUE;



There is no guarantee that a player is actually "in" the server when client_authorized() occurs. So, that means you can't guarantee that that text will make it to the player's console.

You'd probably need to use the method for customizing the kick message for them to see it or delay the kick until after client_putinserver().
__________________
fysiks is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-17-2019 , 14:13   Re: The proper event to print information to client
Reply With Quote #12

Quote:
Originally Posted by fysiks View Post
It does work but your probably just missing it visually (because you come into the server and have the MOTD, Team selection, and class selection menus to deal with). If you really want someone to see something, you have to do it when there is less likely to be something in the way or distracting.

So, it will depend on what your intention is for this message.
There's auto team join and MOTD blocker. Right now I'm using client_authorized + 0.3s delay, it doesn't appear in my console.

Here's logs to see that it actually gets called.
Code:
L 08/17/2019 - 20:12:50: #1 Called
L 08/17/2019 - 20:13:18: #2 Called
PHP Code:
public CheckBannedid )
{
    if( 
get_user_flagsid ) & g_iConfigIMMUNITY_FLAG ] )
    {
        return 
PLUGIN_HANDLED;
    }

    else
    {
        new 
eDataPlayerBan ], szSteamIdMAX_AUTHID_LENGTH ], szNameMAX_NAME_LENGTH ], szIPMAX_IP_LENGTH ];
        
get_user_authididszSteamIdcharsmaxszSteamId ) );
        
get_user_nameidszNamecharsmaxszName ) );
        
get_user_ipidszIPcharsmaxszIP ), );

        for( new 
iArraySizeg_aBans ); i++ )
        {
            
ArrayGetArrayg_aBansieData );
            
            if( 
equaliszSteamIdeDataPlayer_SteamId ] ) || equaliszNameeDataPlayer_Name ] ) || equaliszIPeDataPlayer_IP ] ) )
            {
                if( ! 
HasDatePassedeDataPlayer_BanExpire ] ) || equalieDataPlayer_BanExpire ], "never" ) )
                {
                    if( 
equalieDataPlayer_BanExpire ], "never" ) )
                    {                
                        
                        
send_messageidCONSOLEfalse"************************************************" );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_BANNED" );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_EXPIRE_NEVER" );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_REASON"eDataPlayer_BanReason ] );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_BY"eDataPlayer_BannedBy ] );
                        
send_messageidCONSOLEfalse"************************************************" );
                        
                        
log_to_file"AM.txt""#1 Called" );
                    }
                    
                    else
                    {
                        
send_messageidCONSOLEfalse"************************************************" );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_BANNED" );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_EXPIRE"eDataPlayer_BanExpire ] );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_REASON"eDataPlayer_BanReason ] );
                        
send_messageidCONSOLEfalse"%L"id"BAN_INFO_BY"eDataPlayer_BannedBy ] );
                        
send_messageidCONSOLEfalse"************************************************" );
                        
                        
log_to_file"AM.txt""#2 Called" );
                    }

                    
server_cmd"kick #%d %L"get_user_useridid ), id"CHECK_CONSOLE_INFO" );
                    break;
                }
            }
        }
    }
    return 
PLUGIN_CONTINUE;

__________________
edon1337 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-17-2019 , 14:15   Re: The proper event to print information to client
Reply With Quote #13

Quote:
Originally Posted by fysiks View Post
There is no guarantee that a player is actually "in" the server when client_authorized() occurs. So, that means you can't guarantee that that text will make it to the player's console.

You'd probably need to use the method for customizing the kick message for them to see it or delay the kick until after client_putinserver().
What about client_putinserver, that's a "guaranteed" event that player has joined, I'll test once more with a 3.0s delay.
__________________
edon1337 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-17-2019 , 14:18   Re: The proper event to print information to client
Reply With Quote #14

Quote:
Originally Posted by edon1337 View Post
What about client_putinserver, that's a "guaranteed" event that player has joined, I'll test once more with a 3.0s delay.
Yeah, but there is no guarantee that the client was authorized yet, IIRC. Which would mean you'd have to make sure that both events occur before executing this code.
__________________
fysiks is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-17-2019 , 14:22   Re: The proper event to print information to client
Reply With Quote #15

Quote:
Originally Posted by fysiks View Post
Yeah, but there is no guarantee that the client was authorized yet, IIRC. Which would mean you'd have to make sure that both events occur before executing this code.
Oh, I get it. I thought client_putinserver was always fired after client_authorized, turns out I was wrong. https://www.amxmodx.org/api/amxmodx/client_putinserver

So is there any other event which guarantees that the player is authorized?

EDIT: client_putinserver + 3.0s is working for now, I'll see how long it lasts.
__________________

Last edited by edon1337; 08-18-2019 at 06:49.
edon1337 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-17-2019 , 15:17   Re: The proper event to print information to client
Reply With Quote #16

Quote:
Originally Posted by edon1337 View Post
Oh, I get it. I thought client_putinserver was always fired after client_authorized, turns out I was wrong. https://www.amxmodx.org/api/amxmodx/client_putinserver

So is there any other event which guarantees that the player is authorized?

EDIT: client_authorized + 3.0s is working for now, I'll see how long it lasts.
You can easily use both:

PHP Code:
public client_connect(id)
{
    
g_bAuthorized[id] = false
    g_bInServer
[id] = false
}

public 
client_putinserver(id)
{
    
g_bInServer[id] = true
    
if( g_bAuthorized[id] )
    {
        
do_something(id)
    }
}

public 
client_authorized(id)
{
    
g_bAuthorized[id] = true
    
if( g_bInServer[id] )
    {
        
do_something(id)
    }

__________________
fysiks 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:39.


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