sourcemod
sourcemod copied to clipboard
Player GetName regression from #1544
#1544 has integrated a regression
Names set with SetInfo are now not returned properly.
So we have a display name = B (in scoreboard, chat etc ... with SetInfo and when we do GetClientName we have a name A
An example:
new String:name[64];
GetClientName(client, name, 64);
PrintToServer("Name \"%s\" on #%d", name, client);
SetClientName(client, "TestA");
GetClientName(client, name, 64);
PrintToServer("Name \"%s\" on #%d", name, client);
SetClientInfo(client, "name", "TestB");
PrintToServer("Name \"%s\" on #%d", name, client);
GetClientName(client, name, 64);
PrintToServer("Name \"%s\" on #%d", name, client);
Traces:
Name "BOT Alfred" on #4
Name "BOT Alfred" on #4
Name "BOT Alfred" on #4
Name "BOT Alfred" on #4
Status from console and scoreboard/chats
# userid name uniqueid connected ping loss state adr
# 6920 "TestB" BOT active
TestB is displayed everywhere but when we use GetClientName(), it return "BOT Alfred"
Please fill in the details that were requested in the issue template - we need reproduction instructions at the very least.
Please fill in the details that were requested in the issue template - we need reproduction instructions at the very least.
Completed
What game is this with?
What game is this with?
CSS, but regression is present on others games like TF2, DODS etc
Does this happen for human players as well, or only bots?
It looks like the cached names for bots never get updated because the PlayerManager hook on ClientSettingsChanged has an early out for them.
On humans:
Name "Not Powered TM" on #1
Name "TestA" on #1
Name "TestA" on #1
Name "TestA" on #1
# userid name uniqueid connected ping loss state adr
# 3256 "TestB" [U:1:1015169336] 06:58 65 0 active 161.230.250.136:27005
Humans have problems too when name is setted by info (ie return name from GetClientName = TestA instead of TestB)
Maybe name change is asynchronous. https://github.com/lua9520/source-engine-2018-hl2_src/blob/3bf9df6b2785fa6d951086978a3e66f49427166a/engine/baseclient.cpp#L1443
Name change have delay. Can't get new name after setname in same code sequence.
#include <sdktools>
static const char names[][] = {
"TestA",
"TestB",
"TestC",
"TestD",
};
public void OnPluginStart()
{
RegConsoleCmd("sm_test", test);
}
public Action test(int client, int args)
{
PrintToServer("Name %N %i", client, client);
SetClientName(client, names[0]);
RequestFrame (nextframe, client);
return Plugin_Handled;
}
public void nextframe(int client)
{
static int counter = 0;
PrintToServer("Name %N %i", client, client);
if(counter >= 3)
{
counter = 0;
return;
}
counter++;
SetClientName(client, names[counter]);
RequestFrame (nextframe, client);
}
console
Name 'Bacardi 14
Name TestA 14
Name TestB 14
Name TestC 14
Name TestD 14
status
hostname: Do not come here.
version : 6630498/24 6630498 insecure
udp/ip : 192.168.1.20:27015 (public ip: puff!)
steamid : [A:1:1823713289:18727] (90152426223675401)
map : de_dust2 at: 0 x, 0 y, 0 z
tags :
sourcetv: port 27020, delay 30.0s
players : 1 humans, 1 bots (33 max)
edicts : 263 used of 2048 max
# userid name uniqueid connected ping loss state adr
# 2 "SourceTV" BOT active
# 15 "TestD" [U:1:28327177] 09:18 22 0 active 192.168.1.20:27006
I think there are two separate problems here, which is causing some confusion.
- Cached bot names do not get updated as I mentioned above. This needs to be fixed regardless. It can cause the mismatch between scoreboard/status and GetClientName.
- Player name changes on the engine version mentioned do have a cooldown. SetClientName bypasses the cooldown, but SetClientInfo (with "name") does not). If a name change is requested by the player or with SetClientInfo, there can be a delay before it takes effect (and that delay would be shared with scoreboard/status and GetClientName's return).
I was not able to reproduce the issue with humans, using only SetClientName.
Is this issue reproducible with humans or bots, using only SetClientName for changing name (not SetClientInfo), on SM 1.11.6788 or later?