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(sClientName, sizeof(sClientName), "%N", client);
Format(sMessage, sizeof(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", sClientName, sMessage);
// ^^^ 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;
}