peace-maker / smrpg

A generic RPG plugin for SourceMod
88 stars 40 forks source link

[UTF-8] MYSQL issues #265

Closed Chevalier2016 closed 6 years ago

Chevalier2016 commented 6 years ago

[smrpg.smx] Error executing query 6 of 8 queries: Incorrect string value: '\xF0\x9F\x8C\xBA' for column 'name' at row 1

peace-maker commented 6 years ago

If I remember correctly, the mysqlclient library used in sourcemod's mysql dbi extension on windows is too old to support the utf8mb4 charset. The only thing I could do right now is stripping those invalid characters from the name? That sounds like a bad solution though.

utf8mb4 was introduced in mysql 5.5.3, sourcemod uses mysql 5.0.24a on windows. linux and mac are fine with newer library versions.

deven10100 commented 6 years ago

@Chevalier2016 I was able to solve this issue by adding this plugin, Yes it will force change the name of players with those characters so they will be unusable. I recommend it personally but as @peace-maker mentioned its a bad solution because you are restricting characters from players names.

https://forums.alliedmods.net/showthread.php?p=571978 (csgo & css works fine use version on page 5)

Chevalier2016 commented 6 years ago

@peace-maker We use linux only, so its not working great for newer libraries. I had this same issue with the KZTimer as well, was looking for a fix for this.

@deven10100 Thanks ill give it a try

peace-maker commented 6 years ago

You'll need to change the charset of the tables to utf8mb4 and set the right charset in the plugin too.

-- Change charset of all varchar columns to utf8mb4 to allow 4-byte multibyte characters (like emojis!)
ALTER TABLE players CONVERT TO CHARACTER SET utf8mb4;
ALTER TABLE upgrades CONVERT TO CHARACTER SET utf8mb4;
ALTER TABLE player_upgrades CONVERT TO CHARACTER SET utf8mb4;
ALTER TABLE settings CONVERT TO CHARACTER SET utf8mb4;

I'll prepare an update to smrpg to automatically do that for you.

@Chevalier2016 Looks like SM's buildbots use a different version than the checkout_deps script. Might be worth a shot though until SM is updated.

peace-maker commented 6 years ago

This should do the trick and Just Work™ once SM is compiled against a more recent mysql client library.

Chevalier2016 commented 6 years ago

Doesn't work til this day. Anyone else got this working?

peace-maker commented 6 years ago

This should be fixed with the latest sourcemod build as of yesterday. https://github.com/alliedmodders/sourcemod/pull/786

https://www.sourcemod.net/downloads.php?branch=master Build 1.10-6260+