Raised This Month: $159 Target: $400
 39% 

[Request] Top Setinfo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pirvu
Senior Member
Join Date: Apr 2009
Location: Here and There [ro]
Old 08-23-2009 , 09:49   [Request] Top Setinfo
Reply With Quote #1

First of all to have a nvault with <STRING> <VALUE>

When a guy connects to my server with

setinfo _KEY <String>

1. Search in the nvault for the value <STRING>

If <STRING> is not found in the nvault --> Set <String> to value 1
If <STRING> Has value n --> Set <STRING> to value n+1

2. To make a top 15 with the <Strings> and <Value>

3. Set the user setinfo _KEY to null or 0

Like when you write /topstring --> to show you a motd with first 15 :-s


As allways i want suggestions and some help (not like others .. lordshiva who wants the hole plugin done ;) )

Suggestions like

1. What is the better way to get some1 setinfo _KEY value
2. What is the better way to set some1 setinfo _KEY value to 0
3. How to that top15... maybe using a txt file for all the STRINGS
4. Any ideas ;)?
__________________
Http://pirvu.mybrute.com <- Try my BRUTE! If you dare!

Last edited by pirvu; 08-23-2009 at 09:52.
pirvu is offline
Send a message via Yahoo to pirvu Send a message via Skype™ to pirvu
Old 08-31-2009, 14:10
pirvu
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post.
pirvu
Senior Member
Join Date: Apr 2009
Location: Here and There [ro]
Old 09-02-2009 , 07: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
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:22.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode