Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Downloading files (https://forums.graalonline.com/forums/showthread.php?t=134264756)

pig132 10-10-2011 05:16 AM

Downloading files
 
Is it possible to download a file from a specific URL via gscript?

Thank you ^^

cbk1994 10-10-2011 05:34 AM

Yes, it is. An example from SQL Explorer (all clientside):

PHP Code:

function startFileDownloads() {
  
temp.filesToDownload = {
    {
"sqlexplorer_database-big.png""http://wiki.graal.net/images/3/33/DatabaseSmall.png"},
    {
"sqlexplorer_database-small.png""http://wiki.graal.net/images/d/d2/DatabaseIcon.png"},
    {
"sqlexplorer_loading.gif""http://wiki.graal.net/images/a/a7/GuiBlueLoading.gif"}
  };
 
  for (
temp.fileToDownload temp.filesToDownload) {
    if (
getimgwidth(temp.fileToDownload[0]) <= 0) {
      
// download it
      
this.downloadFile(temp.fileToDownload);
    }
  }
}
 
function 
downloadFile(temp.fileToDownload) {
  
temp.req requestURL(temp.fileToDownload[1]);
  
temp.req.fileName temp.fileToDownload[0];
  
this.catchEvent(temp.req"onReceiveData""onDownloadCompleted");
}
 
function 
onDownloadCompleted(temp.req) {
  
temp.prefix "";
 
  if (
getServerName().starts("Login")) {
    
temp.prefix "scriptfiles/" escapeFileName(getServerName()) @ "/";
  }
 
  
temp.req.fullData.saveString(temp.prefix temp.req.fileNamefalse);



pig132 10-10-2011 11:55 PM

Cool, thanks!


All times are GMT +2. The time now is 04:54 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.