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

Client Name Randomly being returned as blank


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 09-27-2016 , 16:08   Client Name Randomly being returned as blank
Reply With Quote #1

EDIT: This is happening on Half-Life 2: Deathmatch; I cannot verify if it is happening on other Source-based games...

SourceMod Gurus, please help! My plugin I am working on is basically a chat filter functionality, etc. I am having a very strange "bug" I am trying to sort out with the client name not being returned at random.

Here is the weird part, sometimes it happens, sometimes it does not. No consistency to debug it. This is what happens:

1. Map starts
2. When I type in chat, it returns normally, sometimes the whole round...BUT
3. ...Suddenly, sometimes nothing is returned BUT the chat message and NO name so it would come out like this:

Quote:
WORKING OK-

John : Hello, how are you?

WHEN THE "BUG" HAPPENS

: Hello, how are you?
I. am. stumped. Is there any other way to get a clients name? I have also tried this, same result when it happens:

Format(sClientName, sizeof(sClientName), "%N", client);

Here is the code
PHP Code:
public OnPluginStart()
{
    
RegConsoleCmd("say"SayHandler);
}

public 
Action OnClientSayCommand(int client, const char[] command, const char[] args)
{
    new 
String:sClientName[MAX_NAME_LENGTH];
    new 
String:sMessage[255];
    
Format(sClientNamesizeof(sClientName), "%N"client);
    
Format(sMessagesizeof(sMessage), "%s"args);

    if(
IsClientInGame(client))
    {
        if(
StrEqual(command"say"))
        {
            if (
StrEqual(sClientName""false)) { return Plugin_Handled; } // If no name "bug" happens return nothing instead of the chat only
            
PrintToChatAll("%s : %s"sClientNamesMessage);
            
// ^^^ When error happens, the 'sClientName' is blank and returns NOTHING even though the 'client' index IS returned
            // also, the 'sMessage' is always returned as expected regardless, no errors.
            
return Plugin_Handled;
        }
    }
    return 
Plugin_Continue;


Last edited by scorpius2k1; 09-29-2016 at 14:06.
scorpius2k1 is offline
ColdMeekly
Junior Member
Join Date: Sep 2016
Old 09-27-2016 , 17:12   Re: Client Name Randomly being returned as blank
Reply With Quote #2

Instead of completely replacing an existing say command in console, try using the AddCommandListener function. Once you've done that, test and reply back on what the results are.
ColdMeekly is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 09-27-2016 , 17:16   Re: Client Name Randomly being returned as blank
Reply With Quote #3

Quote:
Originally Posted by ColdMeekly View Post
Instead of completely replacing an existing say command in console, try using the AddCommandListener function. Once you've done that, test and reply back on what the results are.
Thank you for your help...I must apologize for not mentioning on my original post, will fix. I actually have tried that functionality. This was commented out in my code from previous; still resulting with the same issue.

PHP Code:
AddCommandListener(SayHandler"say"); 
scorpius2k1 is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 09-27-2016 , 17:23   Re: Client Name Randomly being returned as blank
Reply With Quote #4

PHP Code:
public Action OnClientSayCommand(int client, const char[] command, const char[] args)
{
    if(
IsClientInGame(client))
    {
        if(
StrEqual(command"say"))
        {
            
PrintToChatAll("%N : %s"clientargs);
            return 
Plugin_Handled;
        }
    }

    return 
Plugin_Continue;


Last edited by Michael Shoe Maker; 09-27-2016 at 17:24.
Michael Shoe Maker is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 09-27-2016 , 18:38   Re: Client Name Randomly being returned as blank
Reply With Quote #5

Quote:
Originally Posted by Michael Shoe Maker View Post
PHP Code:
public Action OnClientSayCommand(int client, const char[] command, const char[] args)
{
    if(
IsClientInGame(client))
    {
        if(
StrEqual(command"say"))
        {
            
PrintToChatAll("%N : %s"clientargs);
            return 
Plugin_Handled;
        }
    }

    return 
Plugin_Continue;

+1 for OnClientSayCommand
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 09-28-2016 , 13:14   Re: Client Name Randomly being returned as blank
Reply With Quote #6

THANK YOU all, never cease to amaze! Seems to be working well so far last night & today, I will report back if any further issues. +1,000,000 rep. Thanks again!
scorpius2k1 is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 09-29-2016 , 12:58   Re: Client Name Randomly being returned as blank
Reply With Quote #7

Well everyone, looks like I spoke to soon...it's still happening. New map started, I typed in one sentence and it came back normal, then .... nothing would go through. The plugin was even reloaded a few times just to be sure. Strangely enough, if I simply rejoin the server, it all works fine again. This is really weird, and again, it's just the name not being returned, the chat part always is. I have my plugin setup if there is no name or it == "" then return Plugin_Handled (for debugging)...so that is how I know it's only the name part.

Any other ideas? This is driving me crazy.
scorpius2k1 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 09-29-2016 , 13:10   Re: Client Name Randomly being returned as blank
Reply With Quote #8

What is your code for printing, since others have posted their code I'm not sure what changes you made to the original post.
Also what sourcemod version are you using?
Mitchell is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 09-29-2016 , 13:26   Re: Client Name Randomly being returned as blank
Reply With Quote #9

Quote:
Originally Posted by Mitchell View Post
What is your code for printing, since others have posted their code I'm not sure what changes you made to the original post.
Also what sourcemod version are you using?
My apologies, original post source code updated.
scorpius2k1 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 09-29-2016 , 13:29   Re: Client Name Randomly being returned as blank
Reply With Quote #10

Quote:
Originally Posted by scorpius2k1 View Post
My apologies, original post source code updated.
You left out your SM version, you should post it, it could be the issue also.
And also you should atleast use OnClientSayCommand
Mitchell 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 23:06.


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