我正在使用npm软件包Steam-user
我一直坚持从Steam ID获取Steam名称,我尝试过:
var name;
client.getPersonas([sid], function(personas) {
var persona = personas[sid];
name = persona ? persona.player_name : ("[" + sid + "]");
});
console.log(config.console_userMessageReceived + "(" + name + " | " + sid + "): " + message);
但是,在控制台中打印变量名时,其未定义形式打印。对如何解决此问题以及打印实际的蒸汽名称有帮助吗?
答案 0 :(得分:-1)
好像您有异步调用。试试这个:
var name;
client.getPersonas([sid], function(personas) {
var persona = personas[sid];
name = persona ? persona.player_name : ("[" + sid + "]");
console.log(config.console_userMessageReceived + "(" + name + " | " + sid + "): " + message);
});