View Single Post
  #1  
Old 03-20-2016, 07:05 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Mainfile Preloader

Here are an NPC and Weapon script which can be used to dynamically store and download mainfiles.

The database NPC is setup to only scan for mainfiles on first creation or when the NPC-Server is restarted.

The weapon script writes to a text file within the player's Graal folder once the first preload has completed, which will prevent future preloads while that text file remains within the Graal directory.

As this involves thousands of files and currently amounts to about 48 MB of filesize, it is strongly suggested to modify this script to an optional action (which can possibly list the total file size) as opposed to being an action carried out by every "fresh directory" login. Another possibility may be to split preloading in to different categories, particularly as the bulk of the file size is from old Classic images.

Also attached are categorised lists of the files which are currently preloaded. In the past it would have been possible to compile this in to a reliable GUPD, however the v6 client requires that the server directory of update package files matches the user's local Graal directory.

DB NPC:
PHP Code:
function onCreated()
  
this.onInitialized();
  
function 
onInitialized() {

  
MainfilePreload this;

  if (
this.cache != NULL)
    return;

  
this.cache = new TStaticVar();
  
this.onScanDirectory("levels/mainfiles");
}

//Trigger event used to bypass max loop limit
function onScanDirectory(temp.dir) {
  
temp.files.loadfolder(temp.dir "/*"0);

  for (
temp.file temp.files) {
    
temp.ext extractFileExt(temp.file);
    
    if (
temp.ext == ".txt")
      continue;
    
    if (
temp.ext != "") {
      
this.cache.fileList.add(temp.file);
      
this.cache.totalFileSize += filesize(temp.file);
    }
    else
      
this.trigger("ScanDirectory"temp.dir "/" temp.file);

  }
    
}

public function 
getFileList()
  return 
this.cache.fileList;

public function 
getTotalFileSize()
  return 
this.cache.totalFileSize
Weapon:

PHP Code:
function onActionServerside(temp.action) {
  
  if (
temp.action != "getFilenames")
    return;
    
  
temp.files MainfilePreload.getFileList();
  
player.triggerClient("gui"this.name"preloadFiles"temp.files);
}

//#CLIENTSIDE
function onCreated() {
  
temp.preload = new TStaticVar();
  
temp.preload.loadvars("mainfile_preload.txt");
  
  if (!
temp.preload.hasPreloaded)
    
triggerServer("gui"this.name"getFilenames");
  
}

function 
onActionClientside(temp.actiontemp.files) {

  if (
temp.action != "preloadFiles")
    return;
    
  for (
temp.file temp.files
    if (!
fileexists(temp.file))
      
fileupdate(temp.file);

  
temp.preload = new TStaticVar();
  
temp.preload.hasPreloaded true;
  
temp.preload.savevars("mainfile_preload.txt"0);

Attached Files
File Type: txt mainfiles_bodies.txt (232 Bytes, 200 views)
File Type: txt mainfiles_fonts.txt (566 Bytes, 202 views)
File Type: txt mainfiles_ganis.txt (843 Bytes, 208 views)
File Type: txt mainfiles_gifs.txt (68.9 KB, 818 views)
File Type: txt mainfiles_heads.txt (12.6 KB, 346 views)
File Type: txt mainfiles_heads_info.txt (14.9 KB, 401 views)
File Type: txt mainfiles_music.txt (530 Bytes, 329 views)
File Type: txt mainfiles_shields.txt (31.7 KB, 355 views)
File Type: txt mainfiles_swords.txt (18.8 KB, 201 views)
File Type: txt mainfiles_wavs.txt (789 Bytes, 251 views)
Reply With Quote