Logs and settings
The returned result of command:
print(TheNet:IsWhiteListed(AllPlayers[1].userid))
[03:49:37]: RemoteCommandInput: "print(TheNet:IsWhiteListed(AllPlayers[1].userid))"
[03:49:37]: false
print(AllPlayers[1].userid)
[03:49:52]: RemoteCommandInput: "print(AllPlayers[1].userid)"
[03:49:52]: OU_76561199142772402
And here is my whitelist.txt file's content:
OU_76561199142772402
You can see that the line breaks is CRLF.
Analysis
Preface
I can correctly read the whitelist users under Linux operating system, a few days later, someone told me that when he using my mod on his server (OS: Win10), the whitelist user cannot be read correctly, then I debugging on his server use the 'TheNet:IsWhiteListed' API, the above problems occurred. Then I think this may be a bug caused by inconsistent line breaks.
Debugging
I changed the line breaks of his server's whitelist.txt file to LF (like in Linux, \n),The command `TheNet:IsWhiteListed("OU_76561199142772402")` returned true.
Repair suggestions
code
Code logic
- Replace all the '\r' to '\n' (The line breaks of MacOS seems to be '\r', so I will replace it with '\n' first)
- Replace all the '\n\n' to '\n' (Handle the '\r\n' line break in Windows OS, replace it to Linux OS's line breaks)
- Split the lines of the file contents with '\n' and save them in a table
BTW
Is there any other way to get whether a user is in the white list?
I can correctly read the whitelist users under Linux operating system, a few days later, someone told me that when he using my mod on his server (OS: Win10), the whitelist user cannot be read correctly, then I debugging on his server use the 'TheNet:IsWhiteListed' API, the above problems occurred.
- 1
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now