AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved HTTP:X Problem (https://forums.alliedmods.net/showthread.php?t=332408)

lexzor 05-10-2021 14:40

HTTP:X Problem
 
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 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"""_REQUEST_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;



Shadows Adi 05-10-2021 14:59

Re: HTTP:X Problem
 
Use cURL for sending / receiveing data to websites, it is easier, but you need to read some of the API: https://curl.se/libcurl/c/

Bugsy 05-10-2021 17:42

Re: HTTP:X Problem
 
I recently updated VAC Ban Status to use CURL to allow connections to https servers. You can look at the source to figure out how to use it:

lexzor 05-11-2021 10:17

Re: HTTP:X Problem
 
I will use cURL. Thanks.


All times are GMT -4. The time now is 02:29.

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