So, I need to be able to retreive the name of a player who may be offline via steamID64. I know there is a method BasePlayer.FindAwakeOrSleeping but I assume it returns a player who is awake/sleeping but alive. I'm not really into Rust so I asked and was told that after a sleeping player dies, the player is not ressurected until next time they join the server. If this information is incorrect, then point it out and my question ends here.
However, if not, the question is how to do it. I have one idea - use steam to get username. One can use link "https://steamcommunity.com/profiles/*steamID64*/?xml=1". I tried this approach. The problem is that webrequest returns control immediately. So, this function returns "failed" before the value is overwritten:
However, if not, the question is how to do it. I have one idea - use steam to get username. One can use link "https://steamcommunity.com/profiles/*steamID64*/?xml=1". I tried this approach. The problem is that webrequest returns control immediately. So, this function returns "failed" before the value is overwritten:
private void GetUserNameBySteamID(ulong steamID, out string username)
{
string usrnm = "failed";
webrequest.Enqueue($"https://steamcommunity.com/profiles/{steamID}/?xml=1", null, (code, response) =>
{
usrnm = "Failed";
int pos;
if ((pos = response.IndexOf("<steamID>")) != -1)
{
if ((pos = response.IndexOf("CDATA", pos)) != -1) pos += "CDATA[".Length;
else return;
}
else return;
usrnm = response.Substring(pos, response.IndexOf("]", pos) - pos);
}, this);
username = usrnm;
}Is there any other way of getting player name in the given scenario? If not, is there any way to wait until webrequest is completed?