Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-03-2011, 07:47 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
QR Code Generator Problem

I have recently been playing around with googles API for generating QR codes and have thought, hey why not make one in graal.
So I went on my merry way to script it and this is what I have so far, but theres one huge problem... It doesnt display the image, instead it displays some sort of Binary Dump, any suggestions are appriciated.
In case you do not know what a QR code is click here and it will explain it in greater depth, its a 2D image that stores Binary and can be read extremly fast, it was designed for car parts originally but when they realised how powerful it was they then went on to use it for alot more.
Im not even sure if this task can be achieved in the boundaries of GS2 but hey, its worth a shot.

My Script..
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
Generate_Window.destroy();
  
Generated_Window.destroy();
}

function 
onPlayerChats() {
  if (
player.chat == "/generate") {
    if (
Generate_Window.visible == "1") {
      
Generate_Window.destroy();
      return;
    }
    
CreateGenGUI();
  }
}

function 
CreateGeneratedGUI() {
  new 
GuiWindowCtrl("Generated_Window") {
    
profile = GuiBlueWindowProfile;
    
clientrelative = true;
    
clientextent = "300,  250";

    
canclose = true;
    
canmaximize = false;
    
canminimize = false;
    
canmove = false;
    
canresize = false;
    
closequery = false;
    
destroyonhide = false;
    
isexternal = false;
    
text = "Generated QR Code";
    
x = screenwidth / 2 - width / 2;
    
y = screenheight / 2 - height / 2;
    
alpha = 1;

    new 
GuiScrollCtrl("Generated_MultiLine_Scroll") {
      
profile = GuiBlueScrollProfile;
      
height = 249;
      
hscrollbar = "dynamic";
      
vscrollbar = "dynamic";
      
width = 300;
      
x = 0;
      
y = 0;

      new 
GuiMLTextCtrl("Generated_MultiLine") {
        
profile = GuiBlueMLTextProfile;
        
height = 231;
        
horizsizing = "width";
        
text = "<center><br><br><br><br><br>Generating QR Code.<br>Please wait.";
        
width = 296;
      }
    }
  }
}

function 
CreateGenGUI() {
  new 
GuiWindowCtrl("Generate_Window") {
    
profile = GuiBlueWindowProfile;
    
clientrelative = true;
    
clientextent = "150,82";

    
canclose = false;
    
canmaximize = false;
    
canminimize = false;
    
canmove = true;
    
canresize = true;
    
closequery = false;
    
destroyonhide = false;
    
text = " QR Code Generator";
    
x = screenwidth / 2 - width / 2;
    
y = screenheight / 2 - height / 2;

    new 
GuiTextEditCtrl("Generate_Encode") {
      
profile = GuiBlueTextEditProfile;
      
height = 20;
      
width = 137;
      
x = 7;
      
y = 23;
    }
    new 
GuiTextCtrl("Generate_Text") {
      
profile = GuiBlueTextProfile;
      
height = 20;
      
text = "Enter the text to encode!";
      
width = 139;
      
x = 6;
    }
    new 
GuiButtonCtrl("Generate_Generate") {
      
profile = GuiBlueButtonProfile;
      
text = "Generate";
      
width = 137;
      
x = 7;
      
y = 48;
    }
  }
}

function 
Generate_Generate.onAction() {
  if (
Generate_Encode.text != null) {
    
Generated_Window.destroy();
    
Generate_Window.destroy();
    
CreateGeneratedGUI();
    
Generated_MultiLine.text = "<center><br><br><br><br><br>Generating QR Code.<br>Please wait.";
    
temp.req = requesturl("http://chart.apis.google.com/chart?chs=150x150&cht=qr&chld=L|0&chl=" @ Generate_Encode.text @ "");
    
this.catchevent(temp.req, "onReceiveData", "onSiteDownloaded");
  }
}

function 
onSiteDownloaded(obj) {
  
Generated_MultiLine.text = "<img src=" @ obj.fulldata @ ">";
} 
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
 


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 10:58 PM.


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