Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions game/addons/sourcemod/scripting/sbpp_comms.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,9 +1380,15 @@ public void GotDatabase(Database db, const char[] error, any data)
}

// Set character set to UTF8MB4 in the database
char query[128];
Format(query, sizeof(query), "SET NAMES utf8mb4");
db.Query(Query_ErrorCheck, query);
// Use SQL_SetCharset to ensure charset is set synchronously before any operations
if (!db.SetCharset("utf8mb4"))
{
LogError("Failed to set database charset to utf8mb4");
// Fallback to async method
char query[128];
Format(query, sizeof(query), "SET NAMES utf8mb4");
db.Query(Query_ErrorCheck, query);
}

// Process queue
SQLiteDB.Query(Query_ProcessQueue,
Expand Down
11 changes: 9 additions & 2 deletions game/addons/sourcemod/scripting/sbpp_main.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,8 +1090,15 @@ public void GotDatabase(Database db, const char[] error, any data)

char query[1024];

Format(query, sizeof(query), "SET NAMES utf8mb4");
DB.Query(ErrorCheckCallback, query);
// Set character set to UTF8MB4 in the database
// Use SetCharset to ensure charset is set synchronously before any operations
if (!DB.SetCharset("utf8mb4"))
{
LogToFile(logFile, "Failed to set database charset to utf8mb4, trying async method");
// Fallback to async method
Format(query, sizeof(query), "SET NAMES utf8mb4");
DB.Query(ErrorCheckCallback, query);
}

InsertServerInfo();

Expand Down