View Single Post
r0ma
Senior Member
Join Date: Apr 2012
Location: Great Tomb of Nazarick
Old 08-03-2020 , 20:25   Re: RTL-Chat Module?
Reply With Quote #4

test
PHP Code:
#include <amxmodx>

#pragma semicolon 1
#pragma dynamic 32768

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "alongub"

new Float:minimum 0.1;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd("say""clcmdSay");
}

public 
clcmdSay(id) {
    new 
buffer[192], tokens[96][96], words[96][96], rtledWords;
    
    
read_args(buffercharsmax(buffer));
    
remove_quotes(buffer);
    
replace_all(buffercharsmax(buffer), "%""");
    
    new 
explode_string(buffer" "tokenssizeof tokenssizeof tokens);
    
    for(new 
ini++) {
        if(
WordAnalysis(tokens[i]) >= minimum) {
            
ReverseString(tokens[i], sizeof(tokens[]), words[n-1-i]);
            
rtledWords++;
        }
        else {
            new 
firstWord i;
            new 
lastWord i;
            
            while (
lastWord && WordAnalysis(tokens[lastWord]) < minimum)
            {
                
lastWord++;
            }
            
            for (new 
lastWord 1>= firstWordt--)
            {
                
copy(words[n-1-i], sizeof(tokens[]), tokens[t]);
                
                if (
firstWord)
                    
i++;
            }
        }
    }
    
    if(
rtledWords) {
        
implode_strings(wordsn" "buffersizeof(words[]));
        
        new 
name[33], alive is_user_alive(id);
        
get_user_name(idnamecharsmax(name));
        
        for(new 
1<= MaxClientsi++) {
            if(
id == || alive == is_user_alive(i))
                
client_print_color(iid"^x03%s^x01 : %s"namebuffer);
        }
        
        return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE;
}

stock ReverseString(str[], maxlengthbuffer[]) {
    for (new 
character strlen(str); character >= 0character--)
    {
        if (
str[character] >= 0xD6 && str[character] <= 0xDE)
            continue;
        
        if (
character && str[character 1] >= 0xD7 && str[character 1] <= 0xD9)
            
format(buffermaxlength"%s%c%c"bufferstr[character 1], str[character]);
        else
            
format(buffermaxlength"%s%c"bufferstr[character]);
    }
}

stock Float:WordAnalysis(word[]) {
    new 
count 0length strlen(word);
    
    for (new 
0length 1n++) {
        if (
IsRTLCharacter(wordn)) {
            
count++;
            
n++;
        }
    }
    
    return 
float(count) * length;
}

stock IsRTLCharacter(str[], n) {
    return (
str[n] >= 0xD6 && str[n] <= 0xDE && str[1] >= 0x80 && str[1] <= 0xBF);

__________________
Discord:FluffyDeveloper#4753
Github: https://github.com/francoromaniello
AMX-ES: https://amxmodx-es.com/r0ma'
r0ma is offline
Send a message via MSN to r0ma