Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "SDK\amx\amx.h"
- #include "SDK\plugincommon.h"
- #include <string>
- typedef void(*logprintf_t)(char* format, ...);
- logprintf_t logprintf;
- extern void *pAMXFunctions;
- PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
- {
- pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
- logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];
- logprintf(" =======================================");
- logprintf(" ** Color Embed by Aktah loaded");
- logprintf(" =======================================");
- return 1;
- }
- PLUGIN_EXPORT void PLUGIN_CALL Unload()
- {
- logprintf(" =======================================");
- logprintf(" ** Color Embed by Aktah unloaded");
- logprintf(" =======================================");
- }
- char* subc(const char* input, int offset, int len, char* dest)
- {
- int input_len = strlen(input);
- if (offset + len > input_len)
- {
- return NULL;
- }
- strncpy(dest, input + offset, len);
- return dest;
- }
- int shiftLeft(char text[], char color[], int Pos, int shiftBy)
- {
- int count = 0;
- char igor_spaces[] = { ' ', '\n', '\t' };
- while (shiftBy > 0) {
- text[Pos + 7 - count] = text[Pos - 1 - count];
- if (!memchr(igor_spaces, text[Pos - 1 - count], sizeof(igor_spaces)))
- {
- shiftBy--;
- }
- count++;
- }
- text[Pos - count] = color[0];
- text[Pos - count + 1] = color[1];
- text[Pos - count + 2] = color[2];
- text[Pos - count + 3] = color[3];
- text[Pos - count + 4] = color[4];
- text[Pos - count + 5] = color[5];
- text[Pos - count + 6] = color[6];
- text[Pos - count + 7] = color[7];
- return Pos - count + 7;
- }
- cell AMX_NATIVE_CALL CE_Convert(AMX *amx, cell *params)
- {
- int
- len = NULL,
- ret = NULL;
- cell *addr = NULL;
- amx_GetAddr(amx, params[1], &addr);
- amx_StrLen(addr, &len);
- if (len)
- {
- len++; // for \0
- char* text = new char[len];
- amx_GetString(text, addr, 0, len);
- int next_space = -1;
- int last_check = 0;
- int vowel_count = 0;
- char vowel[] = { 'ั', 'ิ', 'ี', 'ึ', 'ื', 'ุ', 'ู', '็', '่', '้', '๊', '๋', '์', 'ํ', 'ำ' };
- char double_vowel[] = { 'ั', 'ิ', 'ี', 'ึ', 'ื', '่', '้', '๊', '๋', 'ํ', 'ำ' };
- for (int i = 0, j = len; i < j; ++i) {
- next_space = i + 7;
- if (text[i] == '{' && next_space < j && text[next_space] == '}') {
- char EmbledColor[8];
- subc(text, i, 8, EmbledColor);
- for (int x = last_check + 1; x < i; x++) {
- if (memchr(vowel, text[x], sizeof(vowel)))
- {
- vowel_count++;
- }
- // DOUBLE VOWEL WITH SPACES like นั้น_ or นี้_ << underscore are blank space or newline
- if (memchr(double_vowel, text[x], sizeof(double_vowel)) && memchr(double_vowel, text[x + 1], sizeof(double_vowel))
- && (text[x + 2] == ' ' || text[next_space + 1] == ' ' || text[x + 3] == '\n'))
- {
- vowel_count--;
- }
- }
- if (vowel_count > 0) {
- shiftLeft(text, EmbledColor, i, vowel_count);
- }
- last_check = next_space;
- }
- }
- amx_SetString(addr, text, 0, 0, len);
- delete[] text;
- }
- return 1;
- }
- AMX_NATIVE_INFO projectNatives[] =
- {
- { "CE_Convert", CE_Convert }
- };
- PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
- {
- return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES;
- }
- PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx)
- {
- return amx_Register(amx, projectNatives, -1);
- }
- PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx)
- {
- return AMX_ERR_NONE;
- }
Advertisement
Add Comment
Please, Sign In to add comment