Raised This Month: $ Target: $400
 0% 

Plugin possible or wrong?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-26-2013 , 16:14   Re: Plugin possible or wrong?
Reply With Quote #1

Sorry for the delay. I rewrote it using HTTP2 and on-the-fly parsing.
You obviously have to edit the way this information is printed to your liking. I made it fit my purpose of testing.
Code:
#include <amxmodx> #include <http2> #include <regex> #define SERVER_IP "PUT YOUR IP HERE" #define TOTAL   0 #define CURRENT 1 new g_patterns[][] = {     "(?:First Seen:[\r\n\s]*<.+>[\r\n\s]*)(\w{3} [0-3][0-9], [12][019][0-9][0-9])",     "(?:Last Seen:[\r\n\s]*<.+>[\r\n\s]*)(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:[\r\n\s]*<.+>[\r\n\s]*)(\d+)",     "(?:Minutes Played:[\r\n\s]*<.+>[\r\n\s]*)(\d+)",     "(?:Score per Minute:[\r\n\s]*<.+>[\r\n\s]*)(\d+\.?\d?)",     "(?:Rank on Server:[\r\n\s]*<.+>[\r\n\s]*(?:<a.*>[\r\n\s]*)?)(#\d+(?: out of \d+)?)" } enum playerinfo_enum {     FirstSeen[16],     LastSeen[16],     Score[2],     MinutesPlayed[2],     Float:ScorePerMinute[2],     RankOnServer[2],     bool:CurrentStats }; new g_playerinfo[33][playerinfo_enum]; new g_downloadinfo[HTTP2_MAX_DOWNLOAD_SLOTS]; new g_totalranks; new bool:g_cmd_blocked[33]; new buffer[HTTP2_BUFFER_SIZE]; public plugin_init() {     register_plugin("Gametracker Test", "1.1", "[ --{-@ ]");         register_clcmd("say /myinfo", "clcmd_myinfo"); } public clcmd_myinfo(id, level, cid) {         if ( g_cmd_blocked[id] )         return;         g_cmd_blocked[id] = true;         clear_pinfo_array(id);         new name[32];     get_user_name(id, name, charsmax(name));         new URL[128];     formatex(URL, charsmax(URL), "http://www.gametracker.com/player/%s/%s/", name, SERVER_IP);         new download_index = HTTP2_Download(URL, _, _, "DownloadProcess");     if ( download_index >= 0 )         g_downloadinfo[download_index] = id; } public DownloadProcess(index) {         new id = g_downloadinfo[index];     new num, startpos, result[32];         HTTP2_getDataSafe(index, buffer, charsmax(buffer));         if ( contain(buffer, "PLAYER SUMMARY") == -1 )         return PLUGIN_CONTINUE;         if ( contain(buffer, "CURRENT STATS") != -1 )         g_playerinfo[id][CurrentStats] = true;         for ( new i = 0 ; i < sizeof g_patterns ; i++ ) {         new Regex:hRegex = regex_match(buffer[startpos], g_patterns[i], num, result, charsmax(result));                 if ( hRegex >= REGEX_OK ) {             regex_substr(hRegex, 1, result, charsmax(result));                         new slot = g_playerinfo[id][CurrentStats] && ! startpos ? CURRENT : TOTAL;                         switch ( i ) {                 case 0: copy(g_playerinfo[id][FirstSeen], charsmax(g_playerinfo[][FirstSeen]), result);                 case 1: copy(g_playerinfo[id][LastSeen], charsmax(g_playerinfo[][LastSeen]), result);                 case 2: g_playerinfo[id][Score][slot] = str_to_num(result);                 case 3: g_playerinfo[id][MinutesPlayed][slot] = str_to_num(result);                 case 4: g_playerinfo[id][ScorePerMinute][slot] = any:str_to_float(result);                 case 5: {                     g_playerinfo[id][RankOnServer][slot] = str_to_num(result[1]);                     if ( slot == TOTAL ) {                         g_totalranks = str_to_num(result[contain(result, "out of") + 7]);                     }                 }             }                         regex_free(hRegex);         }         if ( i == sizeof g_patterns - 1 && g_playerinfo[id][CurrentStats] && ! startpos ) {             i -= 4;             startpos = contain(buffer, "ALL TIME STATS");         }         else if ( i == sizeof g_patterns - 1 ) {             server_print("");             server_print("First Seen: %s", g_playerinfo[id][FirstSeen]);             server_print("Last Seen: %s", g_playerinfo[id][LastSeen]);             server_print("");             server_print("Total Score: %d", g_playerinfo[id][Score][TOTAL]);             server_print("Total Minutes Played: %d", g_playerinfo[id][MinutesPlayed][TOTAL]);             server_print("Total Score Per Minute: %0.1f", g_playerinfo[id][ScorePerMinute][TOTAL]);             server_print("Total Rank: #%d/#%d", g_playerinfo[id][RankOnServer][TOTAL], g_totalranks);             server_print("");             server_print("Current Score: %d", g_playerinfo[id][Score][CURRENT]);             server_print("Current Minutes Played: %d", g_playerinfo[id][MinutesPlayed][CURRENT]);             server_print("Current Score Per Minute: %0.1f", g_playerinfo[id][ScorePerMinute][CURRENT]);             server_print("Current Rank: #%d", g_playerinfo[id][RankOnServer][CURRENT]);             g_cmd_blocked[id] = false;             return PLUGIN_HANDLED;         }     }     return PLUGIN_CONTINUE; } clear_pinfo_array(id) {     arrayset(g_playerinfo[id][FirstSeen], 0, sizeof g_playerinfo[][FirstSeen]);     arrayset(g_playerinfo[id][LastSeen], 0, sizeof g_playerinfo[][LastSeen]);     g_playerinfo[id][Score][TOTAL] = 0;     g_playerinfo[id][Score][CURRENT] = 0;     g_playerinfo[id][MinutesPlayed][TOTAL] = 0;     g_playerinfo[id][MinutesPlayed][CURRENT] = 0;     g_playerinfo[id][ScorePerMinute][TOTAL] = any:0.0;     g_playerinfo[id][ScorePerMinute][CURRENT] = any:0.0;     g_playerinfo[id][RankOnServer][TOTAL] = 0;     g_playerinfo[id][RankOnServer][CURRENT] = 0;     g_playerinfo[id][CurrentStats] = false; }
__________________

