简体   繁体   English

我需要如何定义用户? 参考错误:用户未定义 Steam 用户

[英]How do i need define the user? ReferenceError: user is not defined Steam user

when im starting my script, this error shows up:当我开始我的脚本时,这个错误出现了:

 /var/www/html/bot/driver.js:309 if(users[user.steamid]) ^ ReferenceError: user is not defined at Namespace.<anonymous> (/var/www/html/bot/driver.js:309:14) at emitOne (events.js:116:13) at Namespace.emit (events.js:211:7) at Namespace.emit (/var/www/html/bot/node_modules/socket.io/lib/namespace.js:213:10) at /var/www/html/bot/node_modules/socket.io/lib/namespace.js:181:14 at _combinedTickCallback (internal/process/next_tick.js:132:7) at process._tickCallback (internal/process/next_tick.js:181:9)

Can someone explain this to me?谁可以给我解释一下这个? How do i need to define the steam user?我需要如何定义 Steam 用户? The part in the script where it crashes looks so:脚本中崩溃的部分看起来是这样的:

 io.sockets.on('connection', function(socket) { var index = -1; if(users[user.steamid]) index = users[user.steamid]['socket'].indexOf(socket.id); if (index > -1) { users[user.steamid]['socket'].splice(index, 1); } if(users[user.steamid]) { if(Object.keys(users[user.steamid]['socket']).length == 0) delete users[user.steamid]; } });

Before in the console, it asks me for the Steam Guard Code, but then it immediately crashes to that error.在控制台之前,它要求我提供 Steam 令牌代码,但随后它立即崩溃到该错误。

You need to actually tell the system what user is, it has no idea what it is because you haven't defined it anywhere and it doesn't have any reference or source from where it originated.您需要实际告诉系统user是什么,它不知道它是什么,因为您没有在任何地方定义它,并且它没有任何参考或来源。

If you do something like:如果您执行以下操作:

const user = 'something';

It will at least be defined, but that's just about as useless as not defining it because you're obviously missing some logic from a library or something along those lines because user should be defined.它至少会被定义,但这与不定义它一样无用,因为你显然缺少库中的一些逻辑或类似的东西,因为user应该被定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM