diff --git a/scripting/include/rtler.inc b/scripting/include/rtler.inc new file mode 100644 index 00000000..6fa2bdb7 --- /dev/null +++ b/scripting/include/rtler.inc @@ -0,0 +1,35 @@ +// code by alongub https://github.com/alongubkin/ + +#if defined _rtler_included + #endinput +#endif +#define _rtler_included + +#pragma semicolon 1 + +/** + * Converts a string that contains words in RTL languages to be displayed correctly in-game. + * + * @param dest Destination string buffer to copy the RTL-ed string to. + * @param destLen Destination buffer length (includes null terminator). + * @param original Original non-rtled string. + * + * @return The amount of words that needed RTLifying. + */ +native int RTLify(char[] dest, int destLen, const char[] original); + +public SharedPlugin __pl_rtler = +{ + name = "rtler", + file = "rtler.smx", +#if defined REQUIRE_PLUGIN + required = 1, +#else + required = 0, +#endif +}; + +public void __pl_rtler_SetNTVOptional() +{ + MarkNativeAsOptional("RTLify"); +} diff --git a/scripting/shavit-chat.sp b/scripting/shavit-chat.sp index 0220b48c..5bc9efed 100644 --- a/scripting/shavit-chat.sp +++ b/scripting/shavit-chat.sp @@ -26,11 +26,18 @@ #undef REQUIRE_PLUGIN #define USES_CHAT_COLORS #include +#include + +#pragma newdecls required +#pragma semicolon 1 // database Database gH_SQL = null; char gS_MySQLPrefix[32]; +// modules +bool gB_RTLer = false; + // cache EngineVersion gEV_Type = Engine_Unknown; @@ -51,6 +58,11 @@ public Plugin myinfo = url = "https://github.com/shavitush/bhoptimer" } +public void OnAllPluginsLoaded() +{ + gB_RTLer = LibraryExists("rtler"); +} + public void OnPluginStart() { gEV_Type = GetEngineVersion(); @@ -131,6 +143,22 @@ void SQL_SetPrefix() delete fFile; } +public void OnLibraryAdded(const char[] name) +{ + if(StrEqual(name, "rtler")) + { + gB_RTLer = true; + } +} + +public void OnLibraryRemoved(const char[] name) +{ + if(StrEqual(name, "rtler")) + { + gB_RTLer = false; + } +} + public void OnClientDisconnect(int client) { gB_AllowCustom[client] = false; @@ -294,7 +322,7 @@ public Action Command_CCList(int client, int args) { if(gB_AllowCustom[i]) { - PrintToConsole(client, "%N (%d/%d) (name: \"%s\"; message: \"%s\")", i, i, GetClientUserId(i), gS_CustomName[i], gS_CustomMessage[i]) + PrintToConsole(client, "%N (%d/%d) (name: \"%s\"; message: \"%s\")", i, i, GetClientUserId(i), gS_CustomName[i], gS_CustomMessage[i]); } } @@ -325,7 +353,19 @@ public Action CP_OnChatMessage(int &author, ArrayList recipients, char[] flagstr if(gB_MessageEnabled[author] && strlen(gS_CustomMessage[author]) > 0) { - Format(message, MAXLENGTH_MESSAGE, "%s%s", gS_CustomMessage[author], message); + char[] sTemp = new char[MAXLENGTH_MESSAGE]; + + // proper colors with rtler + if(gB_RTLer && RTLify(sTemp, MAXLENGTH_MESSAGE, message)) + { + Format(message, MAXLENGTH_MESSAGE, "%s%s", message, gS_CustomMessage[author]); + } + + else + { + Format(message, MAXLENGTH_MESSAGE, "%s%s", gS_CustomMessage[author], message); + } + FormatRandom(message, MAXLENGTH_MESSAGE); } diff --git a/scripting/shavit-core.sp b/scripting/shavit-core.sp index c8327fed..5966fdaf 100644 --- a/scripting/shavit-core.sp +++ b/scripting/shavit-core.sp @@ -1346,7 +1346,6 @@ public void OnClientPutInServer(int client) gB_Auto[client] = true; gB_DoubleSteps[client] = false; gF_StrafeWarning[client] = 0.0; - gBS_Style[client] = 0; gB_PracticeMode[client] = false; gI_SHSW_FirstCombination[client] = -1; gI_Track[client] = 0; @@ -1358,13 +1357,13 @@ public void OnClientPutInServer(int client) else { - gBS_Style[client] = 0; - UpdateAutoBhop(client); UpdateAiraccelerate(client); UpdateBunnyhopping(client); } + gBS_Style[client] = 0; + if(gH_SQL == null) { return;