Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Screenshots (https://forums.graalonline.com/forums/showthread.php?t=134264034)

fowlplay4 07-30-2011 03:06 AM

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


All times are GMT +2. The time now is 06:32 PM.

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