Spoiler
Hello everyone,
I'm experiencing an issue with Node.js script that interacts with my CS2D server. The script is designed to retrieve and display server information, including the number of bots currently present on the server. However, the bot count value being displayed is incorrect.
Here’s a brief overview of the problem:
Context:
I have a Node.js script that uses the dgram module to query CS2D servers for their status. The data is processed using a custom streams class to handle the buffer data. The server data is updated periodically, and the updated information is posted to a Discord channel using discord.js.
Issue:
The bots field in the server data is always being reported as false, even though there are bots present on the server. This indicates that the script might not be correctly reading or interpreting the number of bots from the server response.
Code Snippet:
Debug Information:
I’ve added debugging logs to print out the Server Info but still see that bots is not correctly updated. I suspect that the issue might be in how the bots value is read or how the flag is being interpreted.
Questions:
Has anyone encountered a similar issue with CS2D server data handling?
Are there any known issues with the way bot data is sent or interpreted in CS2D?
Could there be any mistakes in how I’m processing the flags or reading the data?
Any help or insights on how to resolve this issue would be greatly appreciated!
Thank you in advance.
I'm experiencing an issue with Node.js script that interacts with my CS2D server. The script is designed to retrieve and display server information, including the number of bots currently present on the server. However, the bot count value being displayed is incorrect.
Here’s a brief overview of the problem:
Context:
I have a Node.js script that uses the dgram module to query CS2D servers for their status. The data is processed using a custom streams class to handle the buffer data. The server data is updated periodically, and the updated information is posted to a Discord channel using discord.js.
Issue:
The bots field in the server data is always being reported as false, even though there are bots present on the server. This indicates that the script might not be correctly reading or interpreting the number of bots from the server response.
Code Snippet:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function serverInfo(stream) { const res = {} let flags = stream.readByte() res.password = readFlag(flags, 0) res.usgnonly = readFlag(flags, 1) res.fow = readFlag(flags, 2) res.friendlyfire = readFlag(flags, 3) res.bots = readFlag(flags, 5) res.lua = readFlag(flags, 6) res.forcelight = readFlag(flags, 7) res.name = stream.readString(stream.readByte()) res.map = stream.readString(stream.readByte()) res.players = stream.readByte() res.maxplayers = stream.readByte() res.gamemode = stream.readByte() if (res.bots) res.bots = stream.readByte() flags = stream.readByte() res.recoil = readFlag(flags, 0) res.offscreendamage = readFlag(flags, 1) res.hasdownloads = readFlag(flags, 2) return res }
Debug Information:
I’ve added debugging logs to print out the Server Info but still see that bots is not correctly updated. I suspect that the issue might be in how the bots value is read or how the flag is being interpreted.
Questions:
Has anyone encountered a similar issue with CS2D server data handling?
Are there any known issues with the way bot data is sent or interpreted in CS2D?
Could there be any mistakes in how I’m processing the flags or reading the data?
Any help or insights on how to resolve this issue would be greatly appreciated!
Thank you in advance.
Nvm, the res.gamemode was actually showing the number of bots. I just renamed it to res.bots. Was there not supposed to be a flag for gamemodes?
edited 4×, last 23.07.24 06:36:59 pm