Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-10-2011, 05:16 AM
pig132 pig132 is offline
professional troll
Join Date: May 2006
Posts: 260
pig132 will become famous soon enough
Downloading files

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

Thank you
Reply With Quote
  #2  
Old 10-10-2011, 05:34 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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);

__________________
Reply With Quote
  #3  
Old 10-10-2011, 11:55 PM
pig132 pig132 is offline
professional troll
Join Date: May 2006
Posts: 260
pig132 will become famous soon enough
Cool, thanks!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:55 PM.


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