Last edited by Black Rose; 08-27-2013 at 16:33. Reason: Added a flood-check.
Black Rose is offline
devilicioux
Veteran Member
Join Date: Jun 2013
Location: Delhi,India
Old 08-27-2013 , 06:16   Re: Plugin possible or wrong?
Reply With Quote #2

Hey Blackrose .. First of all thank you for helping with the codes everytime ..
I tried the code you made in that thread using HTTP.inc .. There seems to be a little problem .. whenever i type /myinfo in chat .. The server gets stuck for 2-3 seconds and few of the players get Overflowed,I got lagged for atleast a minute .. and suddenly i woke up back in next round .. Checked up the server console it showed almost 10-12 ppl got overflowed and kicked.
This was the bad thing that happened.Now Gud thing was this happened second time.
When i tried first time .. 2-3 Seconds stucking and game continuous and then out of no where after 15-20 seconds the Info was shown on HUD Such a delay is not gud.
So i had to remove the plugin as a result.May be the socket connections are happening too slow in that plugin.

Now i ll go and try the code you made with Http2.inc and Give you the accurate feedback
__________________
You keep bringing ANTICHRISTUS down .. He will rise again and kick asses !

#RespectList ANTICHRISTUS fysiks Bugsy

Most Common Errors You Can Encounter Every Now and Then
devilicioux is offline
Reply



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:57.


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