Hello everyone,
* I have an issue with the plugin "RTLer", and searched the whole web for some answers / available fixed plugin and found nothing.
me and a friend tried to do a few thing to make it work, but we didn't knew what is wrong with it.
we using the latest updated: SC & RTLer
Code:
#include <sourcemod>
#include <chat-processor>
//#include <rtler>
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_VERSION "1.2.5"
ConVar gCV_Flag = null;
ConVar gCV_Minimum = null;
float minimum = 0.1;
public Plugin myinfo =
{
name = "The RTLer",
author = "alongub",
description = "In-game chat support for RTL languages.",
version = PLUGIN_VERSION,
url = "http://steamcommunity.com/id/alon"
};
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
CreateNative("RTLify", Native_RTLify);
RegPluginLibrary("rtler");
return APLRes_Success;
}
public void OnPluginStart()
{
CreateConVar("rtler_version", PLUGIN_VERSION, "RTLer Version", FCVAR_SPONLY|FCVAR_DONTRECORD|FCVAR_NOTIFY);
gCV_Flag = CreateConVar("rtler_flag", "", "Restrict chat correction only for people who have this flag.");
gCV_Minimum = CreateConVar("rtler_minimum", "0.1", "Minimum percent of RTL letters for a word's direction to be considered right to left.", 0, true, 0.001, true, 1.0);
gCV_Minimum.AddChangeHook(OnMinimumChange);
AutoExecConfig(true);
}
public void OnMinimumChange(ConVar cvar, const char[] oldVal, const char[] newVal)
{
minimum = StringToFloat(newVal);
}
public Action CP_OnChatMessage(int &author, ArrayList recipients, char[] flagstring, char[] name, char[] message, bool &processcolors, bool &removecolors)
{
char[] flagString = new char[2];
gCV_Flag.GetString(flagString, 2);
AdminFlag admflag;
if(FindFlagByChar(flagString[0], admflag))
{
AdminId adminId = GetUserAdmin(author);
if(adminId == INVALID_ADMIN_ID || (adminId != INVALID_ADMIN_ID && !GetAdminFlag(adminId, admflag)))
{
return Plugin_Continue;
}
}
if(_RTLify(message, message) == 0)
{
return Plugin_Continue;
}
return Plugin_Changed;
}
int _RTLify(char[] dest, char[] original)
{
int rtledWords = 0;
char[][] tokens = new char[96][96];
char[][] words = new char[96][96];
int n = ExplodeString(original, " ", tokens, 96, 96);
for(int word = 0; word < n; word++)
{
if(WordAnalysis(tokens[word]) >= minimum)
{
ReverseString(tokens[word], 96, words[n-1-word]);
rtledWords++;
}
else
{
int firstWord = word;
int lastWord = word;
while(WordAnalysis(tokens[lastWord]) < minimum)
{
lastWord++;
}
for(int t = lastWord - 1; t >= firstWord; t--)
{
strcopy(words[n-1-word], 96, tokens[t]);
if(t > firstWord)
{
word++;
}
}
}
}
ImplodeStrings(words, n, " ", dest, 96);
return rtledWords;
}
void ReverseString(char[] str, int maxlength, char[] buffer)
{
for(int character = strlen(str); character >= 0; character--)
{
if(str[character] >= 0xD6 && str[character] <= 0xDE)
{
continue;
}
if(character > 0 && str[character - 1] >= 0xD7 && str[character - 1] <= 0xD9)
{
Format(buffer, maxlength, "%s%c%c", buffer, str[character - 1], str[character]);
}
else
{
Format(buffer, maxlength, "%s%c", buffer, str[character]);
}
}
}
float WordAnalysis(char[] word)
{
int count = 0;
int length = strlen(word);
for(int n = 0; n < length - 1; n++)
{
if(IsRTLCharacter(word, n))
{
count++;
n++;
}
}
return float(count) * 2 / length;
}
bool IsRTLCharacter(char[] str, int n)
{
return (str[n] >= 0xD6 && str[n] <= 0xDE && str[n + 1] >= 0x80 && str[n + 1] <= 0xBF);
}
public int Native_RTLify(Handle plugin, int params)
{
int destLen = GetNativeCell(2);
char[] dest = new char[destLen];
int originalLen = destLen;
GetNativeStringLength(3, originalLen);
char[] original = new char[originalLen];
GetNativeString(3, original, originalLen + 1);
int amount = _RTLify(dest, original);
SetNativeString(1, dest, destLen, true);
return amount;
}
ERROR:
Code:
L 05/11/2018 - 23:59:13: [SM] Exception reported: Not enough space on the heapL 05/11/2018 - 23:59:13: [SM] Blaming: rtler.smxL
05/11/2018 - 23:59:13: [SM] Call stack trace
:L 05/11/2018 -
23:59:13: [SM] [1] Line 79, D:\xx\xx\xx\SM Compiler\rtler.sp::_RTLifyL 05/11/2018 - 23:59:13: [SM] [2] Line 66, D:\xx\xx\xx\SM Compiler\rtler.sp::CP_OnChatMessageL 05/11/2018 - 23:59:13: [SM] [4] Call_FinishL 05/11/2018 - 23:59:13: [SM] [5] Line 270, D:\xx\SM Compiler\chat-processor.sp::OnSayText2
* I need help also with the "Menu", i want to change his location instead of the very left side of the HUD to other location on screen.
* I want to lower the "Admin Menu/Store/VIP", because the "Menu" is displayed on the player money.
* Also if there is any Source Pawn Programmer who can add me and we talk in private voice chat and helping me with new script that i want to do.
* Willing to pay for the new script build ^^
Have a great day/evening.
Discord: Di3Z1E#2441
Steam