Raised This Month: $ Target: $400
 0% 

Reading data


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-12-2013 , 19:58   Re: Reading data
Reply With Quote #9

Here's my suggestion. It requires this file.
The regex part might not be perfect because I learned it now just to create this.
Code:
#include <amxmodx> #include <http> #include <regex> new Results[6][32]; enum patternsEnum {     Prefix[32],     Pattern[128] } new 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", "", "");         HTTP_DownloadFile("http://www.gametracker.com/player/londin/78.110.163.197:27015/", "result.txt"); } public HTTP_Download(const szFile[] , iDownloadID , iBytesRecv , iFileSize , bool:TransferComplete) {         if ( ! TransferComplete )         return;         new hFile = fopen(szFile, "r");     new num, i, bool: searching;     new buffer[1024], error[128];     if ( ! hFile )         return;         while ( ! feof(hFile) && i < sizeof Info ) {         fgets(hFile, buffer, charsmax(buffer));                 if ( ! searching && contain(buffer, Info[i][Prefix]) != -1 )         searching = true;                 if ( searching ) {                         new Regex:hRegex = regex_match(buffer, Info[i][Pattern], num, error, 127);                         if ( hRegex >= REGEX_OK ) {                 regex_substr(hRegex, 0, Results[i], 31);                 server_print("%s %s", Info[i][Prefix], Results[i]);                 regex_free(hRegex);                 i++;                 searching = false;             }         }     }     fclose(hFile)         delete_file(szFile); }

Code:
First Seen: Aug 12, 2013
Last Seen: Today 7:36 AM
Score: 0
Minutes Played: 0
Score per Minute: 0
Rank on Server: #24185 out of 24184
__________________

Last edited by Black Rose; 08-13-2013 at 11:38.
Black Rose is offline
 



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 15:56.


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