Thread: HTTP:X
View Single Post
lexzor
Veteran Member
Join Date: Nov 2020
Old 05-10-2021 , 13:34   Re: HTTP:X
Reply With Quote #38

the plugin is updating only when i upload it. i did a debug but didn t even read the version of plugin
PHP Code:
#include <amxmodx>

enum {
    
REQUEST_GET,
    
REQUEST_POST
}

native HTTPX_Download(const URL[], const Filename[] = "", const CompleteHandler[] = "", const ProgressHandler[] = ""Port 0RequestType 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(VersionNumtemp[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"""80REQUEST_GET""""0, -1);
}

public 
Complete(DownloadIDError) {
    if ( 
Error )
    return;

    new 
temp[16];
    
HTTPX_GetData(tempcharsmax(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(hHTTPXfilenamecharsmax(filename));
        
server_print("%s"filename)
        if ( 
callfunc_begin("AutoupdatePlugin"filename) == ) {
            
server_print("auto update start")
            
callfunc_push_int(get_plugin(-1));
            
callfunc_push_str(AUTOUPDATE_FILE_IDfalse);
            
callfunc_push_int(AUTOUPDATE_HOW_OFTEN);
            
callfunc_end();
        }
    }
}

public 
plugin_natives()
set_native_filter("forwardNativeFilter");

public 
forwardNativeFilter(const Native[], IndexTrap) {
    
    if ( 
Trap )
    return 
PLUGIN_CONTINUE;

    if ( 
equal(Native"HTTPX_Download") || equal(Native"HTTPX_GetData") ) {
        
gHTTPX false;
        return 
PLUGIN_HANDLED;
    }

    return 
PLUGIN_CONTINUE;


Last edited by lexzor; 05-10-2021 at 13:35.
lexzor is offline