View Single Post
694372459
Member
Join Date: Aug 2012
Old 12-05-2018 , 01:31   Re: [EXTENSION] System2 - Easy to use HTTP(S)/FTP Request API and useful system nativ
Reply With Quote #104

Quote:
Originally Posted by dordnung View Post
Hey,
can you show me the part of your code, as it works fine for me?
Hi, thanks for replying

here's my code:

PHP Code:
#include <sourcemod>
#include <system2>

#define FTP_HOST ""
#define FTP_PORT
#define FTP_USER ""
#define FTP_PWD ""
#define FTP_REQUEST_FILE ""

public OnPluginStart()
{
    
RegServerCmd("test_ftp_download"Command_TestDownload);
}

public 
Action:Command_TestDownload(args)
{
    
System2FTPRequest ftpRequest = new System2FTPRequest(FtpResponseCallbackFTP_REQUEST_FILE);
    
ftpRequest.SetAuthentication(FTP_USERFTP_PWD);
    
ftpRequest.SetPort(FTP_PORT);
    
ftpRequest.SetOutputFile("addons/sourcemod/data/test_ftp_download.txt");
    
ftpRequest.StartRequest(); 
    
delete ftpRequest;
    
    return 
Plugin_Handled;
}

public 
void FtpResponseCallback(bool success, const char[] errorSystem2FTPRequest requestSystem2FTPResponse response) {
    if (
success) {
        
char file[PLATFORM_MAX_PATH];
        
request.GetInputFile(filesizeof(file));

        if (
strlen(file) > 0) {
            
PrintToServer("Download Finished");    
        }
    }

694372459 is offline