Thread: Screenshots
View Single Post
  #1  
Old 07-30-2011, 03:06 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Screenshots

Here's a script that takes a screenshot and uploads it to the filebrowser.

It currently only works with V6 clients because of the use of makescreenshot2.

Function Documentation:

makescreenshot2(fileName, type, x, y, z, width, height)

PHP Code:
function onActionServerSide() {
  if (
params[0] == "uploadfile") {
    
// Decode Base 64 Data
    
temp.filedata base64decode(params[2]);
    
// Determine Filepath
    
temp.filepath getScreenshotPath();
    
// Determine Filename
    
temp.filename escapefilename(player.account) @ "_" int(timevar2) @ extractfileext(params[1]);
    
// Save File
    
temp.filedata.savestring(temp.filepath temp.filename0);
    
// Alert NC of Success
    
echo("Uploaded Screenshot: " temp.filename);
  }
  else if (
params[0] == "fail") {
    
// Alert NC of Failure
    
echo(player.account SPC "unable to upload screenshot");
  }
}

function 
getScreenshotPath() {
  
temp.folder player.account.substring(02);
  if (
player.account.starts("Graal") && player.account.length() > 6) {
    
temp.folder "Gr" player.account.substring(52);
  }
  return 
format("screenshots/%s/"temp.folder);
}

//#CLIENTSIDE

public function takeScreenshot() {
  
// Generate Random Filename
  
temp.filename int(random(1000000,9999999)) @ ".png";
  
temp.center = {
    
player.- (screenwidth 32),
    
player.- (screenheight 32)
  };
  
// Take Screenshot
  
makescreenshot2(temp.filename0x3ftemp.center[0],temp.center[1],player.z,screenwidth,screenheight);
  
// Check if Screenshot Exists
  
if (fileexists(temp.filename)) {
    
// Upload Screenshot
    
doUpload(temp.filename);
    
// Delete Screenshot
    
deletefile(filename);
  } else {
    
// Screenshot Upload Failed
    // Client is V5 Most Likely
    
triggerserver("gui"this.name"fail");
  }


function 
doUpload(file) {
  
// Load File, Convert to Base 64, Send to Server
  
temp.filedata.loadstring(file);
  
temp.filedata base64encode(temp.filedata);
  
triggerserver("gui"this.name"uploadfile"filetemp.filedata);

You'll also need to set the NPC-Servers folder rights to include:

rw screenshots/*/*.png
__________________
Quote:
Reply With Quote