AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help - Plugin stats (https://forums.alliedmods.net/showthread.php?t=295476)

plazma 03-26-2017 14:30

Help - Plugin stats
 
When i say /myinfo not worked ??


PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <regex>
#include <http>

#define SERVER_IP   "78.110.163.197:27015"

new g_DownloadId[33];
new 
g_MaxClients;

enum patternsEnum {
    
Prefix[32],
    
Pattern[128]
}

new 
g_Info[][patternsEnum] = {
    { 
"First Seen:",        "\w{3} [0-3][0-9], [12][019][0-9][0-9]" },
    { 
"Last Seen:",   "Online Now|(((Yester|To)day)|(\w{3} [0-3][0-9], [12][019][0-9][0-9])) (1[0-2]|[0-9]):[0-5]\d [A|P]M" },
    { 
"Score:",    "(?<=\s)\d+" },
    { 
"Minutes Played:",    "(?<=\s)\d+" },
    { 
"Score per Minute:",  "(?<=\s)\d+\.?\d?" },
    { 
"Rank on Server:",    "#\d+ out of \d+" }
};

public 
plugin_init() {
    
register_plugin("Test Plugin 9""""");
    
register_clcmd("say /myinfo""cmd_MyInfo");
    
    
g_MaxClients global_get(glb_maxClients); // Get maximum possible ammount of players
}

public 
cmd_MyInfo(idlevelcid) {

    if ( 
g_DownloadId[id] ) // Spam protection.
        
return;
    
    new 
name[40];
    new 
url[128];
    
    
get_user_name(idnamecharsmax(name)); // Retrieve user name.
    
    
formatex(urlcharsmax(url), "http://www.gametracker.com/player/%s/%s/"nameSERVER_IP); // Format the url.
    
formatex(name[strlen(name)], charsmax(name) - strlen(name), ".txt"); // We'll reuse the name variable to store the filename since we're done with the name.
    
    
g_DownloadId[id] = HTTP_DownloadFile(urlname);
}

public 
client_disconnect(id) {
    
HTTP_AbortTransfer(g_DownloadId[id]); // No need to download the file if the user isn't interested.
    
g_DownloadId[id] = 0// We have to reset the spam protection, otherwise a joining player might be blocked for no reason.
}

public 
HTTP_Download(const szFile[] , iDownloadID iBytesRecv iFileSize bool:TransferComplete) {
    
    if ( ! 
TransferComplete )
        return; 
// SHUT UP!
    
    
new id;
    
    for ( new 
<= g_MaxClients i++ ) {
        if ( 
g_DownloadId[i] == iDownloadID // Find the person who's requested this download.
            
id i// Store it.
    
}
    
    
g_DownloadId[id] = 0// Reset the spam protection so people can use the command more than once.
    
    
if ( ! is_user_connected(id) ) // Just in case.
        
return;
    
    new 
buffer[1024], iboolsearching// Variables of the file reading.
    
new result[128], num// Variables of RegEx.
    
new message[1024], len// Variables of the hudmessage.
    
    
new hFile fopen(szFile"r"); // Open the file.
    
    
if ( ! hFile // Just in case.
        
return;
    
    while ( ! 
feof(hFile) && sizeof g_Info ) {
        
fgets(hFilebuffercharsmax(buffer)); // Read contents of result.
        
        
if ( ! searching && contain(bufferg_Info[i][Prefix]) != -// Does it contain the prefix?
            
searching true// Because then we will start the regex search.
        
        
if ( searching ) { // To avoid false positives since this is a multiple line file.
            
            
new Regex:hRegex regex_match(bufferg_Info[i][Pattern], numresult127); // Search for the pattern in the current line.
            
            
if ( hRegex <= REGEX_PATTERN_FAIL )
                
server_print("Regex error: %d, %s"numresult); // WROOOOONG!
            
            
if ( hRegex >= REGEX_OK ) { // Do we have a match?
                
regex_substr(hRegex0resultcharsmax(result)); // Read the first match of the regex.
                
len += formatex(message[len], charsmax(message) - len"%s^t%s^n"g_Info[i][Prefix], result); // Add the prefix and result to the hudmessage.
                
regex_free(hRegex); // We don't want leaked memory and open handles.
                
searching false// To avoid false positives.
                
i++; // NEXT!
            
}
        }
    }
    
    
fclose(hFile); // We don't want leaked memory and open handles.
    
    
set_hudmessage(_,_,_,_,_,_,_,15.0,_,_,-1);
    
show_hudmessage(idmessage);
    
    
set_task(3.0"DeleteFile"id 1253862szFilestrlen(szFile)); // It doesn't seem to work if you do it instantly for some reason.
}

public 
DeleteFile(const szFile[]) {
    
delete_file(szFile);



EFFx 03-26-2017 18:22

Re: Help - Plugin stats
 
(id, level, cid) are used when you registered concmd.

OciXCrom 03-26-2017 18:58

Re: Help - Plugin stats
 
No. It's used when you want to add an access flag to both clcmd or concmd.

plazma 03-27-2017 03:41

Re: Help - Plugin stats
 
wtf why not work !! fix him.


All times are GMT -4. The time now is 18:03.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.