Thank you, but unfortunately I'm afraid there's another problem.
Code:
/* Plugin Template generated by Pawn Studio */
#pragma semicolon 1
#pragma dynamic 32767 // Without this line will crash server!!
#include <sourcemod>
#include <cURL>
#define USE_THREAD 1
#define TEST_FOLDER "data/curl_test"
new CURL_Default_opt[][2] = {
#if USE_THREAD
{_:CURLOPT_NOSIGNAL,1},
#endif
{_:CURLOPT_NOPROGRESS,1},
{_:CURLOPT_TIMEOUT,30},
{_:CURLOPT_CONNECTTIMEOUT,60},
{_:CURLOPT_VERBOSE,0}
};
#define CURL_DEFAULT_OPT(%1) curl_easy_setopt_int_array(%1, CURL_Default_opt, sizeof(CURL_Default_opt))
public Plugin:myinfo =
{
name = "New Plugin",
author = "PP(R)TH: Dr. Gregory House",
description = "<- Description ->",
version = "1.0",
url = "<- URL ->"
}
public OnPluginStart()
{
// Add your own code here...
RegAdminCmd("sm_playtimetest", PlaytimeTest_Used, ADMFLAG_KICK);
}
public Action:PlaytimeTest_Used(client, args)
{
new Handle:curl = curl_easy_init();
if(curl != INVALID_HANDLE)
{
CURL_DEFAULT_OPT(curl);
curl_easy_setopt_function(curl, CURLOPT_WRITEFUNCTION, WriteFunction);
curl_easy_setopt_string(curl, CURLOPT_URL, "http://steamcommunity.com/profiles/76561197986272671/stats/L4D2?l=english");
ExecCURL(curl, client);
}
return Plugin_Handled;
}
public WriteFunction(Handle:hndl, const String:buffer[], const bytes, const nmemb)
{
}
public onComplete(Handle:hndl, CURLcode: code, any:data)
{
if(code != CURLE_OK)
{
}
CloseHandle(hndl);
}
stock ExecCURL(Handle:curl, client)
{
#if USE_THREAD
curl_easy_perform_thread(curl, onComplete, client);
#else
new CURLcode:code = curl_load_opt(curl);
if(code != CURLE_OK) {
PrintTestCaseDebug(client, "curl_load_opt Error");
PrintcUrlError(code);
CloseHandle(curl);
return;
}
code = curl_easy_perform(curl);
onComplete(curl, code, client);
#endif
}
I copied this together from the given example. Afais there's no way to get a threaded solution in this form, because I can't pass an identifying value to WriteFunction so that I could know which client executed the command. Due to that it's also not possible to write to multiple buffers at the same time to store the webpages in.