Hello. I'm trying to use HTTP:X by Black Rose, but the plugin is updating only when i upload the plugin. I tried to debug it but at the second change map the plugin is not updating:
Code:
PHP Code:
#include <amxmodx>
enum {
REQUEST_GET,
REQUEST_POST
}
native HTTPX_Download(const URL[], const Filename[] = "", const CompleteHandler[] = "", const ProgressHandler[] = "", Port = 0, RequestType = REQUEST_GET, const Username[] = "", const Password[] = "", ... /* For possible future use */)
native HTTPX_GetData(data[], len)
#define AUTOUPDATE_FILE_ID "76775"
#define AUTOUPDATE_HOW_OFTEN 0 // Download immediately
new const VersionNum = 102
new gHTTPX = true;
public plugin_init() {
new temp[5];
num_to_str(VersionNum, temp[1], charsmax(temp));
temp[0] = temp[1];
temp[1] = '.';
register_plugin("HTTP:X Autoupdate example 2", temp, "[ --{-@ ]");
if ( gHTTPX )
HTTPX_Download("https://lexzor.warface.ro/AutoUpdate/Test/version.txt", "dada.amxx", "Complete", "", _, REQUEST_GET, "", "", 0, -1);
}
public Complete(DownloadID, Error) {
if ( Error )
return;
new temp[16];
HTTPX_GetData(temp, charsmax(temp));
server_print("%s", temp)
if ( str_to_num(temp) > VersionNum )
UpdatePlugin();
}
UpdatePlugin() {
new hHTTPX = is_plugin_loaded("HTTP:X");
server_print("plugin loaded")
if ( hHTTPX )
{
new filename[64];
get_plugin(hHTTPX, filename, charsmax(filename));
server_print("%s", filename)
if ( callfunc_begin("AutoupdatePlugin", filename) == 1 ) {
server_print("auto update start")
callfunc_push_int(get_plugin(-1));
callfunc_push_str(AUTOUPDATE_FILE_ID, false);
callfunc_push_int(AUTOUPDATE_HOW_OFTEN);
callfunc_end();
}
}
}
public plugin_natives()
set_native_filter("forwardNativeFilter");
public forwardNativeFilter(const Native[], Index, Trap) {
if ( Trap )
return PLUGIN_CONTINUE;
if ( equal(Native, "HTTPX_Download") || equal(Native, "HTTPX_GetData") ) {
gHTTPX = false;
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}