Raised This Month: $32 Target: $400
 8% 

[L4D2] OnClientConnected send a message to a specific player (not who is joining)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spinning Turte
Junior Member
Join Date: May 2019
Old 05-19-2019 , 08:38   [L4D2] OnClientConnected send a message to a specific player (not who is joining)
Reply With Quote #1

I was trying to send me a message for every time a player (not bot obv) join the game, this code is "OnClientConnected(client)" but I don't know how to send this message only to me and if I'm in-game

PHP Code:
public OnClientConnected(client)
{
    if (!
IsFakeClient(client) && !IsClientInGame(client/*&& if I'm in-game*/)
        {
            
PrintToChat(/*I want to put here only my name, so I'll receive it only if I'm ingame*/,pMessages[10],256);
        }        
    }

Spinning Turte is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 05-19-2019 , 09:15   Re: [L4D2] OnClientConnected send a message to a specific player (not who is joining)
Reply With Quote #2

PHP Code:
public void OnClientConnected(int client)
{
    if( !
IsFakeClient(client) )
    {
        
char sTemp[64];
        for( 
int i 1<= MaxClientsi++ )
        {
            if( 
IsClientInGame(i) && IsClientAuthorized(i) )
            {
                
GetClientAuthId(iAuthId_SteamID64sTempsizeof(sTemp));
                if( 
strcmp(sTemp"7656119XXXXXXXXXX") == // Replace with your SteamID64
                
{
                    
PrintToChat(i"%N connected."client);
                    return;
                }
            }
        }        
    }

__________________
Silvers is offline
Spinning Turte
Junior Member
Join Date: May 2019
Old 05-19-2019 , 09:57   Re: [L4D2] OnClientConnected send a message to a specific player (not who is joining)
Reply With Quote #3

Quote:
Originally Posted by Silvers View Post
PHP Code:
public void OnClientConnected(int client)
{
    if( !
IsFakeClient(client) )
    {
        
char sTemp[64];
        for( 
int i 1<= MaxClientsi++ )
        {
            if( 
IsClientInGame(i) && IsClientAuthorized(i) )
            {
                
GetClientAuthId(iAuthId_SteamID64sTempsizeof(sTemp));
                if( 
strcmp(sTemp"7656119XXXXXXXXXX") == // Replace with your SteamID64
                
{
                    
PrintToChat(i"%N connected."client);
                    return;
                }
            }
        }        
    }

It works! Thanks
Spinning Turte 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 19:08.


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