Graalians

Graalians (https://www.graalians.com/forums/index.php)
-   Creative Corner (https://www.graalians.com/forums/forumdisplay.php?f=17)
-   -   Script: Hat Viewer (https://www.graalians.com/forums/showthread.php?t=7144)

Emera 06-03-2012 11:38 PM

Script: Hat Viewer
 
1 Attachment(s)
This is just a result of my boredom. I'm finding that I'm quite good at channelling my boredom into doing something constructive. Basically, this shows all of the hats in levels/hats (you can change it, don't worry) and shows them as thumbnails. You can click on these thumbnails to set it as your hat and you can right click them to show the whole hat image.

PHP Code:

function onActionServerside() {
  switch(
params[0]) {
    case 
"gethats": {
      
temp.hatfolder.loadfolder("levels/hats/*"true);
      
waitfor(temp.hatfolder.loadfolder""5);
      for (
hats temp.hatfolder.tokenize(",")) {
        
triggerclient("gui"name"gethats"hats);
      }
      break;
    }
  }
}

//#CLIENTSIDE

function onCreated() {
  
drawGUI();
}

function 
drawGUI() {
  
HatViewerWindow.destroy();
  new 
GuiWindowCtrl("HatViewerMain") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
width 500;
    
height 300;
    
clientextent = {widthheight};
    
screenwidth width 2;
    
15;
    
    
canresize canmaximize false;
    
text "Emera's Sexy Hat Viewer [2.0.1]";
    
    new 
GuiScrollCtrl("HatViewerWindow") {
      
profile GuiBlueScrollProfile;
      
width 500;
      
height 270;
      
0;
      
0;
    
      
hscrollbar "alwaysOn";
      
vscrollbar "alwaysOff";
      
visible true;
    
    }
    new 
GuiButtonCtrl("HatViewerButton") {
      
profile GuiBlueButtonProfile;
      
width HatViewerWindow.width 50;
      
height 30;
      
0;
      
HatViewerWindow.HatViewerWindow.height;
      
text "Refresh";
      
visible true;
    }
    new 
GuiButtonCtrl("HatViewerButton2") {
      
profile GuiBlueButtonProfile;
      
width 50;
      
height 30;
      
HatViewerButton.width;
      
HatViewerWindow.HatViewerWindow.height;
      
text "Ext";
      
visible true;
    }
  }
  new 
GuiWindowCtrl("HatViewerPreviewMain") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
width 192;
    
height 144;
    
clientextent = {widthheight};
    
screenwidth width 2;
    
screenheight height 2;
    
    
text "Preview window";
    
canresize canminimize canmaximize visible false;
    
    new 
GuiShowImgCtrl("HatViewerPreviewImage") {
      
width 192;
      
height 144;
      
0;
      
0;
    }
  }
  
  
GetHats();
}

function 
getHats() {
  
this.col = -1;
  
HatViewerWindow.active false;
  
triggerserver("gui"name"gethats");
}

function 
clearHats() {
  for (
HatViewerWindow.controls) {
    
c.destroy();
  }
  
this.col this.row 0;
  
gethats();
}

function 
onActionClientside() {
  switch(
params[0]) {
    case 
"gethats": {
      
this.hatindex++;
      
temp.hat params[1];
      if (
this.col >= 4) {
        
this.col 0;
        
this.row++;
      } else {
        
this.col++;
      }
      
with(HatViewerWindow) {
        new 
GuiShowImgCtrl("HatViewer_Hat_"@thiso.hatindex) {
          
useownprofile true;
          
image temp.hat;
          
width height 48;
          
+ (48 thiso.row);
          
+ (48 thiso.col);
          
partx 96party 0;
          
partw 48parth 48;
          
hint "<b>"@this.image@"</b>";
          
thiso.catchevent(this"onMouseDown""onSetHatDown");
          
thiso.catchevent(this"onRightMouseDown""onPreview");
        }
        
active true;
      }
      break;
    }
  }


function 
onSetHatDown(obj) {
  
player.attr[1] = obj.image;
}

function 
onPreview(obj) {
  
with(HatViewerPreviewMain) {
    
isexternal HatViewerMain.isexternal;
    
text obj.image;
    
visible true;
    
bringtofront();
  }
  
HatViewerPreviewImage.image obj.image;
}
  
function 
onKeyPressed(code) {
  if (
code == 32) {
    
HatViewerMain.visible = !HatViewerMain.visible;
  }
}

function 
HatViewerButton.onMouseDown() {
  
clearHats();
}

function 
HatViewerButton2.onAction() {
  
HatViewerMain.isexternal = !HatViewerMain.isexternal;


Enjoy.

xSuka 06-03-2012 11:39 PM

It's nice! Great work Emera <3

Rexx 06-03-2012 11:43 PM

sexy sex

Twinny 06-04-2012 01:04 AM

Note: NPC-Server will read r rights to the folder in order to do this.

Emera 06-04-2012 01:37 AM

Quote:

Posted by Twinny (Post 133098)
Note: NPC-Server will read r rights to the folder in order to do this.

I forgot to mention that. You will need to add read rights to the folder you're trying scan to load the hats.

The Doctor 06-04-2012 05:51 AM

weapon -Emera/SexyHatViewer has been added!

Emera 06-04-2012 10:21 AM

2 Attachment(s)
For some reason, the external hat preview window won't load the hat image up correctly, and only shows the top row of the hat template. I've got no idea what it's happening since it works perfectly fine with the internal window, but I'll try and come up with a fix.

callimuc 06-04-2012 10:30 AM

PHP Code:

  new GuiWindowCtrl("HatViewerPreviewMain") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
width 192;
    
height 144;
    
clientextent = {widthheight};
    
screenwidth width 2;
    
screenheight height 2;
    
    
text "Preview window";
    
canresize canminimize canmaximize visible false;
    
    new 
GuiShowImgCtrl("HatViewerPreviewImage") {
      
width 192;
      
height 192;
      
0;
      
0;
    } 

Why did you give the HatViewerPreviewImage a higher hight than the HatViewerPreviewMain?

Else I like it and I could try to mess with that on Delteria

Emera 06-04-2012 11:25 AM

Quote:

Posted by callimuc (Post 133392)
PHP Code:

  new GuiWindowCtrl("HatViewerPreviewMain") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
width 192;
    
height 144;
    
clientextent = {widthheight};
    
screenwidth width 2;
    
screenheight height 2;
    
    
text "Preview window";
    
canresize canminimize canmaximize visible false;
    
    new 
GuiShowImgCtrl("HatViewerPreviewImage") {
      
width 192;
      
height 192;
      
0;
      
0;
    } 

Why did you give the HatViewerPreviewImage a higher hight than the HatViewerPreviewMain?

Else I like it and I could try to mess with that on Delteria

0.o I don't have a clue. I must have been dozing off and added the same value as the height lol. The staff there are pretty hyped up on using it, so you'll have to experiment in a different code. The code took literally 15 minutes to make and another 5-10 minutes to tweak correctly. I'm planning on adding some tabs so you can view heads and bodies too.

As you can probably tell, I was being pretty lazy and quick while I was writing this. It was originally for staff on Delteria to use since they liked the idea when I brought it up in a Skype conversation. If I need to I'll rewrite it ;) I'm not usually this lazy with coding.

callimuc 06-04-2012 05:46 PM

Quote:

Posted by Emera (Post 133397)
I'm not usually this lazy with coding.

Sure you are not <3

ZyKo 06-04-2012 06:02 PM

Great work! Your a good scripter, keep it up! ^_^

Ace 06-05-2012 03:51 AM

I like

Tricxta 06-05-2012 04:49 AM

Quote:

Posted by zenTurtle (Post 133567)
Great work! Your a good scripter, keep it up! ^_^

omy :rolleyes:

Emera, maek me a script that saves the wurld!

Talon 06-05-2012 06:33 AM

Hm, great job. I'll have to try this out sometime. I'm currently channeling my energy into learning GS2 with Twinny's tutorial, but I'm still a noob at it. I'll get there soon enough.

The Doctor 06-06-2012 02:24 AM

Quote:

Posted by Agony (Post 134034)
Hm, great job. I'll have to try this out sometime. I'm currently channeling my energy into learning GS2 with Twinny's tutorial, but I'm still a noob at it. I'll get there soon enough.

player.chat = "I'm a noob";


All times are GMT. The time now is 12:41 AM.

Powered by vBulletin/Copyright ©2000 - 2025, vBulletin Solutions Inc.