Thread: [Solved] CURL: Downloanding an page ?
View Single Post
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 04-29-2022 , 10:40   Re: CURL: Downloanding an page ?
Reply With Quote #15

A friend with AMXX 1.10 got same errors:

Code:
// C:\Users\teodo\OneDrive\Desktop\AMXX 1.8.2 COMPILER LOCAL 26.01\include\curl_consts.inc(497) : warning 200: symbol "CURLINFO_CONTENT_LENGTH_DOWNLOA" is truncated to 31 characters
// C:\Users\teodo\OneDrive\Desktop\AMXX 1.8.2 COMPILER LOCAL 26.01\include\curl_consts.inc(1033) : warning 200: symbol "CURLOPT_CONV_FROM_NETWORK_FUNCT" is truncated to 31 characters
// C:\Users\teodo\OneDrive\Desktop\AMXX 1.8.2 COMPILER LOCAL 26.01\include\curl_consts.inc(1037) : warning 200: symbol "CURLOPT_CONV_TO_NETWORK_FUNCTIO" is truncated to 31 characters
// C:\Users\teodo\OneDrive\Desktop\AMXX 1.8.2 COMPILER LOCAL 26.01\include\curl.inc(160) : warning 207: unknown #pragma
// C:\Users\teodo\OneDrive\Desktop\AMXX 1.8.2 COMPILER LOCAL 26.01\include\curl.inc(160) : error 038: extra characters on line
// C:\Users\teodo\OneDrive\Desktop\AMXX 1.8.2 COMPILER LOCAL 26.01\include\curl.inc(166) : warning 207: unknown #pragma
// C:\Users\teodo\OneDrive\Desktop\AMXX 1.8.2 COMPILER LOCAL 26.01\include\curl.inc(166) : error 038: extra characters on line
// C:\Users\teodo\OneDrive\Desktop\AMXX 1.8.2 COMPILER LOCAL 26.01\ore.sma(16) : error 017: undefined symbol "MAX_PLAYERS"
// C:\Users\teodo\OneDrive\Desktop\AMXX 1.8.2 COMPILER LOCAL 26.01\ore.sma(81 -- 82) : warning 213: tag mismatch
`


Meta List :
Code:
 [ 1] AMX Mod X        RUN   -    amxmodx_mm_i386.so          v1.10.0.5461  ini  Start ANY 
[15] CURL AMXX        RUN   -    curl_amxx_i386.so           v1.1.1        pl1  ANY   ANY
So why the hall doesn't work compile ?

Is because the COMPILER is 1.8.2 maybe ?`

--------------------

Edit: I've changed the compile to 1.9 and it compiles but the plugin doesn't work it shows 0 to everything.

I've made changes to be a client_command in chat to print the output, code:

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

#if !defined MAX_IP_WITH_PORT_LENGTH
#define MAX_IP_WITH_PORT_LENGTH 22
#endif

enum _:PlayerData
{
    
iScore,
    
iMinutes,
    
Float:flAvgScore,
    
iRank
}

new 
g_ePlayerData[MAX_PLAYERS 1][PlayerData]

public 
plugin_init()
{
    
register_clcmd("say /playedtime""SendRequest")
}

public 
SendRequest(id)
{
    new 
CURL:curl curl_easy_init();

    new 
szTemp[100];
    new 
szIP[MAX_IP_WITH_PORT_LENGTH]
    
get_user_ip(0szIPcharsmax(szIP))

    new 
iID[1]
    
iID[0] = id

    
new curl_slist:header

    header 
curl_slist_append(header"text/html; charset=UTF-8");
    
header curl_slist_append(header"User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.126 Mobile Safari/537.36");

    
formatex(szTempcharsmax(szTemp), "https://www.gametracker.com/player/%n/%s/"idszIP);

    if(
curl)
    {
        
curl_easy_setopt(curlCURLOPT_URLszTemp);
        
curl_easy_setopt(curlCURLOPT_COOKIE1);
        
curl_easy_setopt(curlCURLOPT_HTTPHEADERheader)
        
curl_easy_setopt(curlCURLOPT_CUSTOMREQUEST"GET");
        
curl_easy_setopt(curlCURLOPT_FOLLOWLOCATIONtrue);

        
curl_easy_setopt(curlCURLOPT_WRITEFUNCTION"ReceiveData");
        
curl_easy_setopt(curlCURLOPT_WRITEDATAid);
        
curl_easy_setopt(curlCURLOPT_BUFFERSIZE1028);

        
curl_easy_setopt(curlCURLOPT_SSL_VERIFYPEER1);
        
curl_easy_setopt(curlCURLOPT_SSL_VERIFYHOST2);
        
curl_easy_setopt(curlCURLOPT_CAINFO"cstrike/addons/amxmodx/cacert.pem");
        
curl_easy_perform(curl"CurlCallback"iIDsizeof(iID) );
    }
}

public 
ReceiveData(data[], sizenmembid)
{
    
// The position of the "Score: " div
    
new iPos containi(data"Score:")

    if(
iPos != -1)
    {
        
g_ePlayerData[id][iScore] = str_to_num(data[iPos 23])
    }

    
iPos containi(data"Minutes Played:")

    if(
iPos != -1)
    {
        
g_ePlayerData[id][iMinutes] = str_to_num(data[iPos 32])
    }

    
iPos containi(data"Score per Minute:")

    if(
iPos != -1)
    {
        
g_ePlayerData[id][flAvgScore] = str_to_float(data[iPos 34])
    }

    
iPos containi(data"Rank on Server:")

    if(
iPos != -1)
    {
        
g_ePlayerData[id][iRank] = str_to_num(data[iPos 95])
    }

    return 
size nmemb
}

public 
CurlCallback(CURL:cURLHandle CURLcode:codeiID[])
{
    if(
code != CURLE_OK)
    {
        new 
szError[CURL_ERROR_SIZE]
        
curl_easy_strerror(codeszError,charsmax(szError))
        
log_amx("cURL error: %d ^"%s^""codeszError);
    }

    new 
id iID[0]

    
client_print(idprint_chat"Score: %d | Minutes: %d | Score p. m.: %f | Rank: %d"g_ePlayerData[id][iScore], g_ePlayerData[id][iMinutes], \
     
g_ePlayerData[id][flAvgScore], g_ePlayerData[id][iRank])

    
curl_easy_cleanup(cURLHandle);


Image: https://prnt.sc/nG0msaQF2VFr

Last edited by Craxor; 04-29-2022 at 11:40.
Craxor is offline
Send a message via ICQ to Craxor