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";

callimuc 06-06-2012 04:41 AM

Quote:

Posted by Tricxta (Post 133986)
omy :rolleyes:

Emera, maek me a script that saves the wurld!

As .png or .bmp?

The Doctor 06-06-2012 05:01 AM

Quote:

Posted by callimuc (Post 134626)
As .png or .bmp?

LOL

Emera 06-06-2012 12:09 PM

Quote:

Posted by Tricxta (Post 133986)
omy :rolleyes:

Emera, maek me a script that saves the wurld!

You do know callimuc is actually doing it X_X Good job, look what you've started!

callimuc 06-06-2012 12:56 PM

Quote:

Posted by Emera (Post 134832)
You do know callimuc is actually doing it X_X Good job, look what you've started!

After that delteria crashed <3 Well I'll keep that the easy way :P

Fanta 06-06-2012 11:52 PM

Quick question how do you open it because i don't get how lmao thx if u reply

Emera 06-07-2012 12:14 AM

Quote:

Posted by Fanta (Post 135184)
Quick question how do you open it because i don't get how lmao thx if u reply

Press the space bar.

topsamman 07-21-2012 08:10 AM

this would be cool to use

can you drag it more open and more closed with you cursor or is it just the minimize and maximize?

Emera 07-21-2012 02:53 PM

Quote:

Posted by topsamman (Post 165022)
this would be cool to use

can you drag it more open and more closed with you cursor or is it just the minimize and maximize?

No there is no functionality for that. It's easily done though.

Johnaudi 07-21-2012 04:22 PM

I have learned to make my first GUI by viewing this script <3

Emera 07-21-2012 04:53 PM

Quote:

Posted by Johnaudi (Post 165247)
I have learned to make my first GUI by viewing this script <3

I'm glad it helped you. Good job.


All times are GMT. The time now is 08:35 AM.

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