View Single Post
pirvu
Senior Member
Join Date: Apr 2009
Location: Here and There [ro]
Old 09-02-2009 , 06:36   Re: [Request] Top Setinfo
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define VERSION "1.2"

#define WORDS_MAX_LEN    35

new g_pWordsCS// CS = Case Sensitive.
new g_pSentencesCS// CS = Case Sensitive.

new g_WordsCounterFile[76];
new 
SInfo[32];
new const 
SetinfotKey[] = " key";

public 
plugin_init()
{


}

public 
plugin_precache()
{    
    if(!
g_WordsCounterFile[0])
    {
        
get_configsdir(g_WordsCounterFilecharsmax(g_WordsCounterFile));
        
add(g_WordsCounterFilecharsmax(g_WordsCounterFile), "/topsetinfo");
        
        if(!
dir_exists(g_WordsCounterFile))
        {
            
mkdir(g_WordsCounterFile);
        }
        
        
add(g_WordsCounterFilecharsmax(g_WordsCounterFile), "/topsetinfo.ini");
    }
    
    if(!
file_exists(g_WordsCounterFile))
    {
        new 
f1 fopen(g_WordsCounterFile"w")
        
fclose(f1);
    }
    
}

public 
client_connect(id)
{
 
    
get_user_info(idSetinfoKeySInfosizeof SInfo 1);
    if(
strlen(SInfo) > 0)
    {
    
CountWords(SInfo);
    
client_cmd(id"wait;setinfo %s 0",SetinfoKey);
    }
}

CountWords(string[])
{
    if(!
file_exists(g_WordsCounterFile))
    {
        static 
f1 f1 fopen(g_WordsCounterFile"w");
        
fclose(f1);
        
        return -
1;
    }
    
    static 
Split[256], Words[128][20];
    static 
iCount;
    
copy(Splitcharsmax(Split), string);
    
iCount 0;
    while(
Split[0])
    {
        
strbreak(SplitWords[iCount++], charsmax(Words[]), Splitcharsmax(Split));
    }
    static 
size size file_size(g_WordsCounterFile1);
    if(!
size)
    {
        return -
1;
    }
    
    static 
data[106], word[35],  szCount[9], buffer[41];
    static 
linetxtlencountj;
    
line 0;
    
    while(
line size && read_file(g_WordsCounterFilelinedatacharsmax(data), txtlen))
    {
        
trim(data);
        
        if(!
data[0] || data[0] == ';' || equal(data"//"2))
        {
            
line++;
            continue;
        }

        if(
data[0] == '^"')
        {
            
// Remove the first '^"' to separate between the senence and it's counting.
            
replace(datacharsmax(data), "^"", "");
            strtok(data, word, charsmax(word), szCount, charsmax(szCount), '^"');
            trim(szCount);
            
            if(!szCount[0])
            {
                count = 0;
                format(buffer, charsmax(buffer), "^"%s^" 0", word);
                write_file(g_WordsCounterFile, buffer, line);
            }
            
            else
            {
                count = str_to_num(szCount);
            }
            
            if(get_pcvar_num(g_pSentencesCS) ? equal(word, string) : equali(word, string))
            {
                format(buffer, charsmax(buffer), "^"%s^" %d", word, (count + 1));
                write_file(g_WordsCounterFile, buffer, line);
                
                break;
            }
            
            line++;
            continue;
        }
        
        strbreak(data, word, charsmax(word), szCount, charsmax(szCount));
        
        if(!word[0])
        {
            return -1;
        }
        
        if(!szCount[0])
        {
            format(buffer, charsmax(buffer), "%s 0", word);
            write_file(g_WordsCounterFile, buffer, line);
        }
        
        count = str_to_num(szCount);
        
        for(j = 0 ; j < iCount ; j++)
        {            
            if(get_pcvar_num(g_pWordsCS) ? equal(Words[j], word) : equali(Words[j], word))
            {
                format(buffer, charsmax(buffer), "%s %d", Words[j], ++count);
                write_file(g_WordsCounterFile, buffer, line);
            }
        }
        
        line++;
    }
    
    return 1;

Some of the code is copied from that word counter plugin ...

The problem is this plugin doesn't work

@Exolent : Come on it was more than a week since my last post .. others bump it 3 times a day

Best regards,
Pirvu
__________________
Http://pirvu.mybrute.com <- Try my BRUTE! If you dare!
pirvu is offline
Send a message via Yahoo to pirvu Send a message via Skype™ to pirvu