openmultiplayer / open.mp

Open Multiplayer, a multiplayer mod fully backwards compatible with SA-MP
https://open.mp
Mozilla Public License 2.0
453 stars 92 forks source link

non-english nickname #888

Open iLuXing opened 6 months ago

iLuXing commented 6 months ago

When a player enters the game with a non-English nickname, the server will not receive or display any information.

Previously, a Chinese programmer created a plugin for nicknames with Chinese characters. This plugin located the address of the CheckPlayerName function through a characteristic code search and then hooked and managed it. Through this hooking process, the plugin fixed the crash issue caused by the incorrect use of CharLowerA in samp_server.exe.

However, with the updates to the game version, the plugin has become incompatible and can no longer be used. I believe this issue has been a headache for many servers and players, and I hope omp can address and fix this problem.

There are indeed experts who have developed Advanced-SA-NickName (https://github.com/KrYpToDeN/Advanced-SA-NickName), but it is not compatible with omp-server. Furthermore, based on my cursory examination of the code, it seems to be tailored specifically for Cyrillic script.

Thanks for your dedication and efforts.

NexiusTailer commented 6 months ago

Try using AllowNickNameCharacter native.

iLuXing commented 6 months ago

Try using AllowNickNameCharacter native.

This is invalid because when players use Chinese names to connect to the server, the terminal does not indicate that there are players connecting. Furthermore, UTF-8 encodes 27,484 Chinese characters, and I cannot use the function you mentioned to achieve this.

thanks.

NexiusTailer commented 6 months ago

So, what exact solution done in this Chinese plugin, like, what exactly it modified inside CheckPlayerName to solve the issue? Maybe there is sense to share it, so, other people can help you with porting it or advise some alternative ways similar to the algorithm used in that plugin.

Also a question just of curiosity: does Advanced-SA-NickName plugin fit your needs in general (it solves your problem under samp server) and just have some extra code for Cyrillic you may consider unneded, or it still cannot handle Chinese characters and should be modified to work with them properly? I know this plugin is pretty popular among ru crmp servers so I asking this in favour of that it also can be improved for your case and be more useful for Chinese server owners as well, even though it is currently only available for samp server and not adapted (but may be in future).

iLuXing commented 6 months ago

NPatcher.zip http://www.gtaun.com/viewthread.php?tid=682&extra=page%3D5

I only have the .dll file of this plugin, which was released in 2011. According to the description, this .dll file fixes the crash issue caused by the incorrect use of CharLowerA in samp_server.exe. I don't have much knowledge about C++ and Windows programs, so I guess it might be that server.exe cannot receive double-byte characters.

thanks for replying.

NexiusTailer commented 6 months ago

Thank you for sharing. Seems the main problem is really just in two-byte characters, so the author also suggest hooking and rewriting strlen, strcmp and strfind to work with such strings contain Chinese nicknames. Now I'm curious is it possible to bring support for non-ANSI encodings for string functions out-of-the-box in omp server, apart from allowing such nicknames too.

iLuXing commented 6 months ago

Thank you for sharing. Seems the main problem is really just in two-byte characters, so the author also suggest hooking and rewriting strlen, strcmp and strfind to work with such strings contain Chinese nicknames. Now I'm curious is it possible to bring support for non-ANSI encodings at least for string functions out-of-the-box in omp server, apart from allowing such nicknames too.

sorry, my programming ability is as bad as my English. I look forward to you and the big shots of omp trying to solve this problem. Thank you.

dockfries commented 5 months ago

I think AllowNickNameCharacter is valid as long as it internally judges characters in decimal bytes.

Even if a multi-byte character, such as a Chinese character, may be represented by three decimal numbers as a Chinese character in utf8, then I simply let each bit of 0-255 as a valid character.

At least that's how I implemented it in my own library with samp-node. That is, the loop is allowed when OnGameModeInit

    for (let i = 0; i <= 255; i++) {
      if (!isNickNameCharacterAllowed(i))
        allowNickNameCharacter(i, true);
    }

As long as his underlying principle is to determine the character of each index, It is equivalent to supporting all encodings of full characters, because the description of a character in different charset always lies in the parsing of 1 or more of 0-255 as a character

Simply doing so allows the player to connect to the server using a nickname with multi-byte characters.

It just means that there are still two issues that are :

  1. current terminal output of open.mp is still not supported, encounter this multi-character output will cut off the string.
  2. when a player connect with a multi-character nickname and not use allowNickNameCharacter, the server shows server closed message for player